Skip to content

Commit e389929

Browse files
author
Markus Armbruster
committed
sphinx/qapidoc: Fix to generate doc for explicit, unboxed arguments
When a command's arguments are specified as an explicit type T, generated documentation points to the members of T. Example: ## # @announce-self: # # Trigger generation of broadcast RARP frames to update network [...] ## { 'command': 'announce-self', 'boxed': true, 'data' : 'AnnounceParameters'} generates "announce-self" (Command) ------------------------- Trigger generation of broadcast RARP frames to update network [...] Arguments ~~~~~~~~~ The members of "AnnounceParameters" Except when the command takes its arguments unboxed , i.e. it doesn't have 'boxed': true, we generate *nothing*. A few commands have a reference in their doc comment to compensate, but most don't. Example: ## # @blockdev-snapshot-sync: # # Takes a synchronous snapshot of a block device. # # For the arguments, see the documentation of BlockdevSnapshotSync. [...] ## { 'command': 'blockdev-snapshot-sync', 'data': 'BlockdevSnapshotSync', 'allow-preconfig': true } generates "blockdev-snapshot-sync" (Command) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Takes a synchronous snapshot of a block device. For the arguments, see the documentation of BlockdevSnapshotSync. [...] Same for event data. Fix qapidoc.py to generate the reference regardless of boxing. Delete now redundant references in the doc comments. Fixes: 4078ee5 (docs/sphinx: Add new qapi-doc Sphinx extension) Cc: [email protected] Signed-off-by: Markus Armbruster <[email protected]> Message-ID: <[email protected]> Reviewed-by: John Snow <[email protected]>
1 parent 65fa48c commit e389929

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

docs/sphinx/qapidoc.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,15 @@ def _nodes_for_enum_values(self, doc):
230230
section += dlnode
231231
return [section]
232232

233-
def _nodes_for_arguments(self, doc, boxed_arg_type):
233+
def _nodes_for_arguments(self, doc, arg_type):
234234
"""Return list of doctree nodes for the arguments section"""
235-
if boxed_arg_type:
235+
if arg_type and not arg_type.is_implicit():
236236
assert not doc.args
237237
section = self._make_section('Arguments')
238238
dlnode = nodes.definition_list()
239239
dlnode += self._make_dlitem(
240240
[nodes.Text('The members of '),
241-
nodes.literal('', boxed_arg_type.name)],
241+
nodes.literal('', arg_type.name)],
242242
None)
243243
section += dlnode
244244
return [section]
@@ -352,17 +352,15 @@ def visit_command(self, name, info, ifcond, features, arg_type,
352352
allow_preconfig, coroutine):
353353
doc = self._cur_doc
354354
self._add_doc('Command',
355-
self._nodes_for_arguments(doc,
356-
arg_type if boxed else None)
355+
self._nodes_for_arguments(doc, arg_type)
357356
+ self._nodes_for_features(doc)
358357
+ self._nodes_for_sections(doc)
359358
+ self._nodes_for_if_section(ifcond))
360359

361360
def visit_event(self, name, info, ifcond, features, arg_type, boxed):
362361
doc = self._cur_doc
363362
self._add_doc('Event',
364-
self._nodes_for_arguments(doc,
365-
arg_type if boxed else None)
363+
self._nodes_for_arguments(doc, arg_type)
366364
+ self._nodes_for_features(doc)
367365
+ self._nodes_for_sections(doc)
368366
+ self._nodes_for_if_section(ifcond))

qapi/block-core.json

-7
Original file line numberDiff line numberDiff line change
@@ -1675,8 +1675,6 @@
16751675
#
16761676
# Takes a synchronous snapshot of a block device.
16771677
#
1678-
# For the arguments, see the documentation of BlockdevSnapshotSync.
1679-
#
16801678
# Errors:
16811679
# - If @device is not a valid block device, DeviceNotFound
16821680
#
@@ -1705,8 +1703,6 @@
17051703
# device, the block device changes to using 'overlay' as its new
17061704
# active image.
17071705
#
1708-
# For the arguments, see the documentation of BlockdevSnapshot.
1709-
#
17101706
# Features:
17111707
#
17121708
# @allow-write-only-overlay: If present, the check whether this
@@ -6065,9 +6061,6 @@
60656061
# string, or a snapshot with name already exists, the operation will
60666062
# fail.
60676063
#
6068-
# For the arguments, see the documentation of
6069-
# BlockdevSnapshotInternal.
6070-
#
60716064
# Errors:
60726065
# - If @device is not a valid block device, GenericError
60736066
# - If any snapshot matching @name exists, or @name is empty,

0 commit comments

Comments
 (0)