summary refs log tree commit diff stats
path: root/scripts/qapi/common.py
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2019-09-27 15:46:37 +0200
committerMarkus Armbruster <armbru@redhat.com>2019-09-28 17:17:48 +0200
commitf63326985a23cc1bb6327a003050e6fdb52eb9cd (patch)
treec323f9c7d6bf8ed5bb057940c143e8bc7b11e34e /scripts/qapi/common.py
parent13b3997f148bc35d2050bc2fe4bb405791ece94f (diff)
downloadfocaccia-qemu-f63326985a23cc1bb6327a003050e6fdb52eb9cd.tar.gz
focaccia-qemu-f63326985a23cc1bb6327a003050e6fdb52eb9cd.zip
qapi: Improve reporting of missing documentation comment
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>
Diffstat (limited to 'scripts/qapi/common.py')
-rw-r--r--scripts/qapi/common.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index fa354b3f1e..bd834270f8 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -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