Skip to content

Commit

Permalink
qapi: Reject section heading in the middle of a doc comment
Browse files Browse the repository at this point in the history
docs/devel/qapi-code-gen.txt claims "A heading line must be the first
line of the documentation comment block" since commit
55ec69f (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 dcdc07a (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>
  • Loading branch information
Markus Armbruster committed Feb 26, 2024
1 parent 31c54b9 commit 56c64dd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
6 changes: 3 additions & 3 deletions scripts/qapi/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion tests/qapi-schema/doc-good.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

##
# = Section
#
##

##
# == Subsection
#
# *with emphasis*
Expand Down
1 change: 1 addition & 0 deletions tests/qapi-schema/doc-non-first-section.err
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
doc-non-first-section.json:5:1: '=' heading must come first in a comment block
6 changes: 6 additions & 0 deletions tests/qapi-schema/doc-non-first-section.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# = section must be first line

##
#
# = Not first
##
Empty file.

0 comments on commit 56c64dd

Please sign in to comment.