qapi/parser: don't parse rST markup as section headers
authorJohn Snow <jsnow@redhat.com>
Wed, 26 Jun 2024 22:21:19 +0000 (18:21 -0400)
committerMarkus Armbruster <armbru@redhat.com>
Sat, 6 Jul 2024 06:58:24 +0000 (08:58 +0200)
The double-colon synax is rST formatting that precedes a literal code
block. We do not want to capture these as QAPI-specific sections.

Coerce blocks that start with e.g. "Example::" to be parsed as untagged
paragraphs instead of special tagged sections.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-ID: <20240626222128.406106-14-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Indentation tweaked for consistency]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
scripts/qapi/parser.py
tests/qapi-schema/doc-good.json
tests/qapi-schema/doc-good.out
tests/qapi-schema/doc-good.txt

index 0a13f0f541ac91a5a31556a1311600e5f3148caa..6ad5663e5455a1361432f7082eead19b8c683fa7 100644 (file)
@@ -544,10 +544,15 @@ class QAPISchemaParser:
                         line = self.get_doc_indented(doc)
                     no_more_args = True
                 elif match := re.match(
-                        r'(Returns|Errors|Since|Notes?|Examples?|TODO): *',
-                        line):
+                        r'(Returns|Errors|Since|Notes?|Examples?|TODO)'
+                        r'(?!::): *',
+                        line,
+                ):
                     # tagged section
 
+                    # Note: "sections" with two colons are left alone as
+                    # rST markup and not interpreted as a section heading.
+
                     # TODO: Remove this error sometime in 2025 or so
                     # after we've fully transitioned to the new qapidoc
                     # generator.
index 32ff910b4f82bcc69bb365e8268f10dbe81575e3..b56589585873cfbd6a21ea6e41db31238a0ce55c 100644 (file)
 #  - *verbatim*
 #  - {braces}
 #
+# Note::
+#     Ceci n'est pas une note
+#
 # Since: 2.10
 ##
 { 'command': 'cmd',
index 631dc9f8dadc4002562fd574c719f6ec35edd29c..a8e9456f60d6b8d6117ea01c534333c7548a3b66 100644 (file)
@@ -190,6 +190,9 @@ frobnicate
     section=Examples
  - *verbatim*
  - {braces}
+    section=None
+Note::
+    Ceci n'est pas une note
     section=Since
 2.10
 doc symbol=cmd-boxed
index d8bfa742c2f542d2eaf617cec1538698940978ae..30d457e5488283b2a5f97c6e9a6824b15f14839a 100644 (file)
@@ -231,6 +231,9 @@ Examples
    - *verbatim*
    - {braces}
 
+Note::
+   Ceci n'est pas une note
+
 
 Since
 ~~~~~