@@ -481,7 +481,25 @@ def visit_module(self, name):
super().visit_module(name)
-class QAPIDocDirective(Directive):
+class NestedDirective(Directive):
+ def run(self):
+ raise NotImplementedError
+
+ def do_parse(self, rstlist, node):
+ """
+ Parse rST source lines and add them to the specified node
+
+ Take the list of rST source lines rstlist, parse them as
+ rST, and add the resulting docutils nodes as children of node.
+ The nodes are parsed in a way that allows them to include
+ subheadings (titles) without confusing the rendering of
+ anything else.
+ """
+ with switch_source_input(self.state, rstlist):
+ nested_parse_with_titles(self.state, rstlist, node)
+
+
+class QAPIDocDirective(NestedDirective):
"""Extract documentation from the specified QAPI .json file"""
required_argument = 1
@@ -519,18 +537,6 @@ def run(self):
# so they are displayed nicely to the user
raise ExtensionError(str(err)) from err
- def do_parse(self, rstlist, node):
- """Parse rST source lines and add them to the specified node
-
- Take the list of rST source lines rstlist, parse them as
- rST, and add the resulting docutils nodes as children of node.
- The nodes are parsed in a way that allows them to include
- subheadings (titles) without confusing the rendering of
- anything else.
- """
- with switch_source_input(self.state, rstlist):
- nested_parse_with_titles(self.state, rstlist, node)
-
def setup(app):
"""Register qapi-doc directive with Sphinx"""