From nobody Sat May 4 08:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584695959; cv=none; d=zohomail.com; s=zohoarc; b=WA0EQ56TIERv/nAewRV1ZOQB9Ot5fOEjnAmeKAcDHcXmiVZPWQ1KR/aXzGjdwBSKPszmo1MAPov+2Wyl53mwreYS+EPidJp4UEUiTBN9v/Ls4LX52fpnQkatGR02eb9zh1FN8JFwSwqCXRD94h7i8qDkSwkPdIfi+C9pRi0dOo4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584695959; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7ZEDWYjefeu5Ws2I1asjAQwMJZH/7Vs8pFGmds1C/1s=; b=JMpr+EwNAw99xsAViJ7/x+wT8vltWA0+PjoAsUNqmii2tCmqqDpjBr5JJvlsa6FDwNgb4FF1xmbuU3xL7sV6qHpNa/jk2Ok+bGF49ngB4c8+gjP0ZjU0XTcRmAnAb56dLHzoFMszNKTR7IJUuCP5GMvB+5NCB+AWyn/rznWmpx8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584695959869710.9508502972909; Fri, 20 Mar 2020 02:19:19 -0700 (PDT) Received: from localhost ([::1]:49686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFDoE-0000pJ-IG for importer@patchew.org; Fri, 20 Mar 2020 05:19:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51208) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFDn9-0007qI-Uj for qemu-devel@nongnu.org; Fri, 20 Mar 2020 05:18:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jFDn8-000827-BW for qemu-devel@nongnu.org; Fri, 20 Mar 2020 05:18:11 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:56294) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jFDn8-000818-74 for qemu-devel@nongnu.org; Fri, 20 Mar 2020 05:18:10 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-277-bAD99b00P_-JZzW7KZ268w-1; Fri, 20 Mar 2020 05:18:08 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 154A7107ACCA; Fri, 20 Mar 2020 09:18:07 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-130.ams2.redhat.com [10.36.112.130]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7998491295; Fri, 20 Mar 2020 09:18:06 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0871F1138405; Fri, 20 Mar 2020 10:18:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584695889; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7ZEDWYjefeu5Ws2I1asjAQwMJZH/7Vs8pFGmds1C/1s=; b=YmZfowtZyVlHR29wt7BYNXyrAxXWxbmYVds7vnFFHcsTXrG14tw/qd/afKwUwK1gZKnwKO qYrdM/nl9gfQArAxc0BfuIXDM/7bTnwOMxOkkOqLBgVrDGhsc6fbYWoj8D+9a9jAbUXknx Q0Ouq/Tcu5CQp38+aHcvHMCgGylFvr4= X-MC-Unique: bAD99b00P_-JZzW7KZ268w-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 1/2] qapi: Reject section markup in definition documentation Date: Fri, 20 Mar 2020 10:18:04 +0100 Message-Id: <20200320091805.5585-2-armbru@redhat.com> In-Reply-To: <20200320091805.5585-1-armbru@redhat.com> References: <20200320091805.5585-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Section markup in definition documentation makes no sense and can produce invalid Texinfo. Reject. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- docs/devel/qapi-code-gen.txt | 2 ++ scripts/qapi/parser.py | 5 +++++ tests/qapi-schema/doc-bad-section.err | 1 + tests/qapi-schema/doc-bad-section.json | 3 +-- tests/qapi-schema/doc-bad-section.out | 24 ------------------------ 5 files changed, 9 insertions(+), 26 deletions(-) diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index 1967adfa92..382a672874 100644 --- a/docs/devel/qapi-code-gen.txt +++ b/docs/devel/qapi-code-gen.txt @@ -835,6 +835,8 @@ Double the '=3D' for a subsection title: =20 # =3D=3D Subsection title =20 +Both are only permitted in free-form documentation. + '|' denotes examples: =20 # | Text of the example, may span diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index abadacbb0e..f12c67d7d2 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -282,6 +282,11 @@ class QAPISchemaParser: doc.end_comment() self.accept() return doc + if self.val.startswith('# =3D'): + if doc.symbol: + raise QAPIParseError( + self, + "unexpected '=3D' markup in definition documentati= on") doc.append(self.val) self.accept(False) =20 diff --git a/tests/qapi-schema/doc-bad-section.err b/tests/qapi-schema/doc-= bad-section.err index e69de29bb2..785cacc08c 100644 --- a/tests/qapi-schema/doc-bad-section.err +++ b/tests/qapi-schema/doc-bad-section.err @@ -0,0 +1 @@ +doc-bad-section.json:5:1: unexpected '=3D' markup in definition documentat= ion diff --git a/tests/qapi-schema/doc-bad-section.json b/tests/qapi-schema/doc= -bad-section.json index 560df4b087..8175d95867 100644 --- a/tests/qapi-schema/doc-bad-section.json +++ b/tests/qapi-schema/doc-bad-section.json @@ -1,9 +1,8 @@ # =3D section within an expression comment -# BUG: not rejected =20 ## # @Enum: -# =3D=3D Produces *invalid* texinfo +# =3D=3D No good here # @one: The _one_ {and only} # # @two is undocumented diff --git a/tests/qapi-schema/doc-bad-section.out b/tests/qapi-schema/doc-= bad-section.out index 367e2a1c3e..e69de29bb2 100644 --- a/tests/qapi-schema/doc-bad-section.out +++ b/tests/qapi-schema/doc-bad-section.out @@ -1,24 +0,0 @@ -module None -object q_empty -enum QType - prefix QTYPE - member none - member qnull - member qnum - member qstring - member qdict - member qlist - member qbool -module doc-bad-section.json -enum Enum - member one - member two -doc symbol=3DEnum - body=3D -=3D=3D Produces *invalid* texinfo - arg=3Done -The _one_ {and only} - arg=3Dtwo - - section=3DNone -@two is undocumented --=20 2.21.1 From nobody Sat May 4 08:53:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584695961; cv=none; d=zohomail.com; s=zohoarc; b=kKqWAffh+qxW9+iSx0x5Ya4FeCN8ebHros7o2nHOMX2yQ/qwmvLjOcn68BRjSOyeDKfPirKCn8Rvfsl2bw0MK8Dh8RE1vbEn5y19K35K9YH6ETpqjwVgMPWzysKGp8laJRlb7BIfNYUCYaUoNFpnwIZF0YiM5Hl08PjznajcUqA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584695961; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UXTKpzyVZjeOnymPgoD+aEVLEuJzcg/IuAjr4kXReDM=; b=DUbg7LexGiF9Hr90Ol7t2TfAit3BKc+YtfEumLcqBfp43TocSNCH3s9yBb6eIpdnR0+5OosP1KL1MImpW2A3uotjrjTf3BX4mIIatYjxX9rVQcMYgx37rBVj4zyhzrZLot0UM6uSUeyVZrZ5GoS8fUMTYirbOILOBJTpUJeMIxU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584695961386939.7888961972936; Fri, 20 Mar 2020 02:19:21 -0700 (PDT) Received: from localhost ([::1]:49688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFDoG-0000sP-4j for importer@patchew.org; Fri, 20 Mar 2020 05:19:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51228) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFDnA-0007rf-T4 for qemu-devel@nongnu.org; Fri, 20 Mar 2020 05:18:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jFDn9-000848-OS for qemu-devel@nongnu.org; Fri, 20 Mar 2020 05:18:12 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:48310) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jFDn9-000835-Ka for qemu-devel@nongnu.org; Fri, 20 Mar 2020 05:18:11 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-176-pOu8xsLsPf6nS18YXgzabQ-1; Fri, 20 Mar 2020 05:18:07 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C3DB3189F763; Fri, 20 Mar 2020 09:18:06 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-130.ams2.redhat.com [10.36.112.130]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7AE00CFD2; Fri, 20 Mar 2020 09:18:06 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0C75211366CC; Fri, 20 Mar 2020 10:18:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584695891; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UXTKpzyVZjeOnymPgoD+aEVLEuJzcg/IuAjr4kXReDM=; b=g1H30z9YgyKcQUwUEBuVPA0NjM337EyX+ecdIIdBmgIw0Mus1ZZB8NJhbi3TxB2uiIKrF6 fD8f8VML1ExN3mK5cyC8/a1H7EoYijSPr7o2+fmR3+glWPfNxXAiJDq5j84S6jPYrmd+iL xsroAEboztff91FdrB72FYYQb8dr+As= X-MC-Unique: pOu8xsLsPf6nS18YXgzabQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH RFC 2/2] qapi: Make section headings start a new doc comment block Date: Fri, 20 Mar 2020 10:18:05 +0100 Message-Id: <20200320091805.5585-3-armbru@redhat.com> In-Reply-To: <20200320091805.5585-1-armbru@redhat.com> References: <20200320091805.5585-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Our current QAPI doc-comment markup allows section headers (introduced with a leading '=3D' or '=3D=3D') anywhere in a free-form documentation comment. This works for Texinfo because the generator simply prints a Texinfo section command at that point in the output stream. For rST generation, since we're assembling a tree of docutils nodes, this is awkward because a new section implies starting a new section node at the top level of the tree and generating text into there. Make section headers start a new free-form documentation block, so the future rST document generator doesn't have to look at every line in free-form blocks and handle headings in odd places. This change makes no difference to the generated Texinfo. Signed-off-by: Markus Armbruster --- scripts/qapi/parser.py | 21 +++++++++++++-------- tests/qapi-schema/doc-good.out | 3 ++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index f12c67d7d2..165925ca72 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -52,8 +52,8 @@ class QAPISchemaParser: info =3D self.info if self.tok =3D=3D '#': self.reject_expr_doc(cur_doc) - cur_doc =3D self.get_doc(info) - self.docs.append(cur_doc) + for cur_doc in self.get_doc(info): + self.docs.append(cur_doc) continue =20 expr =3D self.get_expr(False) @@ -270,7 +270,8 @@ class QAPISchemaParser: raise QAPIParseError( self, "junk after '##' at start of documentation comment") =20 - doc =3D QAPIDoc(self, info) + docs =3D [] + cur_doc =3D QAPIDoc(self, info) self.accept(False) while self.tok =3D=3D '#': if self.val.startswith('##'): @@ -279,15 +280,20 @@ class QAPISchemaParser: raise QAPIParseError( self, "junk after '##' at end of documentation comment") - doc.end_comment() + cur_doc.end_comment() + docs.append(cur_doc) self.accept() - return doc + return docs if self.val.startswith('# =3D'): - if doc.symbol: + if cur_doc.symbol: raise QAPIParseError( self, "unexpected '=3D' markup in definition documentati= on") - doc.append(self.val) + if cur_doc.body.text: + cur_doc.end_comment() + docs.append(cur_doc) + cur_doc =3D QAPIDoc(self, info) + cur_doc.append(self.val) self.accept(False) =20 raise QAPIParseError(self, "documentation comment must end with '#= #'") @@ -316,7 +322,6 @@ class QAPIDoc: def __init__(self, name=3DNone): # optional section name (argument/member or section name) self.name =3D name - # the list of lines for this section self.text =3D '' =20 def append(self, line): diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 6757dd26a2..d78a424cd9 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -69,7 +69,8 @@ event EVT-BOXED Object doc freeform body=3D =3D Section - +doc freeform + body=3D =3D=3D Subsection =20 *strong* _with emphasis_ --=20 2.21.1