[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 07/14] docs/qapidoc: factor out do_parse()
From: |
Markus Armbruster |
Subject: |
[PULL 07/14] docs/qapidoc: factor out do_parse() |
Date: |
Wed, 17 Jul 2024 12:49:00 +0200 |
From: John Snow <jsnow@redhat.com>
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>
---
docs/sphinx/qapidoc.py | 32 +++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/docs/sphinx/qapidoc.py b/docs/sphinx/qapidoc.py
index 62b39833ca..b3be82998a 100644
--- a/docs/sphinx/qapidoc.py
+++ b/docs/sphinx/qapidoc.py
@@ -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"""
--
2.45.0
- [PULL 02/14] qapi/pci: Clean up documentation around PciDeviceClass, (continued)
- [PULL 02/14] qapi/pci: Clean up documentation around PciDeviceClass, Markus Armbruster, 2024/07/17
- [PULL 04/14] qapi/machine: Clarify query-uuid value when none has been specified, Markus Armbruster, 2024/07/17
- [PULL 03/14] qapi/machine: Clean up documentation around CpuInstanceProperties, Markus Armbruster, 2024/07/17
- [PULL 12/14] qapi: convert "Example" sections with titles, Markus Armbruster, 2024/07/17
- [PULL 06/14] qapi/ui: Drop note on naming of SpiceQueryMouseMode, Markus Armbruster, 2024/07/17
- [PULL 05/14] qapi/sockets: Move deprecation note out of SocketAddress doc comment, Markus Armbruster, 2024/07/17
- [PULL 01/14] qapi/qom: Document feature unstable of @x-vfio-user-server, Markus Armbruster, 2024/07/17
- [PULL 10/14] docs/sphinx: add CSS styling for qmp-example directive, Markus Armbruster, 2024/07/17
- [PULL 09/14] docs/qapidoc: add QMP highlighting to annotated qmp-example blocks, Markus Armbruster, 2024/07/17
- [PULL 14/14] qapi: remove "Example" doc section, Markus Armbruster, 2024/07/17
- [PULL 07/14] docs/qapidoc: factor out do_parse(),
Markus Armbruster <=
- [PULL 11/14] qapi: convert "Example" sections without titles, Markus Armbruster, 2024/07/17
- [PULL 13/14] qapi: convert "Example" sections with longer prose, Markus Armbruster, 2024/07/17
- [PULL 08/14] docs/qapidoc: create qmp-example directive, Markus Armbruster, 2024/07/17
- Re: [PULL 00/14] QAPI patches patches for 2024-07-17, Richard Henderson, 2024/07/18