public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: fix formatting for help set/show extended-prompt
@ 2022-02-02 15:02 Andrew Burgess
  2022-02-02 16:06 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Burgess @ 2022-02-02 15:02 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

The formatting of the help text for 'help set extended-prompt' and
'help show extended-prompt' is a little off.

Here's the offending snippet:

    Substitutions are applied to VALUE to compute the real prompt.

    The currently defined substitutions are:
      \[	Begins a sequence of non-printing characters.
  \\	A backslash.
  \]	Ends a sequence of non-printing characters.
  \e	The ESC character.

Notice that the line for '\[' is indented more that the others.

Turns out this is due to how we build this help text, something which
is done in Python.  We extended a classes __doc__ string with some
dynamically generated text.

The classes doc string looks like this:

    """Set the extended prompt.

    Usage: set extended-prompt VALUE

    Substitutions are applied to VALUE to compute the real prompt.

    The currently defined substitutions are:
    """

Notice the closing """ are in a line of their own, and include some
white space just before.  It's this extra white space that's causing
the problem.

Fix the formatting issue by moving the """ to the end of the previous
line.  I then add the extra newline in at the point where the doc
string is merged with the dynamically generated text.

Now everything lines up correctly.
---
 gdb/python/lib/gdb/command/prompt.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/gdb/python/lib/gdb/command/prompt.py b/gdb/python/lib/gdb/command/prompt.py
index 1491c6a3e65..8dfa8ed91ef 100644
--- a/gdb/python/lib/gdb/command/prompt.py
+++ b/gdb/python/lib/gdb/command/prompt.py
@@ -28,12 +28,11 @@ class _ExtendedPrompt(gdb.Parameter):
 
     Substitutions are applied to VALUE to compute the real prompt.
 
-    The currently defined substitutions are:
-    """
+    The currently defined substitutions are:"""
 
     # Add the prompt library's dynamically generated help to the
     # __doc__ string.
-    __doc__ = __doc__ + gdb.prompt.prompt_help()
+    __doc__ = __doc__ + "\n" + gdb.prompt.prompt_help()
 
     set_doc = "Set the extended prompt."
     show_doc = "Show the extended prompt."
-- 
2.25.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] gdb: fix formatting for help set/show extended-prompt
  2022-02-02 15:02 [PATCH] gdb: fix formatting for help set/show extended-prompt Andrew Burgess
@ 2022-02-02 16:06 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2022-02-02 16:06 UTC (permalink / raw)
  To: Andrew Burgess via Gdb-patches; +Cc: Andrew Burgess

>>>>> "Andrew" == Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> writes:

Andrew> Fix the formatting issue by moving the """ to the end of the previous
Andrew> line.  I then add the extra newline in at the point where the doc
Andrew> string is merged with the dynamically generated text.

Looks good, thank you.

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-02 16:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-02 15:02 [PATCH] gdb: fix formatting for help set/show extended-prompt Andrew Burgess
2022-02-02 16:06 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).