[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 for-2.9 34/47] qapi: Move empty doc section check
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH v2 for-2.9 34/47] qapi: Move empty doc section checking to doc parser |
Date: |
Wed, 15 Mar 2017 13:57:23 +0100 |
Results in a more precise error location, but the real reason is
emptying out check_docs() step by step.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
scripts/qapi.py | 20 ++++++++++++++------
tests/qapi-schema/doc-empty-section.err | 2 +-
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 4edcea1..648355e 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -173,6 +173,9 @@ class QAPIDoc(object):
else:
self._append_freeform(line)
+ def end_comment(self):
+ self._end_section()
+
def _append_symbol_line(self, line):
name = line.split(' ', 1)[0]
@@ -200,6 +203,7 @@ class QAPIDoc(object):
raise QAPIParseError(self.parser,
"'@%s:' can't follow '%s' section"
% (name, self.sections[0].name))
+ self._end_section()
self.section = QAPIDoc.ArgSection(name)
self.args[name] = self.section
@@ -207,9 +211,18 @@ class QAPIDoc(object):
if name in ('Returns', 'Since') and self.has_section(name):
raise QAPIParseError(self.parser,
"Duplicated '%s' section" % name)
+ self._end_section()
self.section = QAPIDoc.Section(name)
self.sections.append(self.section)
+ def _end_section(self):
+ if self.section:
+ contents = str(self.section)
+ if self.section.name and (not contents or contents.isspace()):
+ raise QAPIParseError(self.parser, "Empty doc section '%s'"
+ % self.section.name)
+ self.section = None
+
def _append_freeform(self, line):
in_arg = isinstance(self.section, QAPIDoc.ArgSection)
if (in_arg and self.section.content
@@ -512,6 +525,7 @@ class QAPISchemaParser(object):
if self.val != '##':
raise QAPIParseError(self, "Junk after '##' at end of "
"documentation comment")
+ doc.end_comment()
self.accept()
return doc
else:
@@ -1012,12 +1026,6 @@ def check_definition_doc(doc, expr, info):
def check_docs(docs):
for doc in docs:
- for section in doc.args.values() + doc.sections:
- content = str(section)
- if not content or content.isspace():
- raise QAPISemError(doc.info,
- "Empty doc section '%s'" % section.name)
-
if doc.expr:
check_definition_doc(doc, doc.expr, doc.info)
diff --git a/tests/qapi-schema/doc-empty-section.err
b/tests/qapi-schema/doc-empty-section.err
index 00ad625..b61e4a7 100644
--- a/tests/qapi-schema/doc-empty-section.err
+++ b/tests/qapi-schema/doc-empty-section.err
@@ -1 +1 @@
-tests/qapi-schema/doc-empty-section.json:3: Empty doc section 'Note'
+tests/qapi-schema/doc-empty-section.json:7:1: Empty doc section 'Note'
--
2.7.4
- [Qemu-devel] [PATCH v2 for-2.9 13/47] qapi: Fix QAPISchemaEnumType.is_implicit() for 'QType', (continued)
- [Qemu-devel] [PATCH v2 for-2.9 13/47] qapi: Fix QAPISchemaEnumType.is_implicit() for 'QType', Markus Armbruster, 2017/03/15
- [Qemu-devel] [PATCH v2 for-2.9 06/47] qapi: Have each QAPI schema declare its name rule violations, Markus Armbruster, 2017/03/15
- [Qemu-devel] [PATCH v2 for-2.9 04/47] docs/qapi-code-gen.txt: Drop confusing reference to 'gen', Markus Armbruster, 2017/03/15
- [Qemu-devel] [PATCH v2 for-2.9 12/47] qapi/rocker: Fix up doc comment notes on optional members, Markus Armbruster, 2017/03/15
- [Qemu-devel] [PATCH v2 for-2.9 23/47] qapi2texi: Don't hide undocumented members and arguments, Markus Armbruster, 2017/03/15
- [Qemu-devel] [PATCH v2 for-2.9 15/47] qapi: Conjure up QAPIDoc.ArgSection for undocumented members, Markus Armbruster, 2017/03/15
- [Qemu-devel] [PATCH v2 for-2.9 16/47] qapi2texi: Convert to QAPISchemaVisitor, Markus Armbruster, 2017/03/15
- [Qemu-devel] [PATCH v2 for-2.9 32/47] qapi: Move detection of doc / expression name mismatch, Markus Armbruster, 2017/03/15
- [Qemu-devel] [PATCH v2 for-2.9 22/47] qapi2texi: Explain enum value undocumentedness more clearly, Markus Armbruster, 2017/03/15
- [Qemu-devel] [PATCH v2 for-2.9 34/47] qapi: Move empty doc section checking to doc parser,
Markus Armbruster <=
- [Qemu-devel] [PATCH v2 for-2.9 14/47] qapi: Prepare for requiring more complete documentation, Markus Armbruster, 2017/03/15
- [Qemu-devel] [PATCH v2 for-2.9 42/47] qapi: enum_types is a list used like a dict, make it one, Markus Armbruster, 2017/03/15
- [Qemu-devel] [PATCH v2 for-2.9 07/47] qapi: Clean up build of generated documentation, Markus Armbruster, 2017/03/15
- [Qemu-devel] [PATCH v2 for-2.9 20/47] qapi2texi: Plainer enum value and member name formatting, Markus Armbruster, 2017/03/15
- [Qemu-devel] [PATCH v2 for-2.9 11/47] qapi: Avoid unwanted blank lines in QAPIDoc, Markus Armbruster, 2017/03/15
- [Qemu-devel] [PATCH v2 for-2.9 02/47] qapi: Make doc comments optional where we don't need them, Markus Armbruster, 2017/03/15
- [Qemu-devel] [PATCH v2 for-2.9 29/47] qapi2texi: Use category "Object" for all object types, Markus Armbruster, 2017/03/15