[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 33/51] qapi2texi: add 'If:' section to generated
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH v4 33/51] qapi2texi: add 'If:' section to generated documentation |
Date: |
Thu, 11 Jan 2018 22:32:32 +0100 |
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é Lureau <address@hidden>
---
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 'address@hidden:address@hidden @address@hidden table\n' % (what,
items)
-def texi_sections(doc):
+def texi_sections(doc, ifcond):
"""Format additional sections following arguments"""
body = ''
for section in doc.sections:
@@ -185,14 +185,16 @@ def texi_sections(doc):
body += texi_example(section.text)
else:
body += texi_format(section.text)
+ if ifcond:
+ body += 'address@hidden:} @code{%s}' % ", ".join(ifcond)
return body
-def texi_entity(doc, what, base=None, variants=None,
+def texi_entity(doc, what, ifcond, base=None, variants=None,
member_func=texi_member):
return (texi_body(doc)
+ texi_members(doc, what, base, variants, member_func)
- + texi_sections(doc))
+ + texi_sections(doc, ifcond))
class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
@@ -207,7 +209,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
doc = self.cur_doc
self.out += TYPE_FMT(type='Enum',
name=doc.symbol,
- body=texi_entity(doc, 'Values',
+ body=texi_entity(doc, 'Values', ifcond,
member_func=texi_enum_value))
def visit_object_type(self, name, info, ifcond, base, members, variants):
@@ -216,13 +218,14 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
base = None
self.out += TYPE_FMT(type='Object',
name=doc.symbol,
- body=texi_entity(doc, 'Members', base, variants))
+ body=texi_entity(doc, 'Members', ifcond,
+ base, variants))
def visit_alternate_type(self, name, info, ifcond, variants):
doc = self.cur_doc
self.out += TYPE_FMT(type='Alternate',
name=doc.symbol,
- body=texi_entity(doc, 'Members'))
+ body=texi_entity(doc, 'Members', ifcond))
def visit_command(self, name, info, ifcond, arg_type, ret_type,
gen, success_response, boxed):
@@ -231,9 +234,9 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
body = texi_body(doc)
body += ('address@hidden:} the members of @code{%s}\n'
% arg_type.name)
- body += texi_sections(doc)
+ body += texi_sections(doc, ifcond)
else:
- body = texi_entity(doc, 'Arguments')
+ body = texi_entity(doc, 'Arguments', ifcond)
self.out += MSG_FMT(type='Command',
name=doc.symbol,
body=body)
@@ -242,7 +245,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
doc = self.cur_doc
self.out += MSG_FMT(type='Event',
name=doc.symbol,
- body=texi_entity(doc, 'Arguments'))
+ body=texi_entity(doc, 'Arguments', ifcond))
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 += '\n'
- self.out += texi_body(doc) + texi_sections(doc)
+ self.out += texi_body(doc) + texi_sections(doc, None)
def texi_schema(schema):
diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.json
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)' }
##
# @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.texi
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
+
address@hidden:} @code{defined(IFCOND)}
@end deftp
--
2.16.0.rc1.1.gef27df75a1
- [Qemu-devel] [PATCH v4 24/51] qapi-event: add 'if' condition to implicit event enum, (continued)
- [Qemu-devel] [PATCH v4 24/51] qapi-event: add 'if' condition to implicit event enum, Marc-André Lureau, 2018/01/11
- [Qemu-devel] [PATCH v4 23/51] qapi: add 'if' to enum members, Marc-André Lureau, 2018/01/11
- [Qemu-devel] [PATCH v4 25/51] qapi: rename allow_dict to allow_implicit, Marc-André Lureau, 2018/01/11
- [Qemu-devel] [PATCH v4 27/51] qapi: add 'if' to implicit struct members, Marc-André Lureau, 2018/01/11
- [Qemu-devel] [PATCH v4 26/51] qapi: add a dictionary form with 'type' key for members, Marc-André Lureau, 2018/01/11
- [Qemu-devel] [PATCH v4 28/51] qapi: add an error in case a discriminator is conditionnal, Marc-André Lureau, 2018/01/11
- [Qemu-devel] [PATCH v4 29/51] qapi: add 'if' on union members, Marc-André Lureau, 2018/01/11
- [Qemu-devel] [PATCH v4 30/51] qapi: add 'if' to alternate members, Marc-André Lureau, 2018/01/11
- [Qemu-devel] [PATCH v4 31/51] qapi: add #if conditions to generated code, Marc-André Lureau, 2018/01/11
- [Qemu-devel] [PATCH v4 32/51] docs: document schema configuration, Marc-André Lureau, 2018/01/11
- [Qemu-devel] [PATCH v4 33/51] qapi2texi: add 'If:' section to generated documentation,
Marc-André Lureau <=
- [Qemu-devel] [PATCH v4 34/51] qapi2texi: add 'If:' condition to enum values, Marc-André Lureau, 2018/01/11
- [Qemu-devel] [PATCH v4 36/51] qapi2texi: add condition to variants, Marc-André Lureau, 2018/01/11
- [Qemu-devel] [PATCH v4 35/51] qapi2texi: add 'If:' condition to struct members, Marc-André Lureau, 2018/01/11
- [Qemu-devel] [PATCH v4 37/51] qapi: add conditions to VNC type/commands/events on the schema, Marc-André Lureau, 2018/01/11
- [Qemu-devel] [PATCH v4 38/51] qapi: add conditions to SPICE type/commands/events on the schema, Marc-André Lureau, 2018/01/11
- [Qemu-devel] [PATCH v4 39/51] qapi: add conditions to REPLICATION type/commands on the schema, Marc-André Lureau, 2018/01/11