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
py/builtinhelp: Add options for changing help('modules') format.
This commit allow to change count and width of columns for help('modules') output by mpconfigport.h.
Summary
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.
Testing
Tested on unix port.
diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h
index e290935bc..a586c4f81 100644
--- a/ports/unix/mpconfigport.h
+++ b/ports/unix/mpconfigport.h
@@ -121,6 +121,9 @@ typedef long mp_off_t;
// port modtime functions use time_t
#define MICROPY_TIMESTAMP_IMPL (MICROPY_TIMESTAMP_IMPL_TIME_T)
+#define MICROPY_PY_BUILTINS_HELP_NUM_COLUMNS (2)
+#define MICROPY_PY_BUILTINS_HELP_COLUMN_WIDTH (22)
+
// Assume that select() call, interrupted with a signal, and erroring
// with EINTR, updates remaining timeout value.
#define MICROPY_SELECT_REMAINING_TIME (1)
Result:
MicroPython 9b9d8cc783-dirty on 2026-01-28; linux [GCC 13.1.0] version
Type "help()" for more information.
>>> help("modules")
__main__ io
_asyncio json
_thread machine
argparse math
array micropython
asyncio/__init__ mip/__init__
asyncio/core mip/__main__
asyncio/event os
asyncio/funcs platform
asyncio/lock random
asyncio/stream re
binascii requests/__init__
btree select
builtins socket
cmath ssl
collections struct
cryptolib sys
deflate termios
errno time
ffi tls
framebuf uasyncio
gc uctypes
hashlib vfs
heapq websocket
Plus any modules on the filesystem
>>>