From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Ani Sinha" <anisinha@redhat.com>,
"Michael Roth" <michael.roth@amd.com>,
"Igor Mammedov" <imammedo@redhat.com>,
"John Snow" <jsnow@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Eric Blake" <eblake@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@mailo.com>,
"Mauro Carvalho Chehab" <mchehab+huawei@kernel.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
linux-edac@vger.kernel.org, "Cleber Rosa" <crosa@redhat.com>
Subject: [PATCH v3 02/16] tests/qapi: generate output in source order
Date: Tue, 2 Jun 2026 23:21:47 -0400 [thread overview]
Message-ID: <20260603032201.993015-3-jsnow@redhat.com> (raw)
In-Reply-To: <20260603032201.993015-1-jsnow@redhat.com>
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
next prev parent reply other threads:[~2026-06-03 3:22 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 3:21 [PATCH v3 00/16] qapi: add formal "intro" section John Snow
2026-06-03 3:21 ` [PATCH v3 01/16] python: temporarily restrict max mypy version John Snow
2026-06-03 3:21 ` John Snow [this message]
2026-06-03 3:21 ` [PATCH v3 03/16] qapi/docs: remove unused QAPIDoc subsection members John Snow
2026-06-03 3:21 ` [PATCH v3 04/16] qapi/docs: add has_features property John Snow
2026-06-03 3:21 ` [PATCH v3 05/16] qapi/docs: make remaining subsection members "private" John Snow
2026-06-03 3:21 ` [PATCH v3 06/16] qapi/docs: fix comment phrasing John Snow
2026-06-03 3:21 ` [PATCH v3 07/16] qapi/docs: add "Intro" section John Snow
2026-06-03 3:21 ` [PATCH v3 08/16] qapi/parser: move _insert_near_kind() method John Snow
2026-06-03 3:21 ` [PATCH v3 09/16] qapi/docs: adjust stub member insertion algorithm John Snow
2026-06-03 11:27 ` Markus Armbruster
2026-06-03 3:21 ` [PATCH v3 10/16] qapi/docs: remove implicit Plain section John Snow
2026-06-03 3:21 ` [PATCH v3 11/16] qapi/docs: add rendering for INTRO sections John Snow
2026-06-03 3:21 ` [PATCH v3 12/16] qapi/docs: add "Intro" section parsing John Snow
2026-06-03 3:21 ` [PATCH v3 13/16] qapi: convert intro sections for accelerator.json John Snow
2026-06-03 3:21 ` [PATCH v3 14/16] qapi: convert intro sections for acpi-hest.json John Snow
2026-06-03 3:22 ` [PATCH v3 15/16] qapi: convert intro sections for acpi.json John Snow
2026-06-03 3:22 ` [PATCH v3 16/16] qapi: convert intro sections for audio.json John Snow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260603032201.993015-3-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=anisinha@redhat.com \
--cc=armbru@redhat.com \
--cc=crosa@redhat.com \
--cc=eblake@redhat.com \
--cc=imammedo@redhat.com \
--cc=kraxel@redhat.com \
--cc=linux-edac@vger.kernel.org \
--cc=marcandre.lureau@redhat.com \
--cc=mchehab+huawei@kernel.org \
--cc=michael.roth@amd.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=philmd@mailo.com \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox