Skip to content

Commit dbf51d1

Browse files
jnsnowMarkus Armbruster
authored andcommitted
docs/qapidoc: add visit_member() method
This method is used for generating the "members" of a wide variety of things, including structs, unions, enums, alternates, etc. The field name it uses to do so is dependent on the type of entity the "member" belongs to. Currently, IF conditionals for individual members are not handled or rendered, a small regression from the prior documentation generator. This will be fixed in a future patch. 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 52c806c commit dbf51d1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

docs/sphinx/qapidoc.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@
7878

7979

8080
class Transmogrifier:
81+
# Field names used for different entity types:
82+
field_types = {
83+
"enum": "value",
84+
"struct": "memb",
85+
"union": "memb",
86+
"event": "memb",
87+
"command": "arg",
88+
"alternate": "alt",
89+
}
90+
8191
def __init__(self) -> None:
8292
self._curr_ent: Optional[QAPISchemaDefinition] = None
8393
self._result = StringList()
@@ -88,6 +98,10 @@ def entity(self) -> QAPISchemaDefinition:
8898
assert self._curr_ent is not None
8999
return self._curr_ent
90100

101+
@property
102+
def member_field_type(self) -> str:
103+
return self.field_types[self.entity.meta]
104+
91105
# General-purpose rST generation functions
92106

93107
def get_indent(self) -> str:
@@ -202,6 +216,19 @@ def visit_paragraph(self, section: QAPIDoc.Section) -> None:
202216
self.add_lines(section.text, section.info)
203217
self.ensure_blank_line()
204218

219+
def visit_member(self, section: QAPIDoc.ArgSection) -> None:
220+
# FIXME: ifcond for members
221+
# TODO: features for members (documented at entity-level,
222+
# but sometimes defined per-member. Should we add such
223+
# information to member descriptions when we can?)
224+
assert section.text and section.member
225+
self.generate_field(
226+
self.member_field_type,
227+
section.member,
228+
section.text,
229+
section.info,
230+
)
231+
205232
def visit_feature(self, section: QAPIDoc.ArgSection) -> None:
206233
# FIXME - ifcond for features is not handled at all yet!
207234
# Proposal: decorate the right-hand column with some graphical

0 commit comments

Comments
 (0)