[PATCH v3 22/33] doc/scripts/hxtool.py: Strip trailing ':' from DEFHEADING/ARCHHEADING

Peter Maydell posted 33 patches 5 years, 8 months ago
Maintainers: Aurelien Jarno <aurelien@aurel32.net>, Aleksandar Markovic <amarkovic@wavecomp.com>, Aleksandar Rikalo <aleksandar.rikalo@rt-rk.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, Peter Maydell <peter.maydell@linaro.org>
[PATCH v3 22/33] doc/scripts/hxtool.py: Strip trailing ':' from DEFHEADING/ARCHHEADING
Posted by Peter Maydell 5 years, 8 months ago
In hxtool files, section headings defined with the DEFHEADING
and ARCHHEADING macros have a trailing ':'
  DEFHEADING(Standard options:)

This is for the benefit of the --help output. For consistency
with the rest of the rST documentation, strip any trailing ':'
when we construct headings with the Sphinx hxtool extension.
This makes the table of contents look neater.

This only affects generation of documentation from qemu-options.hx,
which we will start doing in a later commit.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 docs/sphinx/hxtool.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/docs/sphinx/hxtool.py b/docs/sphinx/hxtool.py
index 5d6736f3002..7dd223fe362 100644
--- a/docs/sphinx/hxtool.py
+++ b/docs/sphinx/hxtool.py
@@ -60,8 +60,9 @@ def parse_defheading(file, lnum, line):
     # empty we ignore the directive -- these are used only to add
     # blank lines in the plain-text content of the --help output.
     #
-    # Return the heading text
-    match = re.match(r'DEFHEADING\((.*)\)', line)
+    # Return the heading text. We strip out any trailing ':' for
+    # consistency with other headings in the rST documentation.
+    match = re.match(r'DEFHEADING\((.*?):?\)', line)
     if match is None:
         serror(file, lnum, "Invalid DEFHEADING line")
     return match.group(1)
@@ -72,8 +73,9 @@ def parse_archheading(file, lnum, line):
     # though note that the 'some string' could be the empty string.
     # As with DEFHEADING, empty string ARCHHEADINGs will be ignored.
     #
-    # Return the heading text
-    match = re.match(r'ARCHHEADING\((.*),.*\)', line)
+    # Return the heading text. We strip out any trailing ':' for
+    # consistency with other headings in the rST documentation.
+    match = re.match(r'ARCHHEADING\((.*?):?,.*\)', line)
     if match is None:
         serror(file, lnum, "Invalid ARCHHEADING line")
     return match.group(1)
-- 
2.20.1


Re: [PATCH v3 22/33] doc/scripts/hxtool.py: Strip trailing ':' from DEFHEADING/ARCHHEADING
Posted by Alex Bennée 5 years, 8 months ago
Peter Maydell <peter.maydell@linaro.org> writes:

> In hxtool files, section headings defined with the DEFHEADING
> and ARCHHEADING macros have a trailing ':'
>   DEFHEADING(Standard options:)
>
> This is for the benefit of the --help output. For consistency
> with the rest of the rST documentation, strip any trailing ':'
> when we construct headings with the Sphinx hxtool extension.
> This makes the table of contents look neater.
>
> This only affects generation of documentation from qemu-options.hx,
> which we will start doing in a later commit.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  docs/sphinx/hxtool.py | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/docs/sphinx/hxtool.py b/docs/sphinx/hxtool.py
> index 5d6736f3002..7dd223fe362 100644
> --- a/docs/sphinx/hxtool.py
> +++ b/docs/sphinx/hxtool.py
> @@ -60,8 +60,9 @@ def parse_defheading(file, lnum, line):
>      # empty we ignore the directive -- these are used only to add
>      # blank lines in the plain-text content of the --help output.
>      #
> -    # Return the heading text
> -    match = re.match(r'DEFHEADING\((.*)\)', line)
> +    # Return the heading text. We strip out any trailing ':' for
> +    # consistency with other headings in the rST documentation.
> +    match = re.match(r'DEFHEADING\((.*?):?\)', line)
>      if match is None:
>          serror(file, lnum, "Invalid DEFHEADING line")
>      return match.group(1)
> @@ -72,8 +73,9 @@ def parse_archheading(file, lnum, line):
>      # though note that the 'some string' could be the empty string.
>      # As with DEFHEADING, empty string ARCHHEADINGs will be ignored.
>      #
> -    # Return the heading text
> -    match = re.match(r'ARCHHEADING\((.*),.*\)', line)
> +    # Return the heading text. We strip out any trailing ':' for
> +    # consistency with other headings in the rST documentation.
> +    match = re.match(r'ARCHHEADING\((.*?):?,.*\)', line)
>      if match is None:
>          serror(file, lnum, "Invalid ARCHHEADING line")
>      return match.group(1)


-- 
Alex Bennée