summary refs log tree commit diff stats
path: root/docs/sphinx
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2025-03-10 23:42:07 -0400
committerMarkus Armbruster <armbru@redhat.com>2025-03-11 10:07:03 +0100
commit6d64a27cd367d9d8639b560dc4ed13cf05b5f43b (patch)
tree4e0ff0994d7d5af49286b0c01f9305d3f9801172 /docs/sphinx
parent760b37e1df0cd4129127e1e381fb25b98ceecc79 (diff)
downloadfocaccia-qemu-6d64a27cd367d9d8639b560dc4ed13cf05b5f43b.tar.gz
focaccia-qemu-6d64a27cd367d9d8639b560dc4ed13cf05b5f43b.zip
docs/qapi-domain: add compatibility node classes
Sphinx prior to v4.0 uses different classes for rendering elements of
documentation objects; add some compatibility classes to use the right
node classes conditionally.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-ID: <20250311034303.75779-10-jsnow@redhat.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'docs/sphinx')
-rw-r--r--docs/sphinx/compat.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/docs/sphinx/compat.py b/docs/sphinx/compat.py
index 39b859a25e..6bc698c5ad 100644
--- a/docs/sphinx/compat.py
+++ b/docs/sphinx/compat.py
@@ -2,12 +2,27 @@
 Sphinx cross-version compatibility goop
 """
 
-from docutils.nodes import Element
+from typing import Callable
 
+from docutils.nodes import Element, Node, Text
+
+import sphinx
+from sphinx import addnodes
 from sphinx.util import nodes
 from sphinx.util.docutils import SphinxDirective, switch_source_input
 
 
+SpaceNode: Callable[[str], Node]
+KeywordNode: Callable[[str, str], Node]
+
+if sphinx.version_info[:3] >= (4, 0, 0):
+    SpaceNode = addnodes.desc_sig_space
+    KeywordNode = addnodes.desc_sig_keyword
+else:
+    SpaceNode = Text
+    KeywordNode = addnodes.desc_annotation
+
+
 def nested_parse_with_titles(
     directive: SphinxDirective, content_node: Element
 ) -> None: