From: Markus Armbruster <armbru@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: qemu-devel@nongnu.org, "Michael Roth" <michael.roth@amd.com>,
"Eric Blake" <eblake@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Mauro Carvalho Chehab" <mchehab+huawei@kernel.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
"Igor Mammedov" <imammedo@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Ani Sinha" <anisinha@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: Re: [PATCH v2 03/13] qapi/docs: make remaining subsection members "private"
Date: Mon, 04 May 2026 11:54:52 +0200 [thread overview]
Message-ID: <87cxzbbitv.fsf@pond.sub.org> (raw)
In-Reply-To: <20260429192611.1581223-4-jsnow@redhat.com> (John Snow's message of "Wed, 29 Apr 2026 15:26:01 -0400")
John Snow <jsnow@redhat.com> writes:
> These fields are used to provide error checking and internal logistics
> and should not be used by a user of the library to directly access
> documentation sections, so make them private.
>
> The "since" field alone is left public, as the qapidoc generator does
> use this field to pull that section out of the regular flow of the
> document.
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
> scripts/qapi/parser.py | 54 +++++++++++++++++++++++-------------------
> 1 file changed, 29 insertions(+), 25 deletions(-)
>
> diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
> index b33edbba74f..da4756a7424 100644
> --- a/scripts/qapi/parser.py
> +++ b/scripts/qapi/parser.py
> @@ -555,7 +555,7 @@ def get_doc(self) -> 'QAPIDoc':
> break
> # Non-blank line, first of a section
> if line == 'Features:':
> - if doc.features:
> + if doc.has_features:
> raise QAPIParseError(
> self, "duplicated 'Features:' line")
> self.accept(False)
> @@ -570,7 +570,7 @@ def get_doc(self) -> 'QAPIDoc':
> if text:
> doc.append_line(text)
> line = self.get_doc_indented(doc)
> - if not doc.features:
> + if not doc.has_features:
> raise QAPIParseError(
> self, 'feature descriptions expected')
> no_more_args = True
These two hunks along with the one adding .has_features() below make the
patch not purely mechanical. Separate patch, please.
Have you considered using a local bool variable instead?
> @@ -733,14 +733,18 @@ def __init__(self, info: QAPISourceInfo, symbol: Optional[str] = None):
> QAPIDoc.Section(info, QAPIDoc.Kind.PLAIN)
> ]
> # dicts mapping parameter/feature names to their description
> - self.args: Dict[str, QAPIDoc.ArgSection] = {}
> - self.features: Dict[str, QAPIDoc.ArgSection] = {}
> + self._args: Dict[str, QAPIDoc.ArgSection] = {}
> + self._features: Dict[str, QAPIDoc.ArgSection] = {}
> # a command's "Returns" and "Errors" section
> - self.returns: Optional[QAPIDoc.Section] = None
> - self.errors: Optional[QAPIDoc.Section] = None
> + self._returns: Optional[QAPIDoc.Section] = None
> + self._errors: Optional[QAPIDoc.Section] = None
> # "Since" section
> self.since: Optional[QAPIDoc.Section] = None
>
> + @property
> + def has_features(self) -> bool:
> + return bool(self._features)
> +
> def end(self) -> None:
> for section in self.all_sections:
> section.text = section.text.strip('\n')
> @@ -771,15 +775,15 @@ def new_tagged_section(
> ) -> None:
> section = self.Section(info, kind)
> if kind == QAPIDoc.Kind.RETURNS:
> - if self.returns:
> + if self._returns:
> raise QAPISemError(
> info, "duplicated '%s' section" % kind)
> - self.returns = section
> + self._returns = section
> elif kind == QAPIDoc.Kind.ERRORS:
> - if self.errors:
> + if self._errors:
> raise QAPISemError(
> info, "duplicated '%s' section" % kind)
> - self.errors = section
> + self._errors = section
> elif kind == QAPIDoc.Kind.SINCE:
> if self.since:
> raise QAPISemError(
> @@ -803,16 +807,16 @@ def _new_description(
> desc[name] = section
>
> def new_argument(self, info: QAPISourceInfo, name: str) -> None:
> - self._new_description(info, name, QAPIDoc.Kind.MEMBER, self.args)
> + self._new_description(info, name, QAPIDoc.Kind.MEMBER, self._args)
>
> def new_feature(self, info: QAPISourceInfo, name: str) -> None:
> - self._new_description(info, name, QAPIDoc.Kind.FEATURE, self.features)
> + self._new_description(info, name, QAPIDoc.Kind.FEATURE, self._features)
>
> def append_line(self, line: str) -> None:
> self.all_sections[-1].append_line(line)
>
> def connect_member(self, member: 'QAPISchemaMember') -> None:
> - if member.name not in self.args:
> + if member.name not in self._args:
> assert member.info
> if self.symbol not in member.info.pragma.documentation_exceptions:
> raise QAPISemError(member.info,
> @@ -823,7 +827,7 @@ def connect_member(self, member: 'QAPISchemaMember') -> None:
>
> section = QAPIDoc.ArgSection(
> self.info, QAPIDoc.Kind.MEMBER, member.name)
> - self.args[member.name] = section
> + self._args[member.name] = section
>
> # Determine where to insert stub doc - it should go at the
> # end of the members section(s), if any. Note that index 0
> @@ -835,14 +839,14 @@ def connect_member(self, member: 'QAPISchemaMember') -> None:
> index += 1
> self.all_sections.insert(index, section)
>
> - self.args[member.name].connect(member)
> + self._args[member.name].connect(member)
>
> def connect_feature(self, feature: 'QAPISchemaFeature') -> None:
> - if feature.name not in self.features:
> + if feature.name not in self._features:
> raise QAPISemError(feature.info,
> "feature '%s' lacks documentation"
> % feature.name)
> - self.features[feature.name].connect(feature)
> + self._features[feature.name].connect(feature)
>
> def ensure_returns(self, info: QAPISourceInfo) -> None:
>
> @@ -883,18 +887,18 @@ def _insert_near_kind(
>
> def check_expr(self, expr: QAPIExpression) -> None:
> if 'command' in expr:
> - if self.returns and 'returns' not in expr:
> + if self._returns and 'returns' not in expr:
> raise QAPISemError(
> - self.returns.info,
> + self._returns.info,
> "'Returns' section, but command doesn't return anything")
> else:
> - if self.returns:
> + if self._returns:
> raise QAPISemError(
> - self.returns.info,
> + self._returns.info,
> "'Returns' section is only valid for commands")
> - if self.errors:
> + if self._errors:
> raise QAPISemError(
> - self.errors.info,
> + self._errors.info,
> "'Errors' section is only valid for commands")
>
> def check(self) -> None:
> @@ -914,5 +918,5 @@ def check_args_section(
> "do" if len(bogus) > 1 else "does"
> ))
>
> - check_args_section(self.args, 'member')
> - check_args_section(self.features, 'feature')
> + check_args_section(self._args, 'member')
> + check_args_section(self._features, 'feature')
next prev parent reply other threads:[~2026-05-04 9:55 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 19:25 [PATCH v2 00/13] qapi: add formal "intro" section John Snow
2026-04-29 19:25 ` [PATCH v2 01/13] tests/qapi: generate output in source order John Snow
2026-05-04 9:50 ` Markus Armbruster
2026-05-04 17:55 ` John Snow
2026-04-29 19:26 ` [PATCH v2 02/13] qapi/docs: remove unused QAPIDoc subsection members John Snow
2026-05-04 9:51 ` Markus Armbruster
2026-04-29 19:26 ` [PATCH v2 03/13] qapi/docs: make remaining subsection members "private" John Snow
2026-05-04 9:54 ` Markus Armbruster [this message]
2026-05-04 18:07 ` John Snow
2026-04-29 19:26 ` [PATCH v2 04/13] qapi/docs: add "Intro" section John Snow
2026-04-29 19:26 ` [PATCH v2 05/13] qapi/docs: adjust stub member insertion algorithm John Snow
2026-05-04 11:20 ` Markus Armbruster
2026-05-04 18:30 ` John Snow
2026-05-05 13:54 ` Markus Armbruster
2026-05-04 18:33 ` John Snow
2026-04-29 19:26 ` [PATCH v2 06/13] qapi/docs: remove implicit Plain section John Snow
2026-04-29 19:26 ` [PATCH v2 07/13] qapi/docs: add "Intro" section parsing John Snow
2026-05-04 11:57 ` Markus Armbruster
2026-05-04 18:44 ` John Snow
2026-05-05 13:30 ` Markus Armbruster
2026-04-29 19:26 ` [PATCH v2 08/13] qapi/docs: Add rendering for INTRO sections John Snow
2026-05-04 12:05 ` Markus Armbruster
2026-05-12 21:13 ` John Snow
2026-05-13 6:25 ` Markus Armbruster
2026-04-29 19:26 ` [PATCH v2 09/13] qapi: convert intro sections for accelerator.json John Snow
2026-04-29 19:26 ` [PATCH v2 10/13] qapi: convert intro sections for acpi-hest.json John Snow
2026-04-29 19:26 ` [PATCH v2 11/13] qapi: convert intro sections for acpi.json John Snow
2026-04-29 19:26 ` [PATCH v2 12/13] qapi: convert intro sections for audio.json John Snow
2026-04-29 19:26 ` [PATCH v2 13/13] rfc: intro starts on next line 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=87cxzbbitv.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=anisinha@redhat.com \
--cc=eblake@redhat.com \
--cc=imammedo@redhat.com \
--cc=jsnow@redhat.com \
--cc=kraxel@redhat.com \
--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=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