Skip to content

Commit

Permalink
qapi: Improve error message on @name: in free-form doc
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Markus Armbruster committed Mar 16, 2017
1 parent 7947016 commit 2d43323
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
17 changes: 6 additions & 11 deletions scripts/qapi.py
Expand Up @@ -219,6 +219,11 @@ def _append_freeform(self, line):
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):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 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

0 comments on commit 2d43323

Please sign in to comment.