Message ID | 20240216145841.2099240-6-armbru@redhat.com |
---|---|
State | New |
Headers | show |
Series | qapi: Doc comment parsing & doc generation work | expand |
On Fri, Feb 16, 2024 at 03:58:29PM +0100, Markus Armbruster wrote: > 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> > --- > scripts/qapi/parser.py | 4 +++- > tests/qapi-schema/doc-bad-alternate-member.err | 2 +- > tests/qapi-schema/doc-bad-boxed-command-arg.err | 2 +- > tests/qapi-schema/doc-bad-command-arg.err | 2 +- > tests/qapi-schema/doc-bad-enum-member.err | 2 +- > tests/qapi-schema/doc-bad-event-arg.err | 2 +- > tests/qapi-schema/doc-bad-feature.err | 2 +- > tests/qapi-schema/doc-bad-union-member.err | 2 +- > 8 files changed, 10 insertions(+), 8 deletions(-) Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> With regards, Daniel
diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index 88221b3c64..82db595dcf 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -472,6 +472,8 @@ class Section: # 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 @@ def check_args_section( 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 "", diff --git a/tests/qapi-schema/doc-bad-alternate-member.err b/tests/qapi-schema/doc-bad-alternate-member.err index d7286bb57c..1f6b7d2fe4 100644 --- a/tests/qapi-schema/doc-bad-alternate-member.err +++ b/tests/qapi-schema/doc-bad-alternate-member.err @@ -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 diff --git a/tests/qapi-schema/doc-bad-boxed-command-arg.err b/tests/qapi-schema/doc-bad-boxed-command-arg.err index 7137af3ec9..d6793e7fd8 100644 --- a/tests/qapi-schema/doc-bad-boxed-command-arg.err +++ b/tests/qapi-schema/doc-bad-boxed-command-arg.err @@ -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 diff --git a/tests/qapi-schema/doc-bad-command-arg.err b/tests/qapi-schema/doc-bad-command-arg.err index 18ed076cef..b76167ec60 100644 --- a/tests/qapi-schema/doc-bad-command-arg.err +++ b/tests/qapi-schema/doc-bad-command-arg.err @@ -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 diff --git a/tests/qapi-schema/doc-bad-enum-member.err b/tests/qapi-schema/doc-bad-enum-member.err index 7efeb47363..0aa8d8e8e2 100644 --- a/tests/qapi-schema/doc-bad-enum-member.err +++ b/tests/qapi-schema/doc-bad-enum-member.err @@ -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 diff --git a/tests/qapi-schema/doc-bad-event-arg.err b/tests/qapi-schema/doc-bad-event-arg.err index d13cacf21f..90527d5f82 100644 --- a/tests/qapi-schema/doc-bad-event-arg.err +++ b/tests/qapi-schema/doc-bad-event-arg.err @@ -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 diff --git a/tests/qapi-schema/doc-bad-feature.err b/tests/qapi-schema/doc-bad-feature.err index 49d1746c3d..3166c6a305 100644 --- a/tests/qapi-schema/doc-bad-feature.err +++ b/tests/qapi-schema/doc-bad-feature.err @@ -1 +1 @@ -doc-bad-feature.json:3: documented feature 'a' does not exist +doc-bad-feature.json:7: documented feature 'a' does not exist diff --git a/tests/qapi-schema/doc-bad-union-member.err b/tests/qapi-schema/doc-bad-union-member.err index 6dd2726a65..cdf1225cab 100644 --- a/tests/qapi-schema/doc-bad-union-member.err +++ b/tests/qapi-schema/doc-bad-union-member.err @@ -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
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> --- scripts/qapi/parser.py | 4 +++- tests/qapi-schema/doc-bad-alternate-member.err | 2 +- tests/qapi-schema/doc-bad-boxed-command-arg.err | 2 +- tests/qapi-schema/doc-bad-command-arg.err | 2 +- tests/qapi-schema/doc-bad-enum-member.err | 2 +- tests/qapi-schema/doc-bad-event-arg.err | 2 +- tests/qapi-schema/doc-bad-feature.err | 2 +- tests/qapi-schema/doc-bad-union-member.err | 2 +- 8 files changed, 10 insertions(+), 8 deletions(-)