]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qapi: Improve reporting of missing documentation comment
authorMarkus Armbruster <armbru@redhat.com>
Fri, 27 Sep 2019 13:46:37 +0000 (15:46 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Sat, 28 Sep 2019 15:17:48 +0000 (17:17 +0200)
Have check_exprs() check this later, so the error message gains an "in
definition line".  Tweak the error message.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190927134639.4284-25-armbru@redhat.com>

scripts/qapi/common.py
tests/qapi-schema/doc-missing.err

index fa354b3f1eabe53e527ca7a6cdb8dbb3c8ceeb2b..bd834270f8841bef0cbbaf9cc5c059eb5f46fdae 100644 (file)
@@ -933,10 +933,6 @@ def check_exprs(exprs):
         if 'include' in expr:
             continue
 
-        if not doc and doc_required:
-            raise QAPISemError(info,
-                               "definition missing documentation comment")
-
         if 'enum' in expr:
             meta = 'enum'
         elif 'union' in expr:
@@ -957,9 +953,14 @@ def check_exprs(exprs):
         info.set_defn(meta, name)
         check_defn_name_str(name, info, meta)
 
-        if doc and doc.symbol != name:
-            raise QAPISemError(
-                info, "documentation comment is for '%s'" % doc.symbol)
+        if doc:
+            if doc.symbol != name:
+                raise QAPISemError(
+                    info, "documentation comment is for '%s'" % doc.symbol)
+            doc.check_expr(expr)
+        elif doc_required:
+            raise QAPISemError(info,
+                               "documentation comment required")
 
         if meta == 'enum':
             check_keys(expr, info, meta,
@@ -1004,9 +1005,6 @@ def check_exprs(exprs):
         check_if(expr, info, meta)
         check_flags(expr, info)
 
-        if doc:
-            doc.check_expr(expr)
-
     return exprs
 
 
index 08c827931a8585757fc5eaafbfe6e4ea16b01a43..7fbf54ff65744dc0dce9ee3b43a2206dce9c0e14 100644 (file)
@@ -1 +1,2 @@
-tests/qapi-schema/doc-missing.json:5: definition missing documentation comment
+tests/qapi-schema/doc-missing.json: In command 'undocumented':
+tests/qapi-schema/doc-missing.json:5: documentation comment required