From nobody Tue Feb 10 12:42:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151570797277488.03021235223332; Thu, 11 Jan 2018 13:59:32 -0800 (PST) Received: from localhost ([::1]:45314 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZksl-0002Hm-Rr for importer@patchew.org; Thu, 11 Jan 2018 16:59:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZkWW-0007dZ-U6 for qemu-devel@nongnu.org; Thu, 11 Jan 2018 16:36:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZkWR-0004cp-Sx for qemu-devel@nongnu.org; Thu, 11 Jan 2018 16:36:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46700) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZkWR-0004ZL-Jm for qemu-devel@nongnu.org; Thu, 11 Jan 2018 16:36:27 -0500 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 mx1.redhat.com (Postfix) with ESMTPS id C5FEE7AE99; Thu, 11 Jan 2018 21:36:26 +0000 (UTC) Received: from localhost (ovpn-112-44.ams2.redhat.com [10.36.112.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 801736017B; Thu, 11 Jan 2018 21:36:23 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 11 Jan 2018 22:32:32 +0100 Message-Id: <20180111213250.16511-34-marcandre.lureau@redhat.com> In-Reply-To: <20180111213250.16511-1-marcandre.lureau@redhat.com> References: <20180111213250.16511-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 11 Jan 2018 21:36:26 +0000 (UTC) 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: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 33/51] qapi2texi: add 'If:' section to generated documentation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Michael Roth , armbru@redhat.com, Cleber Rosa , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The documentation is generated only once, and doesn't know C pre-conditions. Add 'If:' sections for top-level entities. Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi2texi.py | 23 +++++++++++++---------- tests/qapi-schema/doc-good.json | 2 +- tests/qapi-schema/doc-good.out | 1 + tests/qapi-schema/doc-good.texi | 2 ++ 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py index 755bd2f15d..76c336af34 100755 --- a/scripts/qapi2texi.py +++ b/scripts/qapi2texi.py @@ -174,7 +174,7 @@ def texi_members(doc, what, base, variants, member_func= ): return '\n@b{%s:}\n@table @asis\n%s@end table\n' % (what, items) =20 =20 -def texi_sections(doc): +def texi_sections(doc, ifcond): """Format additional sections following arguments""" body =3D '' for section in doc.sections: @@ -185,14 +185,16 @@ def texi_sections(doc): body +=3D texi_example(section.text) else: body +=3D texi_format(section.text) + if ifcond: + body +=3D '\n\n@b{If:} @code{%s}' % ", ".join(ifcond) return body =20 =20 -def texi_entity(doc, what, base=3DNone, variants=3DNone, +def texi_entity(doc, what, ifcond, base=3DNone, variants=3DNone, member_func=3Dtexi_member): return (texi_body(doc) + texi_members(doc, what, base, variants, member_func) - + texi_sections(doc)) + + texi_sections(doc, ifcond)) =20 =20 class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): @@ -207,7 +209,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): doc =3D self.cur_doc self.out +=3D TYPE_FMT(type=3D'Enum', name=3Ddoc.symbol, - body=3Dtexi_entity(doc, 'Values', + body=3Dtexi_entity(doc, 'Values', ifcond, member_func=3Dtexi_enum_valu= e)) =20 def visit_object_type(self, name, info, ifcond, base, members, variant= s): @@ -216,13 +218,14 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): base =3D None self.out +=3D TYPE_FMT(type=3D'Object', name=3Ddoc.symbol, - body=3Dtexi_entity(doc, 'Members', base, vari= ants)) + body=3Dtexi_entity(doc, 'Members', ifcond, + base, variants)) =20 def visit_alternate_type(self, name, info, ifcond, variants): doc =3D self.cur_doc self.out +=3D TYPE_FMT(type=3D'Alternate', name=3Ddoc.symbol, - body=3Dtexi_entity(doc, 'Members')) + body=3Dtexi_entity(doc, 'Members', ifcond)) =20 def visit_command(self, name, info, ifcond, arg_type, ret_type, gen, success_response, boxed): @@ -231,9 +234,9 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): body =3D texi_body(doc) body +=3D ('\n@b{Arguments:} the members of @code{%s}\n' % arg_type.name) - body +=3D texi_sections(doc) + body +=3D texi_sections(doc, ifcond) else: - body =3D texi_entity(doc, 'Arguments') + body =3D texi_entity(doc, 'Arguments', ifcond) self.out +=3D MSG_FMT(type=3D'Command', name=3Ddoc.symbol, body=3Dbody) @@ -242,7 +245,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): doc =3D self.cur_doc self.out +=3D MSG_FMT(type=3D'Event', name=3Ddoc.symbol, - body=3Dtexi_entity(doc, 'Arguments')) + body=3Dtexi_entity(doc, 'Arguments', ifcond)) =20 def symbol(self, doc, entity): if self.out: @@ -255,7 +258,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): assert not doc.args if self.out: self.out +=3D '\n' - self.out +=3D texi_body(doc) + texi_sections(doc) + self.out +=3D texi_body(doc) + texi_sections(doc, None) =20 =20 def texi_schema(schema): diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.j= son index 97ab4625ff..984cd8ed06 100644 --- a/tests/qapi-schema/doc-good.json +++ b/tests/qapi-schema/doc-good.json @@ -55,7 +55,7 @@ # # @two is undocumented ## -{ 'enum': 'Enum', 'data': [ 'one', 'two' ] } +{ 'enum': 'Enum', 'data': [ 'one', 'two' ], 'if': 'defined(IFCOND)' } =20 ## # @Base: diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index e615b04281..8c75da180c 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -3,6 +3,7 @@ object Base enum Enum member one member two + if ['defined(IFCOND)'] object Object base Base tag base1 diff --git a/tests/qapi-schema/doc-good.texi b/tests/qapi-schema/doc-good.t= exi index 1778312581..cd422f8a8f 100644 --- a/tests/qapi-schema/doc-good.texi +++ b/tests/qapi-schema/doc-good.texi @@ -87,6 +87,8 @@ Not documented @end table @code{two} is undocumented =20 + +@b{If:} @code{defined(IFCOND)} @end deftp =20 =20 --=20 2.16.0.rc1.1.gef27df75a1