mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
docs/qapidoc: factor out do_parse()
Factor out the compatibility parser helper into a base class, so it can be shared by other directives. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240717021312.606116-3-jsnow@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
29a9efb09f
commit
a7d07ccd20
1 changed files with 19 additions and 13 deletions
|
@ -481,7 +481,25 @@ class QAPISchemaGenDepVisitor(QAPISchemaVisitor):
|
||||||
super().visit_module(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"""
|
"""Extract documentation from the specified QAPI .json file"""
|
||||||
|
|
||||||
required_argument = 1
|
required_argument = 1
|
||||||
|
@ -519,18 +537,6 @@ class QAPIDocDirective(Directive):
|
||||||
# so they are displayed nicely to the user
|
# so they are displayed nicely to the user
|
||||||
raise ExtensionError(str(err)) from err
|
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):
|
def setup(app):
|
||||||
"""Register qapi-doc directive with Sphinx"""
|
"""Register qapi-doc directive with Sphinx"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue