Rewrite the test doc generator to produce output in source order instead
of arbitrarily by section name.
This patch removes our last use of the "body" field, which has an
effect on how the sections of each test documention block are
printed. We now print the name of the section followed by the section
text for all sections except Members and Features, which are printed
as "Member=%s" or "Feature=%s" followed by the section text,
respectively.
This patch is motivated by a desire to move the QAPIDoc API away from
named fields for specific sections in a bid to force all users to simply
iterate through all_sections in order, instead - and to remove the named
subsections.
Signed-off-by: John Snow <jsnow@redhat.com>
---
tests/qapi-schema/doc-good.out | 82 +++++++++++++++++-----------------
tests/qapi-schema/test-qapi.py | 14 +++---
2 files changed, 48 insertions(+), 48 deletions(-)
diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
index 04a55072646..b9829e2f841 100644
--- a/tests/qapi-schema/doc-good.out
+++ b/tests/qapi-schema/doc-good.out
@@ -54,15 +54,15 @@ event EVT_BOXED Object
boxed=True
feature feat3
doc freeform
- body=
+ Plain
*******
Section
*******
doc freeform
- body=
+ Plain
Just text, no heading.
doc freeform
- body=
+ Plain
Subsection
==========
@@ -106,84 +106,84 @@ Examples:
- *verbatim*
- {braces}
doc symbol=Enum
- body=
+ Plain
- arg=one
+ Member=one
The _one_ {and only}, description on the same line
- arg=two
+ Member=two
- feature=enum-feat
+ Feature=enum-feat
Also _one_ {and only}
- feature=enum-member-feat
+ Feature=enum-member-feat
a member feature
- section=Plain
+ Plain
@two is undocumented
doc symbol=Base
- body=
+ Plain
- arg=base1
+ Member=base1
description starts on a new line,
minimally indented
doc symbol=Variant1
- body=
+ Plain
A paragraph
Another paragraph
@var1 is undocumented
- arg=var1
+ Member=var1
- feature=variant1-feat
+ Feature=variant1-feat
a feature
- feature=member-feat
+ Feature=member-feat
a member feature
doc symbol=Variant2
- body=
+ Plain
doc symbol=Object
- body=
+ Plain
- feature=union-feat1
+ Feature=union-feat1
a feature
doc symbol=Alternate
- body=
+ Plain
- arg=i
+ Member=i
description starts on the same line
remainder indented the same
@b is undocumented
- arg=b
+ Member=b
- feature=alt-feat
+ Feature=alt-feat
a feature
doc freeform
- body=
+ Plain
Another subsection
==================
doc symbol=cmd
- body=
+ Plain
- arg=arg1
+ Member=arg1
description starts on a new line,
indented
- arg=arg2
+ Member=arg2
description starts on the same line
remainder indented differently
- arg=arg3
+ Member=arg3
- feature=cmd-feat1
+ Feature=cmd-feat1
a feature
- feature=cmd-feat2
+ Feature=cmd-feat2
another feature
- section=Plain
+ Plain
.. note:: @arg3 is undocumented
- section=Returns
+ Returns
@Object
- section=Errors
+ Errors
some
- section=Todo
+ Todo
frobnicate
- section=Plain
+ Plain
.. admonition:: Notes
- Lorem ipsum dolor sit amet
@@ -207,23 +207,23 @@ Examples::
Note::
Ceci n'est pas une note
- section=Since
+ Since
2.10
doc symbol=cmd-boxed
- body=
+ Plain
If you're bored enough to read this, go see a video of boxed cats
- feature=cmd-feat1
+ Feature=cmd-feat1
a feature
- feature=cmd-feat2
+ Feature=cmd-feat2
another feature
- section=Plain
+ Plain
.. qmp-example::
-> "this example"
<- ... has no title ...
doc symbol=EVT_BOXED
- body=
+ Plain
- feature=feat3
+ Feature=feat3
a feature
diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
index cf7fb8a6df5..5beb96e894f 100755
--- a/tests/qapi-schema/test-qapi.py
+++ b/tests/qapi-schema/test-qapi.py
@@ -19,6 +19,7 @@
from io import StringIO
from qapi.error import QAPIError
+from qapi.parser import QAPIDoc
from qapi.schema import QAPISchema, QAPISchemaVisitor
@@ -116,13 +117,12 @@ def test_frontend(fname):
print('doc symbol=%s' % doc.symbol)
else:
print('doc freeform')
- print(' body=\n%s' % doc.body.text)
- for arg, section in doc.args.items():
- print(' arg=%s\n%s' % (arg, section.text))
- for feat, section in doc.features.items():
- print(' feature=%s\n%s' % (feat, section.text))
- for section in doc.sections:
- print(' section=%s\n%s' % (section.kind, section.text))
+ for section in doc.all_sections:
+ if isinstance(section, QAPIDoc.ArgSection):
+ print(' %s=%s' % (section.kind, section.name))
+ else:
+ print(' %s' % section.kind)
+ print(section.text)
def open_test_result(dir_name, file_name, update):
--
2.54.0