py/builtinhelp: Add options for changing help('modules') format.
Description
Hello, MicoPython community.
We are porting MicroPython on our device. We recently ran into a problem. Width of screen of our device is so small. Default format of help('modules') is poorly displayed. We would like to be able to change it by NUM_COLUMNS and COLUMN_WIDTH.
https://github.com/micropython/micropython/pull/18734
Code Size
No response
Implementation
I intend to implement this feature and would submit a Pull Request if desirable
Code of Conduct
Yes, I agree
Implement help('modules') to list available modules
This is how CPython does it, and it's very useful to help users discover the available modules for a given port, especially built-in and frozen modules (and module weak links). The function does not list modules that are in the filesystem because this would require a fair bit of work to do correctly, and is very port specific (depending on the filesystem).
Note that there is no additional config option for this feature, because pyhelp.c is already optional, and if a port wants to implement help() then it's highly likely they want this feature (and users should be allowed to rely on this feature so they can discover modules on a given board).
Example output on pyboard:
>>> help('modules')
__main__ json stm umachine
array lcd160cr struct uos
binascii machine sys urandom
builtins math time ure
cmath micropython ubinascii uselect
collections network ucollections usocket
errno os uctypes ustruct
framebuf pyb uerrno utime
gc random uhashlib utimeq
hashlib re uheapq uzlib
heapq select uio zlib
io socket ujson
Plus any modules on the filesystem