From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1coOtW-00068X-5I for qemu-devel@nongnu.org; Thu, 16 Mar 2017 02:28:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1coOtS-00078q-0N for qemu-devel@nongnu.org; Thu, 16 Mar 2017 02:28:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37628) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1coOtR-00077A-My for qemu-devel@nongnu.org; Thu, 16 Mar 2017 02:28:13 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8F3BB64478 for ; Thu, 16 Mar 2017 06:28:13 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5D98D5C3FA for ; Thu, 16 Mar 2017 06:28:13 +0000 (UTC) From: Markus Armbruster Date: Thu, 16 Mar 2017 07:27:51 +0100 Message-Id: <1489645685-4750-36-git-send-email-armbru@redhat.com> In-Reply-To: <1489645685-4750-1-git-send-email-armbru@redhat.com> References: <1489645685-4750-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PULL for 2.9 35/49] qapi: Improve error message on @NAME: in free-form doc List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <1489582656-31133-34-git-send-email-armbru@redhat.com> --- scripts/qapi.py | 17 ++++++----------- tests/qapi-schema/doc-invalid-section.err | 2 +- 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 -- 2.7.4