qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

qapi: Move empty doc section checking to doc parser

Results in a more precise error location, but the real reason is
emptying out check_docs() step by step.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1489582656-31133-35-git-send-email-armbru@redhat.com>

+15 -7
+14 -6
scripts/qapi.py
··· 173 173 else: 174 174 self._append_freeform(line) 175 175 176 + def end_comment(self): 177 + self._end_section() 178 + 176 179 def _append_symbol_line(self, line): 177 180 name = line.split(' ', 1)[0] 178 181 ··· 200 203 raise QAPIParseError(self.parser, 201 204 "'@%s:' can't follow '%s' section" 202 205 % (name, self.sections[0].name)) 206 + self._end_section() 203 207 self.section = QAPIDoc.ArgSection(name) 204 208 self.args[name] = self.section 205 209 ··· 207 211 if name in ('Returns', 'Since') and self.has_section(name): 208 212 raise QAPIParseError(self.parser, 209 213 "Duplicated '%s' section" % name) 214 + self._end_section() 210 215 self.section = QAPIDoc.Section(name) 211 216 self.sections.append(self.section) 217 + 218 + def _end_section(self): 219 + if self.section: 220 + contents = str(self.section) 221 + if self.section.name and (not contents or contents.isspace()): 222 + raise QAPIParseError(self.parser, "Empty doc section '%s'" 223 + % self.section.name) 224 + self.section = None 212 225 213 226 def _append_freeform(self, line): 214 227 in_arg = isinstance(self.section, QAPIDoc.ArgSection) ··· 512 525 if self.val != '##': 513 526 raise QAPIParseError(self, "Junk after '##' at end of " 514 527 "documentation comment") 528 + doc.end_comment() 515 529 self.accept() 516 530 return doc 517 531 else: ··· 1012 1026 1013 1027 def check_docs(docs): 1014 1028 for doc in docs: 1015 - for section in doc.args.values() + doc.sections: 1016 - content = str(section) 1017 - if not content or content.isspace(): 1018 - raise QAPISemError(doc.info, 1019 - "Empty doc section '%s'" % section.name) 1020 - 1021 1029 if doc.expr: 1022 1030 check_definition_doc(doc, doc.expr, doc.info) 1023 1031
+1 -1
tests/qapi-schema/doc-empty-section.err
··· 1 - tests/qapi-schema/doc-empty-section.json:3: Empty doc section 'Note' 1 + tests/qapi-schema/doc-empty-section.json:7:1: Empty doc section 'Note'