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>
---
docs/devel/qapi-code-gen.rst | 16 +++++++---------
scripts/qapi/parser.py | 4 ++--
tests/qapi-schema/doc-good.out | 18 ++++++++++++++++++
3 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/docs/devel/qapi-code-gen.rst b/docs/devel/qapi-code-gen.rst
index 3a632b4a648..b1cc5b5f0db 100644
--- a/docs/devel/qapi-code-gen.rst
+++ b/docs/devel/qapi-code-gen.rst
@@ -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 ...
diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
index b7a7b9465a9..9e14c2f7921 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -542,8 +542,8 @@ def get_doc(self) -> 'QAPIDoc':
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:
diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
index 16f44221771..371dd25ffc7 100644
--- a/tests/qapi-schema/doc-good.out
+++ b/tests/qapi-schema/doc-good.out
@@ -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
--
2.54.0