Browse Source

qapi: Reject section heading in the middle of a doc comment

docs/devel/qapi-code-gen.txt claims "A heading line must be the first
line of the documentation comment block" since commit
55ec69f8b16 (docs/devel/qapi-code-gen.txt: Update to new rST backend
conventions).  Not true, we have code to make it work anywhere in a
free-form doc comment: commit dcdc07a97cb (qapi: Make section headings
start a new doc comment block).

Make it true, for simplicity's sake.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20240216145841.2099240-10-armbru@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Markus Armbruster 1 year ago
parent
commit
56c64dd60a

+ 3 - 3
scripts/qapi/parser.py

@@ -440,9 +440,9 @@ def get_doc(self, info: QAPISourceInfo) -> List['QAPIDoc']:
                         self,
                         "unexpected '=' markup in definition documentation")
                 if cur_doc.body.text:
-                    cur_doc.end_comment()
-                    docs.append(cur_doc)
-                    cur_doc = QAPIDoc(self, info)
+                    raise QAPIParseError(
+                        self,
+                        "'=' heading must come first in a comment block")
             cur_doc.append(self.val)
             self.accept(False)
 

+ 3 - 1
tests/qapi-schema/doc-good.json

@@ -9,7 +9,9 @@
 
 ##
 # = Section
-#
+##
+
+##
 # == Subsection
 #
 # *with emphasis*

+ 1 - 0
tests/qapi-schema/doc-non-first-section.err

@@ -0,0 +1 @@
+doc-non-first-section.json:5:1: '=' heading must come first in a comment block

+ 6 - 0
tests/qapi-schema/doc-non-first-section.json

@@ -0,0 +1,6 @@
+# = section must be first line
+
+##
+#
+# = Not first
+##

+ 0 - 0
tests/qapi-schema/doc-non-first-section.out