From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: michael.roth@amd.com, jsnow@redhat.com, eblake@redhat.com,
peter.maydell@linaro.org
Subject: [PATCH 08/16] qapi: Rename QAPIDoc.Section.name to .tag
Date: Fri, 16 Feb 2024 15:58:32 +0100 [thread overview]
Message-ID: <20240216145841.2099240-9-armbru@redhat.com> (raw)
In-Reply-To: <20240216145841.2099240-1-armbru@redhat.com>
Since the previous commit, QAPIDoc.Section.name is either
None (untagged section) or the section's tag string ('Returns',
'@name', ...). Rename it to .tag.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
docs/sphinx/qapidoc.py | 6 +++---
scripts/qapi/parser.py | 30 +++++++++++++++---------------
tests/qapi-schema/test-qapi.py | 2 +-
3 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/docs/sphinx/qapidoc.py b/docs/sphinx/qapidoc.py
index 1e8b4a70a1..8d428c64b0 100644
--- a/docs/sphinx/qapidoc.py
+++ b/docs/sphinx/qapidoc.py
@@ -258,11 +258,11 @@ def _nodes_for_sections(self, doc):
"""Return list of doctree nodes for additional sections"""
nodelist = []
for section in doc.sections:
- if section.name and section.name == 'TODO':
+ if section.tag and section.tag == 'TODO':
# Hide TODO: sections
continue
- snode = self._make_section(section.name)
- if section.name and section.name.startswith('Example'):
+ snode = self._make_section(section.tag)
+ if section.tag and section.tag.startswith('Example'):
snode += self._nodes_for_example(section.text)
else:
self._parse_text_into_node(section.text, snode)
diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
index 43daf55860..cc69f4f770 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -471,17 +471,17 @@ class QAPIDoc:
class Section:
# pylint: disable=too-few-public-methods
def __init__(self, parser: QAPISchemaParser,
- name: Optional[str] = None):
+ tag: Optional[str] = None):
# section source info, i.e. where it begins
self.info = parser.info
# parser, for error messages about indentation
self._parser = parser
# section tag, if any ('Returns', '@name', ...)
- self.name = name
+ self.tag = tag
# section text without tag
self.text = ''
# indentation to strip (None means indeterminate)
- self._indent = None if self.name else 0
+ self._indent = None if self.tag else 0
def append(self, line: str) -> None:
line = line.rstrip()
@@ -504,8 +504,8 @@ def append(self, line: str) -> None:
class ArgSection(Section):
def __init__(self, parser: QAPISchemaParser,
- name: str):
- super().__init__(parser, name)
+ tag: str):
+ super().__init__(parser, tag)
self.member: Optional['QAPISchemaMember'] = None
def connect(self, member: 'QAPISchemaMember') -> None:
@@ -536,10 +536,10 @@ def __init__(self, parser: QAPISchemaParser, info: QAPISourceInfo):
self._section = self.body
self._append_line = self._append_body_line
- def has_section(self, name: str) -> bool:
- """Return True if we have a section with this name."""
+ def has_section(self, tag: str) -> bool:
+ """Return True if we have a section with this tag."""
for i in self.sections:
- if i.name == name:
+ if i.tag == tag:
return True
return False
@@ -710,11 +710,11 @@ def _start_args_section(self, name: str) -> None:
def _start_features_section(self, name: str) -> None:
self._start_symbol_section(self.features, name)
- def _start_section(self, name: Optional[str] = None) -> None:
- if name in ('Returns', 'Since') and self.has_section(name):
+ def _start_section(self, tag: Optional[str] = None) -> None:
+ if tag in ('Returns', 'Since') and self.has_section(tag):
raise QAPIParseError(self._parser,
- "duplicated '%s' section" % name)
- new_section = QAPIDoc.Section(self._parser, name)
+ "duplicated '%s' section" % tag)
+ new_section = QAPIDoc.Section(self._parser, tag)
self._switch_section(new_section)
self.sections.append(new_section)
@@ -726,10 +726,10 @@ def _switch_section(self, new_section: 'QAPIDoc.Section') -> None:
if self._section != self.body and not text:
# We do not create anonymous sections unless there is
# something to put in them; this is a parser bug.
- assert self._section.name
+ assert self._section.tag
raise QAPISemError(
self._section.info,
- "text required after '%s:'" % self._section.name)
+ "text required after '%s:'" % self._section.tag)
self._section = new_section
@@ -761,7 +761,7 @@ def connect_feature(self, feature: 'QAPISchemaFeature') -> None:
def check_expr(self, expr: QAPIExpression) -> None:
if 'command' not in expr:
sec = next((sec for sec in self.sections
- if sec.name == 'Returns'),
+ if sec.tag == 'Returns'),
None)
if sec:
raise QAPISemError(sec.info,
diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
index 14f7b62a44..40095431ae 100755
--- a/tests/qapi-schema/test-qapi.py
+++ b/tests/qapi-schema/test-qapi.py
@@ -130,7 +130,7 @@ def test_frontend(fname):
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.name, section.text))
+ print(' section=%s\n%s' % (section.tag, section.text))
def open_test_result(dir_name, file_name, update):
--
2.43.0
next prev parent reply other threads:[~2024-02-16 15:04 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-16 14:58 [PATCH 00/16] qapi: Doc comment parsing & doc generation work Markus Armbruster
2024-02-16 14:58 ` [PATCH 01/16] tests/qapi-schema: Fix test 'QAPI rST doc' Markus Armbruster
2024-02-20 15:11 ` Daniel P. Berrangé
2024-02-16 14:58 ` [PATCH 02/16] tests/qapi-schema: Cover duplicate 'Features:' line Markus Armbruster
2024-02-20 15:12 ` Daniel P. Berrangé
2024-02-16 14:58 ` [PATCH 03/16] tests/qapi-schema: Cover 'Features:' not followed by descriptions Markus Armbruster
2024-02-20 15:12 ` Daniel P. Berrangé
2024-02-16 14:58 ` [PATCH 04/16] sphinx/qapidoc: Drop code to generate doc for simple union branch Markus Armbruster
2024-02-20 15:13 ` Daniel P. Berrangé
2024-02-16 14:58 ` [PATCH 05/16] qapi: Improve error position for bogus argument descriptions Markus Armbruster
2024-02-20 15:14 ` Daniel P. Berrangé
2024-02-16 14:58 ` [PATCH 06/16] qapi: Improve error position for bogus invalid "Returns" section Markus Armbruster
2024-02-20 15:15 ` Daniel P. Berrangé
2024-02-16 14:58 ` [PATCH 07/16] qapi: Improve error message for empty doc sections Markus Armbruster
2024-02-20 15:16 ` Daniel P. Berrangé
2024-02-16 14:58 ` Markus Armbruster [this message]
2024-02-20 15:17 ` [PATCH 08/16] qapi: Rename QAPIDoc.Section.name to .tag Daniel P. Berrangé
2024-02-16 14:58 ` [PATCH 09/16] qapi: Reject section heading in the middle of a doc comment Markus Armbruster
2024-02-20 15:18 ` Daniel P. Berrangé
2024-02-16 14:58 ` [PATCH 10/16] qapi: Require descriptions and tagged sections to be indented Markus Armbruster
2024-02-20 15:19 ` Daniel P. Berrangé
2024-02-16 14:58 ` [PATCH 11/16] qapi: Recognize section tags and 'Features:' only after blank line Markus Armbruster
2024-02-20 15:22 ` Daniel P. Berrangé
2024-02-20 16:06 ` Markus Armbruster
2024-02-20 16:13 ` Daniel P. Berrangé
2024-02-16 14:58 ` [PATCH 12/16] qapi: Call QAPIDoc.check() always Markus Armbruster
2024-02-20 15:22 ` Daniel P. Berrangé
2024-02-16 14:58 ` [PATCH 13/16] qapi: Merge adjacent untagged sections Markus Armbruster
2024-02-20 15:23 ` Daniel P. Berrangé
2024-02-16 14:58 ` [PATCH 14/16] qapi: Rewrite doc comment parser Markus Armbruster
2024-02-20 16:18 ` Daniel P. Berrangé
2024-02-22 8:55 ` Markus Armbruster
2024-02-16 14:58 ` [PATCH 15/16] qapi: Reject multiple and empty feature descriptions Markus Armbruster
2024-02-20 15:24 ` Daniel P. Berrangé
2024-02-16 14:58 ` [PATCH 16/16] qapi: Divorce QAPIDoc from QAPIParseError Markus Armbruster
2024-02-20 15:25 ` Daniel P. Berrangé
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=20240216145841.2099240-9-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=jsnow@redhat.com \
--cc=michael.roth@amd.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).