Skip to content

Commit e4a9b44

Browse files
Markus ArmbrusterMichael Tokarev
authored andcommitted
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]> (cherry picked from commit e389929) Signed-off-by: Michael Tokarev <[email protected]>
1 parent 837864a commit e4a9b44

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

docs/sphinx/qapidoc.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,15 @@ def _nodes_for_enum_values(self, doc):
219219
section += dlnode
220220
return [section]
221221

222-
def _nodes_for_arguments(self, doc, boxed_arg_type):
222+
def _nodes_for_arguments(self, doc, arg_type):
223223
"""Return list of doctree nodes for the arguments section"""
224-
if boxed_arg_type:
224+
if arg_type and not arg_type.is_implicit():
225225
assert not doc.args
226226
section = self._make_section('Arguments')
227227
dlnode = nodes.definition_list()
228228
dlnode += self._make_dlitem(
229229
[nodes.Text('The members of '),
230-
nodes.literal('', boxed_arg_type.name)],
230+
nodes.literal('', arg_type.name)],
231231
None)
232232
section += dlnode
233233
return [section]
@@ -331,17 +331,15 @@ def visit_command(self, name, info, ifcond, features, arg_type,
331331
allow_preconfig, coroutine):
332332
doc = self._cur_doc
333333
self._add_doc('Command',
334-
self._nodes_for_arguments(doc,
335-
arg_type if boxed else None)
334+
self._nodes_for_arguments(doc, arg_type)
336335
+ self._nodes_for_features(doc)
337336
+ self._nodes_for_sections(doc)
338337
+ self._nodes_for_if_section(ifcond))
339338

340339
def visit_event(self, name, info, ifcond, features, arg_type, boxed):
341340
doc = self._cur_doc
342341
self._add_doc('Event',
343-
self._nodes_for_arguments(doc,
344-
arg_type if boxed else None)
342+
self._nodes_for_arguments(doc, arg_type)
345343
+ self._nodes_for_features(doc)
346344
+ self._nodes_for_sections(doc)
347345
+ self._nodes_for_if_section(ifcond))

qapi/block-core.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,8 +1671,6 @@
16711671
#
16721672
# Takes a synchronous snapshot of a block device.
16731673
#
1674-
# For the arguments, see the documentation of BlockdevSnapshotSync.
1675-
#
16761674
# Errors:
16771675
# - If @device is not a valid block device, DeviceNotFound
16781676
#
@@ -1701,8 +1699,6 @@
17011699
# device, the block device changes to using 'overlay' as its new
17021700
# active image.
17031701
#
1704-
# For the arguments, see the documentation of BlockdevSnapshot.
1705-
#
17061702
# Features:
17071703
#
17081704
# @allow-write-only-overlay: If present, the check whether this
@@ -6061,9 +6057,6 @@
60616057
# string, or a snapshot with name already exists, the operation will
60626058
# fail.
60636059
#
6064-
# For the arguments, see the documentation of
6065-
# BlockdevSnapshotInternal.
6066-
#
60676060
# Errors:
60686061
# - If @device is not a valid block device, GenericError
60696062
# - If any snapshot matching @name exists, or @name is empty,

0 commit comments

Comments
 (0)