aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-03-15 13:57:22 +0100
committerMarkus Armbruster <armbru@redhat.com>2017-03-16 07:13:03 +0100
commit2d433236df5ab15d61a117c3d8e47a4abc651ce0 (patch)
tree3bce9246c8c5a9a10af2099e7bfbb9c4128922f1
parent7947016d1ceb08584f0d0a3f62b8049ab27219ba (diff)
downloadqemu-2d433236df5ab15d61a117c3d8e47a4abc651ce0.zip
qemu-2d433236df5ab15d61a117c3d8e47a4abc651ce0.tar.gz
qemu-2d433236df5ab15d61a117c3d8e47a4abc651ce0.tar.bz2
qapi: Improve error message on @NAME: in free-form doc
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <1489582656-31133-34-git-send-email-armbru@redhat.com>
-rw-r--r--scripts/qapi.py17
-rw-r--r--tests/qapi-schema/doc-invalid-section.err2
2 files changed, 7 insertions, 12 deletions
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 9a1d830..4edcea1 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -219,6 +219,11 @@ class QAPIDoc(object):
if (in_arg or not self.section.name
or not self.section.name.startswith('Example')):
line = line.strip()
+ match = re.match(r'(@\S+:)', line)
+ if match:
+ raise QAPIParseError(self.parser,
+ "'%s' not allowed in free-form documentation"
+ % match.group(1))
# TODO Drop this once the dust has settled
if (isinstance(self.section, QAPIDoc.ArgSection)
and '#optional' in line):
@@ -975,14 +980,6 @@ def check_exprs(exprs):
return exprs
-def check_freeform_doc(doc):
- body = str(doc.body)
- if re.search(r'@\S+:', body, re.MULTILINE):
- raise QAPISemError(doc.info,
- "Free-form documentation block must not contain"
- " @NAME: sections")
-
-
def check_definition_doc(doc, expr, info):
for i in ('enum', 'union', 'alternate', 'struct', 'command', 'event'):
if i in expr:
@@ -1021,9 +1018,7 @@ def check_docs(docs):
raise QAPISemError(doc.info,
"Empty doc section '%s'" % section.name)
- if not doc.expr:
- check_freeform_doc(doc)
- else:
+ if doc.expr:
check_definition_doc(doc, doc.expr, doc.info)
return docs
diff --git a/tests/qapi-schema/doc-invalid-section.err b/tests/qapi-schema/doc-invalid-section.err
index 85bb67b..bda93b4 100644
--- a/tests/qapi-schema/doc-invalid-section.err
+++ b/tests/qapi-schema/doc-invalid-section.err
@@ -1 +1 @@
-tests/qapi-schema/doc-invalid-section.json:3: Free-form documentation block must not contain @NAME: sections
+tests/qapi-schema/doc-invalid-section.json:5:1: '@note:' not allowed in free-form documentation