Skip to content

Commit c05de72

Browse files
jnsnowMarkus Armbruster
authored andcommitted
docs/qapidoc: add visit_entity()
Finally, the core entry method for a qapi entity. 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 8cb0a41 commit c05de72

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/sphinx/qapidoc.py

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

7979

8080
class Transmogrifier:
81+
# pylint: disable=too-many-public-methods
82+
8183
# Field names used for different entity types:
8284
field_types = {
8385
"enum": "value",
@@ -362,6 +364,25 @@ def visit_freeform(self, doc: QAPIDoc) -> None:
362364
self.add_lines(text, info)
363365
self.ensure_blank_line()
364366

367+
def visit_entity(self, ent: QAPISchemaDefinition) -> None:
368+
assert ent.info
369+
370+
try:
371+
self._curr_ent = ent
372+
373+
# Squish structs and unions together into an "object" directive.
374+
meta = ent.meta
375+
if meta in ("struct", "union"):
376+
meta = "object"
377+
378+
# This line gets credited to the start of the /definition/.
379+
self.add_line(f".. qapi:{meta}:: {ent.name}", ent.info)
380+
with self.indented():
381+
self.preamble(ent)
382+
self.visit_sections(ent)
383+
finally:
384+
self._curr_ent = None
385+
365386

366387
class QAPISchemaGenDepVisitor(QAPISchemaVisitor):
367388
"""A QAPI schema visitor which adds Sphinx dependencies each module

0 commit comments

Comments
 (0)