mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 4/5] Documentation: gen_commands.py: use literal block for help text
Date: Fri, 24 Oct 2025 11:07:05 +0200	[thread overview]
Message-ID: <20251024090708.2476109-4-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20251024090708.2476109-1-a.fatoum@pengutronix.de>

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 <a.fatoum@pengutronix.de>
---
 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




  parent reply	other threads:[~2025-10-24  9:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-24  9:07 [PATCH 1/5] Documentation: gen_commands.py: escape special characters Ahmad Fatoum
2025-10-24  9:07 ` [PATCH 2/5] Documentation: gen_commands.py: align whitespace with coding style Ahmad Fatoum
2025-10-24  9:07 ` [PATCH 3/5] Documentation: gen_commands.py: rework if statements for compactness Ahmad Fatoum
2025-10-24  9:07 ` Ahmad Fatoum [this message]
2025-10-24  9:07 ` [PATCH 5/5] Documentation: gen_commands.py: escape name in title Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251024090708.2476109-4-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox