aboutsummaryrefslogtreecommitdiff
path: root/scripts/qapi2texi.py
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2018-01-11 22:01:17 +0200
committerMichael S. Tsirkin <mst@redhat.com>2018-01-11 22:03:50 +0200
commitacc95bc85036c443da8bf7159a77edf9f00dcd80 (patch)
tree21965c6e60a2e29664b7685e52feacdb6a86e0bd /scripts/qapi2texi.py
parent880b1ffe6ec2f0ae25cc4175716227ad275e8b8a (diff)
parent997eba28a3ed5400a80f754bf3a1c8044b75b9ff (diff)
Merge remote-tracking branch 'origin/master' into HEAD
Resolve conflicts around apb. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'scripts/qapi2texi.py')
-rwxr-xr-xscripts/qapi2texi.py65
1 files changed, 27 insertions, 38 deletions
diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
index a317526e51..92e2af2cd6 100755
--- a/scripts/qapi2texi.py
+++ b/scripts/qapi2texi.py
@@ -13,7 +13,6 @@ MSG_FMT = """
@deftypefn {type} {{}} {name}
{body}
-
@end deftypefn
""".format
@@ -22,7 +21,6 @@ TYPE_FMT = """
@deftp {{{type}}} {name}
{body}
-
@end deftp
""".format
@@ -74,7 +72,7 @@ def texi_format(doc):
- 1. or 1): generates an @enumerate @item
- */-: generates an @itemize list
"""
- lines = []
+ ret = ''
doc = subst_braces(doc)
doc = subst_vars(doc)
doc = subst_emph(doc)
@@ -100,32 +98,32 @@ def texi_format(doc):
line = '@subsection ' + line[3:]
elif re.match(r'^([0-9]*\.) ', line):
if not inlist:
- lines.append('@enumerate')
+ ret += '@enumerate\n'
inlist = 'enumerate'
+ ret += '@item\n'
line = line[line.find(' ')+1:]
- lines.append('@item')
elif re.match(r'^[*-] ', line):
if not inlist:
- lines.append('@itemize %s' % {'*': '@bullet',
- '-': '@minus'}[line[0]])
+ ret += '@itemize %s\n' % {'*': '@bullet',
+ '-': '@minus'}[line[0]]
inlist = 'itemize'
- lines.append('@item')
+ ret += '@item\n'
line = line[2:]
elif lastempty and inlist:
- lines.append('@end %s\n' % inlist)
+ ret += '@end %s\n\n' % inlist
inlist = ''
lastempty = empty
- lines.append(line)
+ ret += line + '\n'
if inlist:
- lines.append('@end %s\n' % inlist)
- return '\n'.join(lines)
+ ret += '@end %s\n\n' % inlist
+ return ret
def texi_body(doc):
"""Format the main documentation body"""
- return texi_format(str(doc.body)) + '\n'
+ return texi_format(doc.body.text)
def texi_enum_value(value):
@@ -149,15 +147,16 @@ def texi_members(doc, what, base, variants, member_func):
items = ''
for section in doc.args.itervalues():
# TODO Drop fallbacks when undocumented members are outlawed
- if section.content:
- desc = texi_format(str(section))
+ if section.text:
+ desc = texi_format(section.text)
elif (variants and variants.tag_member == section.member
and not section.member.type.doc_type()):
values = section.member.type.member_names()
- desc = 'One of ' + ', '.join(['@t{"%s"}' % v for v in values])
+ members_text = ', '.join(['@t{"%s"}' % v for v in values])
+ desc = 'One of ' + members_text + '\n'
else:
- desc = 'Not documented'
- items += member_func(section.member) + desc + '\n'
+ desc = 'Not documented\n'
+ items += member_func(section.member) + desc
if base:
items += '@item The members of @code{%s}\n' % base.doc_type()
if variants:
@@ -180,16 +179,13 @@ def texi_sections(doc):
"""Format additional sections following arguments"""
body = ''
for section in doc.sections:
- name, doc = (section.name, str(section))
- func = texi_format
- if name.startswith('Example'):
- func = texi_example
-
- if name:
+ if section.name:
# prefer @b over @strong, so txt doesn't translate it to *Foo:*
- body += '\n\n@b{%s:}\n' % name
-
- body += func(doc)
+ body += '\n@b{%s:}\n' % section.name
+ if section.name and section.name.startswith('Example'):
+ body += texi_example(section.text)
+ else:
+ body += texi_format(section.text)
return body
@@ -210,8 +206,6 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
def visit_enum_type(self, name, info, values, prefix):
doc = self.cur_doc
- if self.out:
- self.out += '\n'
self.out += TYPE_FMT(type='Enum',
name=doc.symbol,
body=texi_entity(doc, 'Values',
@@ -221,16 +215,12 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
doc = self.cur_doc
if base and base.is_implicit():
base = None
- if self.out:
- self.out += '\n'
self.out += TYPE_FMT(type='Object',
name=doc.symbol,
body=texi_entity(doc, 'Members', base, variants))
def visit_alternate_type(self, name, info, variants):
doc = self.cur_doc
- if self.out:
- self.out += '\n'
self.out += TYPE_FMT(type='Alternate',
name=doc.symbol,
body=texi_entity(doc, 'Members'))
@@ -238,11 +228,10 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
def visit_command(self, name, info, arg_type, ret_type,
gen, success_response, boxed):
doc = self.cur_doc
- if self.out:
- self.out += '\n'
if boxed:
body = texi_body(doc)
- body += '\n@b{Arguments:} the members of @code{%s}' % arg_type.name
+ body += ('\n@b{Arguments:} the members of @code{%s}\n'
+ % arg_type.name)
body += texi_sections(doc)
else:
body = texi_entity(doc, 'Arguments')
@@ -252,13 +241,13 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
def visit_event(self, name, info, arg_type, boxed):
doc = self.cur_doc
- if self.out:
- self.out += '\n'
self.out += MSG_FMT(type='Event',
name=doc.symbol,
body=texi_entity(doc, 'Arguments'))
def symbol(self, doc, entity):
+ if self.out:
+ self.out += '\n'
self.cur_doc = doc
entity.visit(self)
self.cur_doc = None