The help text can have lists, like in the boot command[1] and printing this as normal text messes up the formatting. Therefore, let's just print it as a code block.
This doesn't solve interleaved output like fiptool's, but it makes e.g. the boot help text or menu actually readable. [1]: https://www.barebox.org/doc/latest/commands/boot/boot.html Signed-off-by: Ahmad Fatoum <[email protected]> --- Documentation/gen_commands.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Documentation/gen_commands.py b/Documentation/gen_commands.py index 2f15c8b40540..f8a7ed7b879f 100755 --- a/Documentation/gen_commands.py +++ b/Documentation/gen_commands.py @@ -57,7 +57,7 @@ def parse_c(name): elif x := HELP_TEXT.match(line): last = cmd['h_post' if 'h_opts' in cmd else 'h_pre'] - last.append(string_escape(x.group(1)).strip()) + last.append(string_escape_literal(x.group(1)).strip()) elif x := HELP_OPT.match(line): last = cmd['h_opts'] @@ -123,7 +123,8 @@ def gen_rst(name, cmd): if pre: out.append('Synopsis') out.append('^' * len(out[-1])) - out.append('\n'.join(cmd['h_pre']).strip()) + out.append('\n::\n') + out.append('\n'.join([f' {s}' for s in cmd['h_pre']])) out.append('') if 'h_opts' in cmd: out.append('Options') @@ -144,7 +145,8 @@ def gen_rst(name, cmd): if post: out.append('Description') out.append('^' * len(out[-1])) - out.append('\n'.join(cmd['h_post']).strip()) + out.append('\n::\n') + out.append('\n'.join([f' {s}' for s in cmd['h_post']])) out.append('') out.append('.. generated from: %s' % ', '.join(cmd['files'])) if 'c_func' in cmd: -- 2.47.3
