Skip to content

Commit 52c806c

Browse files
jnsnowMarkus Armbruster
authored andcommitted
docs/qapidoc: add visit_returns() method
Generates :return: fields for explicit returns statements. Note that this does not presently handle undocumented returns, which is handled in a later commit. Signed-off-by: John Snow <[email protected]> Message-ID: <[email protected]> Acked-by: Markus Armbruster <[email protected]> Signed-off-by: Markus Armbruster <[email protected]>
1 parent 38a349f commit 52c806c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

docs/sphinx/qapidoc.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from qapi.schema import (
4242
QAPISchema,
4343
QAPISchemaArrayType,
44+
QAPISchemaCommand,
4445
QAPISchemaDefinition,
4546
QAPISchemaEnumMember,
4647
QAPISchemaFeature,
@@ -210,6 +211,20 @@ def visit_feature(self, section: QAPIDoc.ArgSection) -> None:
210211

211212
self.generate_field("feat", section.member, section.text, section.info)
212213

214+
def visit_returns(self, section: QAPIDoc.Section) -> None:
215+
assert isinstance(self.entity, QAPISchemaCommand)
216+
rtype = self.entity.ret_type
217+
# q_empty can produce None, but we won't be documenting anything
218+
# without an explicit return statement in the doc block, and we
219+
# should not have any such explicit statements when there is no
220+
# return value.
221+
assert rtype
222+
223+
typ = self.format_type(rtype)
224+
assert typ
225+
assert section.text
226+
self.add_field("return", typ, section.text, section.info)
227+
213228
def visit_errors(self, section: QAPIDoc.Section) -> None:
214229
# FIXME: the formatting for errors may be inconsistent and may
215230
# or may not require different newline placement to ensure

0 commit comments

Comments
 (0)