qapi: Improve error position for bogus argument descriptions

When documented arguments don't exist, the error message points to the
beginning of the definition comment.  Point to the first bogus
argument description instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20240216145841.2099240-6-armbru@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Markus Armbruster
2024-02-16 15:58:29 +01:00
parent e51e80ccf6
commit 15333abed9
8 changed files with 10 additions and 8 deletions
+3 -1
View File
@@ -472,6 +472,8 @@ class QAPIDoc:
# pylint: disable=too-few-public-methods
def __init__(self, parser: QAPISchemaParser,
name: Optional[str] = None):
# section source info, i.e. where it begins
self.info = parser.info
# parser, for error messages about indentation
self._parser = parser
# optional section name (argument/member or section name)
@@ -770,7 +772,7 @@ class QAPIDoc:
if not section.member]
if bogus:
raise QAPISemError(
self.info,
args[bogus[0]].info,
"documented %s%s '%s' %s not exist" % (
what,
"s" if len(bogus) > 1 else "",
@@ -1 +1 @@
doc-bad-alternate-member.json:3: documented members 'aa', 'bb' do not exist
doc-bad-alternate-member.json:7: documented members 'aa', 'bb' do not exist
@@ -1 +1 @@
doc-bad-boxed-command-arg.json:9: documented member 'a' does not exist
doc-bad-boxed-command-arg.json:11: documented member 'a' does not exist
+1 -1
View File
@@ -1 +1 @@
doc-bad-command-arg.json:3: documented member 'b' does not exist
doc-bad-command-arg.json:6: documented member 'b' does not exist
+1 -1
View File
@@ -1 +1 @@
doc-bad-enum-member.json:3: documented member 'a' does not exist
doc-bad-enum-member.json:5: documented member 'a' does not exist
+1 -1
View File
@@ -1 +1 @@
doc-bad-event-arg.json:3: documented member 'a' does not exist
doc-bad-event-arg.json:5: documented member 'a' does not exist
+1 -1
View File
@@ -1 +1 @@
doc-bad-feature.json:3: documented feature 'a' does not exist
doc-bad-feature.json:7: documented feature 'a' does not exist
+1 -1
View File
@@ -1 +1 @@
doc-bad-union-member.json:3: documented members 'a', 'b' do not exist
doc-bad-union-member.json:5: documented members 'a', 'b' do not exist