mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-29 13:23:54 -06:00
qapi: add 'If:' condition to enum values documentation
Use a common function to generate the "If:..." line. While at it, get rid of the existing \n\n (no idea why it was there). Use a line-break in member description, this seems to look slightly better in the plaintext version. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20181213123724.4866-19-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
8ee06f61e1
commit
a35c9bf82a
4 changed files with 21 additions and 11 deletions
|
@ -126,19 +126,27 @@ def texi_body(doc):
|
||||||
return texi_format(doc.body.text)
|
return texi_format(doc.body.text)
|
||||||
|
|
||||||
|
|
||||||
def texi_enum_value(value):
|
def texi_if(ifcond, prefix='\n', suffix='\n'):
|
||||||
|
"""Format the #if condition"""
|
||||||
|
if not ifcond:
|
||||||
|
return ''
|
||||||
|
return '%s@b{If:} @code{%s}%s' % (prefix, ', '.join(ifcond), suffix)
|
||||||
|
|
||||||
|
|
||||||
|
def texi_enum_value(value, desc, suffix):
|
||||||
"""Format a table of members item for an enumeration value"""
|
"""Format a table of members item for an enumeration value"""
|
||||||
return '@item @code{%s}\n' % value.name
|
return '@item @code{%s}\n%s%s' % (
|
||||||
|
value.name, desc, texi_if(value.ifcond, prefix='@*'))
|
||||||
|
|
||||||
|
|
||||||
def texi_member(member, suffix=''):
|
def texi_member(member, desc, suffix):
|
||||||
"""Format a table of members item for an object type member"""
|
"""Format a table of members item for an object type member"""
|
||||||
typ = member.type.doc_type()
|
typ = member.type.doc_type()
|
||||||
membertype = ': ' + typ if typ else ''
|
membertype = ': ' + typ if typ else ''
|
||||||
return '@item @code{%s%s}%s%s\n' % (
|
return '@item @code{%s%s}%s%s\n%s' % (
|
||||||
member.name, membertype,
|
member.name, membertype,
|
||||||
' (optional)' if member.optional else '',
|
' (optional)' if member.optional else '',
|
||||||
suffix)
|
suffix, desc)
|
||||||
|
|
||||||
|
|
||||||
def texi_members(doc, what, base, variants, member_func):
|
def texi_members(doc, what, base, variants, member_func):
|
||||||
|
@ -155,7 +163,7 @@ def texi_members(doc, what, base, variants, member_func):
|
||||||
desc = 'One of ' + members_text + '\n'
|
desc = 'One of ' + members_text + '\n'
|
||||||
else:
|
else:
|
||||||
desc = 'Not documented\n'
|
desc = 'Not documented\n'
|
||||||
items += member_func(section.member) + desc
|
items += member_func(section.member, desc, suffix='')
|
||||||
if base:
|
if base:
|
||||||
items += '@item The members of @code{%s}\n' % base.doc_type()
|
items += '@item The members of @code{%s}\n' % base.doc_type()
|
||||||
if variants:
|
if variants:
|
||||||
|
@ -165,7 +173,7 @@ def texi_members(doc, what, base, variants, member_func):
|
||||||
if v.type.is_implicit():
|
if v.type.is_implicit():
|
||||||
assert not v.type.base and not v.type.variants
|
assert not v.type.base and not v.type.variants
|
||||||
for m in v.type.local_members:
|
for m in v.type.local_members:
|
||||||
items += member_func(m, when)
|
items += member_func(m, desc='', suffix=when)
|
||||||
else:
|
else:
|
||||||
items += '@item The members of @code{%s}%s\n' % (
|
items += '@item The members of @code{%s}%s\n' % (
|
||||||
v.type.doc_type(), when)
|
v.type.doc_type(), when)
|
||||||
|
@ -185,8 +193,7 @@ def texi_sections(doc, ifcond):
|
||||||
body += texi_example(section.text)
|
body += texi_example(section.text)
|
||||||
else:
|
else:
|
||||||
body += texi_format(section.text)
|
body += texi_format(section.text)
|
||||||
if ifcond:
|
body += texi_if(ifcond, suffix='')
|
||||||
body += '\n\n@b{If:} @code{%s}' % ", ".join(ifcond)
|
|
||||||
return body
|
return body
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,9 @@
|
||||||
#
|
#
|
||||||
# @two is undocumented
|
# @two is undocumented
|
||||||
##
|
##
|
||||||
{ 'enum': 'Enum', 'data': [ 'one', 'two' ], 'if': 'defined(IFCOND)' }
|
{ 'enum': 'Enum', 'data':
|
||||||
|
[ { 'name': 'one', 'if': 'defined(IFONE)' }, 'two' ],
|
||||||
|
'if': 'defined(IFCOND)' }
|
||||||
|
|
||||||
##
|
##
|
||||||
# @Base:
|
# @Base:
|
||||||
|
|
|
@ -11,6 +11,7 @@ enum QType
|
||||||
module doc-good.json
|
module doc-good.json
|
||||||
enum Enum
|
enum Enum
|
||||||
member one
|
member one
|
||||||
|
if ['defined(IFONE)']
|
||||||
member two
|
member two
|
||||||
if ['defined(IFCOND)']
|
if ['defined(IFCOND)']
|
||||||
object Base
|
object Base
|
||||||
|
|
|
@ -84,12 +84,12 @@ Examples:
|
||||||
@table @asis
|
@table @asis
|
||||||
@item @code{one}
|
@item @code{one}
|
||||||
The @emph{one} @{and only@}
|
The @emph{one} @{and only@}
|
||||||
|
@*@b{If:} @code{defined(IFONE)}
|
||||||
@item @code{two}
|
@item @code{two}
|
||||||
Not documented
|
Not documented
|
||||||
@end table
|
@end table
|
||||||
@code{two} is undocumented
|
@code{two} is undocumented
|
||||||
|
|
||||||
|
|
||||||
@b{If:} @code{defined(IFCOND)}
|
@b{If:} @code{defined(IFCOND)}
|
||||||
@end deftp
|
@end deftp
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue