qapi: add doc comment "Intro" section parsing

Add parsing for explicit Intro section syntax.

A side effect of this patch is that we will (currently) always create
an empty Intro section, similar to how we used to have an empty Plain
section. The tests are adjusted accordingly, rendered document output
does not change at all.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-ID: <20260611042332.482979-14-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
John Snow
2026-06-11 00:23:32 -04:00
committed by Markus Armbruster
parent a5635d6181
commit ebb49d4bb6
3 changed files with 27 additions and 11 deletions

View File

@@ -984,11 +984,11 @@ definition it documents.
When documentation is required (see pragma_ 'doc-required'), every
definition must have documentation.
Definition documentation starts with a line naming the definition,
followed by an optional overview, a description of each argument (for
commands and events), member (for structs and unions), branch (for
alternates), or value (for enums), a description of each feature (if
any), and finally optional tagged sections.
Definition documentation starts with a description naming the
definition with an optional indented overview, a description of each
argument (for commands and events), member (for structs and unions),
branch (for alternates), or value (for enums), a description of each
feature (if any), and finally optional tagged sections.
Descriptions start with '\@name:'. The description text must be
indented like this::
@@ -1093,8 +1093,7 @@ Examples of complete definition documentation::
##
# @BlockStats:
#
# Statistics of a virtual block device or a block backing device.
# Statistics of a virtual block device or a block backing device.
#
# @device: If the stats are for a virtual block device, the name
# corresponding to the virtual block device.
@@ -1111,8 +1110,7 @@ Examples of complete definition documentation::
##
# @query-blockstats:
#
# Query the @BlockStats for all virtual block devices.
# Query the @BlockStats for all virtual block devices.
#
# @query-nodes: If true, the command will query all the block nodes
# ... explain, explain ...

View File

@@ -542,8 +542,8 @@ class QAPISchemaParser:
if not symbol:
raise QAPIParseError(self, "name required after '@'")
doc = QAPIDoc(info, symbol)
self.accept(False)
line = self.get_doc_line()
doc.all_sections.append(QAPIDoc.Section(info, QAPIDoc.Kind.INTRO))
line = self.get_doc_indented(doc)
no_more_args = False
while line is not None:

View File

@@ -106,6 +106,8 @@ Examples:
- *verbatim*
- {braces}
doc symbol=Enum
Intro
Member=one
The _one_ {and only}, description on the same line
Member=two
@@ -117,10 +119,14 @@ a member feature
Plain
@two is undocumented
doc symbol=Base
Intro
Member=base1
description starts on a new line,
minimally indented
doc symbol=Variant1
Intro
Plain
A paragraph
@@ -134,10 +140,16 @@ a feature
Feature=member-feat
a member feature
doc symbol=Variant2
Intro
doc symbol=Object
Intro
Feature=union-feat1
a feature
doc symbol=Alternate
Intro
Member=i
description starts on the same line
remainder indented the same
@@ -151,6 +163,8 @@ doc freeform
Another subsection
==================
doc symbol=cmd
Intro
Member=arg1
description starts on a new line,
indented
@@ -198,6 +212,8 @@ Note::
Since
2.10
doc symbol=cmd-boxed
Intro
Plain
If you're bored enough to read this, go see a video of boxed cats
Feature=cmd-feat1
@@ -211,5 +227,7 @@ another feature
<- ... has no title ...
doc symbol=EVT_BOXED
Intro
Feature=feat3
a feature