[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v2 10/35] docs/qapi-domain: add compatibility node classes
From: |
John Snow |
Subject: |
[RFC PATCH v2 10/35] docs/qapi-domain: add compatibility node classes |
Date: |
Thu, 12 Dec 2024 20:12:39 -0500 |
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>
---
docs/sphinx/compat.py | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/docs/sphinx/compat.py b/docs/sphinx/compat.py
index 4c8d1e94530..28cb39161fe 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.docutils import SphinxDirective, switch_source_input
from sphinx.util.nodes import nested_parse_with_titles
+space_node: Callable[[str], Node]
+keyword_node: Callable[[str, str], Node]
+
+if sphinx.version_info[:3] >= (4, 0, 0):
+ space_node = addnodes.desc_sig_space
+ keyword_node = addnodes.desc_sig_keyword
+else:
+ space_node = Text
+ keyword_node = addnodes.desc_annotation
+
+
def nested_parse(directive: SphinxDirective, content_node: Element) -> None:
"""
This helper preserves error parsing context across sphinx versions.
--
2.47.0
- [RFC PATCH v2 00/35] Add qapi-domain Sphinx extension, John Snow, 2024/12/12
- [RFC PATCH v2 01/35] do-not-merge, John Snow, 2024/12/12
- [RFC PATCH v2 02/35] pylint touchups, John Snow, 2024/12/12
- [RFC PATCH v2 03/35] docs/sphinx: create QAPI domain extension stub, John Snow, 2024/12/12
- [RFC PATCH v2 04/35] docs/sphinx: add compat.py module and nested_parse helper, John Snow, 2024/12/12
- [RFC PATCH v2 05/35] docs/qapi-domain: add qapi:module directive, John Snow, 2024/12/12
- [RFC PATCH v2 08/35] docs/qapi-domain: add resolve_any_xref(), John Snow, 2024/12/12
- [RFC PATCH v2 07/35] docs/qapi-domain: add QAPI index, John Snow, 2024/12/12
- [RFC PATCH v2 09/35] docs/qapi-domain: add QAPI xref roles, John Snow, 2024/12/12
- [RFC PATCH v2 06/35] docs/qapi-domain: add QAPI domain object registry, John Snow, 2024/12/12
- [RFC PATCH v2 10/35] docs/qapi-domain: add compatibility node classes,
John Snow <=
- [RFC PATCH v2 11/35] docs/qapi-domain: add qapi:command directive, John Snow, 2024/12/12
- [RFC PATCH v2 12/35] docs/qapi-domain: add :since: directive option, John Snow, 2024/12/12
- [RFC PATCH v2 13/35] docs/qapi-domain: add "Arguments:" field lists, John Snow, 2024/12/12
- [RFC PATCH v2 14/35] docs/qapi-domain: add "Features:" field lists, John Snow, 2024/12/12
- [RFC PATCH v2 15/35] docs/qapi-domain: add "Errors:" field lists, John Snow, 2024/12/12
- [RFC PATCH v2 16/35] docs/qapi-domain: add "Returns:" field lists, John Snow, 2024/12/12
- [RFC PATCH v2 17/35] docs/qapi-domain: add returns-nodesc, John Snow, 2024/12/12
- [RFC PATCH v2 19/35] docs/qapi-domain: add qapi:alternate directive, John Snow, 2024/12/12
- [RFC PATCH v2 18/35] docs/qapi-domain: add qapi:enum directive, John Snow, 2024/12/12
- [RFC PATCH v2 20/35] docs/qapi-domain: add qapi:event directive, John Snow, 2024/12/12