qapi2texi: Present the table of members more clearly

The table of members follows the main descriptive text immediately.
Makes it hard to see what it is about.  Start a new paragraph, and
lead with a line "Members:" for object and alternate types, "Values:"
for enumeration types, and "Arguments:" for commands and events.

Example change (qemu-qmp-ref.txt):

  -- Command: set_link

      Sets the link status of a virtual network adapter.
+
+     Arguments:
      'name'
           the device name of the virtual network adapter
      'up'
           true to set the link status to be up

      Returns: Nothing on success If 'name' is not a valid network
      device, DeviceNotFound

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1489582656-31133-22-git-send-email-armbru@redhat.com>
This commit is contained in:
Markus Armbruster 2017-03-15 13:57:10 +01:00
parent 71d918a1b1
commit 2a1183ce93

View File

@ -139,7 +139,7 @@ def texi_member(member):
member.name, ' (optional)' if member.optional else '') member.name, ' (optional)' if member.optional else '')
def texi_members(doc, member_func, show_undocumented): def texi_members(doc, what, member_func, show_undocumented):
"""Format the table of members""" """Format the table of members"""
items = '' items = ''
for section in doc.args.itervalues(): for section in doc.args.itervalues():
@ -149,7 +149,7 @@ def texi_members(doc, member_func, show_undocumented):
items += member_func(section.member) + texi_format(desc) + '\n' items += member_func(section.member) + texi_format(desc) + '\n'
if not items: if not items:
return '' return ''
return '@table @asis\n' + items + '@end table\n' return '\n@b{%s:}\n@table @asis\n%s@end table\n' % (what, items)
def texi_sections(doc): def texi_sections(doc):
@ -169,9 +169,10 @@ def texi_sections(doc):
return body return body
def texi_entity(doc, member_func=texi_member, show_undocumented=False): def texi_entity(doc, what, member_func=texi_member,
show_undocumented=False):
return (texi_body(doc) return (texi_body(doc)
+ texi_members(doc, member_func, show_undocumented) + texi_members(doc, what, member_func, show_undocumented)
+ texi_sections(doc)) + texi_sections(doc))
@ -189,7 +190,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
self.out += '\n' self.out += '\n'
self.out += TYPE_FMT(type='Enum', self.out += TYPE_FMT(type='Enum',
name=doc.symbol, name=doc.symbol,
body=texi_entity(doc, body=texi_entity(doc, 'Values',
member_func=texi_enum_value, member_func=texi_enum_value,
show_undocumented=True)) show_undocumented=True))
@ -205,7 +206,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
self.out += '\n' self.out += '\n'
self.out += TYPE_FMT(type=typ, self.out += TYPE_FMT(type=typ,
name=doc.symbol, name=doc.symbol,
body=texi_entity(doc)) body=texi_entity(doc, 'Members'))
def visit_alternate_type(self, name, info, variants): def visit_alternate_type(self, name, info, variants):
doc = self.cur_doc doc = self.cur_doc
@ -213,7 +214,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
self.out += '\n' self.out += '\n'
self.out += TYPE_FMT(type='Alternate', self.out += TYPE_FMT(type='Alternate',
name=doc.symbol, name=doc.symbol,
body=texi_entity(doc)) body=texi_entity(doc, 'Members'))
def visit_command(self, name, info, arg_type, ret_type, def visit_command(self, name, info, arg_type, ret_type,
gen, success_response, boxed): gen, success_response, boxed):
@ -222,7 +223,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
self.out += '\n' self.out += '\n'
self.out += MSG_FMT(type='Command', self.out += MSG_FMT(type='Command',
name=doc.symbol, name=doc.symbol,
body=texi_entity(doc)) body=texi_entity(doc, 'Arguments'))
def visit_event(self, name, info, arg_type, boxed): def visit_event(self, name, info, arg_type, boxed):
doc = self.cur_doc doc = self.cur_doc
@ -230,7 +231,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
self.out += '\n' self.out += '\n'
self.out += MSG_FMT(type='Event', self.out += MSG_FMT(type='Event',
name=doc.symbol, name=doc.symbol,
body=texi_entity(doc)) body=texi_entity(doc, 'Arguments'))
def symbol(self, doc, entity): def symbol(self, doc, entity):
self.cur_doc = doc self.cur_doc = doc