diff mbox series

[RFC,v2,34/35] WIP: 3.x ObjectDesc compat

Message ID 20241213011307.2942030-35-jsnow@redhat.com (mailing list archive)
State New
Headers show
Series Add qapi-domain Sphinx extension | expand

Commit Message

John Snow Dec. 13, 2024, 1:13 a.m. UTC
Signed-off-by: John Snow <jsnow@redhat.com>
---
 docs/sphinx/compat.py      | 7 +++++++
 docs/sphinx/qapi-domain.py | 9 +++------
 2 files changed, 10 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/docs/sphinx/compat.py b/docs/sphinx/compat.py
index 5126b450a5f..b2d2d1be403 100644
--- a/docs/sphinx/compat.py
+++ b/docs/sphinx/compat.py
@@ -33,15 +33,22 @@ 
 SOURCE_LOCATION_FIX = (5, 3, 0) <= sphinx.version_info[:3] < (6, 2, 0)
 
 
+# Alias for the return of QAPIObject.handle_signature(), which is used
+# in several places. (In the Python domain, this type is Tuple[str,
+# str] instead.)
+Signature = str
+
 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
+    ObjectDesc = ObjectDescription[Signature]
 else:
     space_node = Text
     keyword_node = addnodes.desc_annotation
+    ObjectDesc = ObjectDescription
 
 
 def nested_parse(directive: SphinxDirective, content_node: Element) -> None:
diff --git a/docs/sphinx/qapi-domain.py b/docs/sphinx/qapi-domain.py
index 00d32d44e1d..fcda281d45e 100644
--- a/docs/sphinx/qapi-domain.py
+++ b/docs/sphinx/qapi-domain.py
@@ -26,7 +26,9 @@ 
 from compat import (
     Field,
     GroupedField,
+    ObjectDesc,
     ParserFix,
+    Signature,
     TypedField,
     keyword_node,
     nested_parse,
@@ -164,12 +166,7 @@  def since_validator(param: str) -> str:
     return param
 
 
-# Alias for the return of handle_signature(), which is used in several places.
-# (In the Python domain, this is Tuple[str, str] instead.)
-Signature = str
-
-
-class QAPIObject(ParserFix, ObjectDescription[Signature]):
+class QAPIObject(ParserFix, ObjectDesc):
     """
     Description of a generic QAPI object.