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 07/16] qapi: Improve error message for empty doc sections
Date: Fri, 16 Feb 2024 15:58:31 +0100 [thread overview]
Message-ID: <20240216145841.2099240-8-armbru@redhat.com> (raw)
In-Reply-To: <20240216145841.2099240-1-armbru@redhat.com>
Improve the message for an empty tagged section from
empty doc section 'Note'
to
text required after 'Note:'
and the message for an empty argument or feature description from
empty doc section 'foo'
to
text required after '@foo:'
Improve the error position to refer to the beginning of the empty
section instead of its end.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
docs/sphinx/qapidoc.py | 4 ++--
scripts/qapi/parser.py | 14 +++++++-------
tests/qapi-schema/doc-empty-section.err | 2 +-
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/docs/sphinx/qapidoc.py b/docs/sphinx/qapidoc.py
index 488de23d72..1e8b4a70a1 100644
--- a/docs/sphinx/qapidoc.py
+++ b/docs/sphinx/qapidoc.py
@@ -239,8 +239,8 @@ def _nodes_for_features(self, doc):
seen_item = False
dlnode = nodes.definition_list()
for section in doc.features.values():
- dlnode += self._make_dlitem([nodes.literal('', section.name)],
- section.text)
+ dlnode += self._make_dlitem(
+ [nodes.literal('', section.member.name)], section.text)
seen_item = True
if not seen_item:
diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
index a771013959..43daf55860 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -476,9 +476,9 @@ def __init__(self, parser: QAPISchemaParser,
self.info = parser.info
# parser, for error messages about indentation
self._parser = parser
- # optional section name (argument/member or section name)
+ # section tag, if any ('Returns', '@name', ...)
self.name = name
- # section text without section name
+ # section text without tag
self.text = ''
# indentation to strip (None means indeterminate)
self._indent = None if self.name else 0
@@ -700,7 +700,7 @@ def _start_symbol_section(
raise QAPIParseError(self._parser,
"'%s' parameter name duplicated" % name)
assert not self.sections
- new_section = QAPIDoc.ArgSection(self._parser, name)
+ new_section = QAPIDoc.ArgSection(self._parser, '@' + name)
self._switch_section(new_section)
symbols_dict[name] = new_section
@@ -727,9 +727,9 @@ def _switch_section(self, new_section: 'QAPIDoc.Section') -> None:
# We do not create anonymous sections unless there is
# something to put in them; this is a parser bug.
assert self._section.name
- raise QAPIParseError(
- self._parser,
- "empty doc section '%s'" % self._section.name)
+ raise QAPISemError(
+ self._section.info,
+ "text required after '%s:'" % self._section.name)
self._section = new_section
@@ -748,7 +748,7 @@ def connect_member(self, member: 'QAPISchemaMember') -> None:
"%s '%s' lacks documentation"
% (member.role, member.name))
self.args[member.name] = QAPIDoc.ArgSection(self._parser,
- member.name)
+ '@' + member.name)
self.args[member.name].connect(member)
def connect_feature(self, feature: 'QAPISchemaFeature') -> None:
diff --git a/tests/qapi-schema/doc-empty-section.err b/tests/qapi-schema/doc-empty-section.err
index ba7ba70125..5f03a6d733 100644
--- a/tests/qapi-schema/doc-empty-section.err
+++ b/tests/qapi-schema/doc-empty-section.err
@@ -1 +1 @@
-doc-empty-section.json:7:1: empty doc section 'Note'
+doc-empty-section.json:6: text required after 'Note:'
--
2.43.0
next prev parent reply other threads:[~2024-02-16 14:59 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 ` Markus Armbruster [this message]
2024-02-20 15:16 ` [PATCH 07/16] qapi: Improve error message for empty doc sections Daniel P. Berrangé
2024-02-16 14:58 ` [PATCH 08/16] qapi: Rename QAPIDoc.Section.name to .tag Markus Armbruster
2024-02-20 15:17 ` 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-8-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).