[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v2 19/35] docs/qapi-domain: add qapi:alternate directive
From: |
John Snow |
Subject: |
[RFC PATCH v2 19/35] docs/qapi-domain: add qapi:alternate directive |
Date: |
Thu, 12 Dec 2024 20:12:48 -0500 |
Add the .. qapi:alternate:: directive, object, and qapi:alt:`name`
cross-reference role.
Add the "Choices:" field list for describing alternate choices. Like
other field lists that reference QAPI types, a forthcoming commit will
add cross-referencing support to this field.
RFC: In the future, it would be nice to directly inline Alternates as
part of the type information in the containing object (i.e. directly in
arguments/members) - but that's a task for another series. For now, the
branch "names" are documented just like qapidoc.py does, even though
this information is superfluous for user documentation. Room for future
improvement, but not now.
Signed-off-by: John Snow <jsnow@redhat.com>
---
docs/sphinx/qapi-domain.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/docs/sphinx/qapi-domain.py b/docs/sphinx/qapi-domain.py
index e37e300e4e6..e0c31b2ee4d 100644
--- a/docs/sphinx/qapi-domain.py
+++ b/docs/sphinx/qapi-domain.py
@@ -304,6 +304,23 @@ class QAPIEnum(QAPIObject):
)
+class QAPIAlternate(QAPIObject):
+ """Description of a QAPI Alternate."""
+
+ doc_field_types = QAPIObject.doc_field_types.copy()
+ doc_field_types.extend(
+ [
+ # :choice type name: descr
+ TypedField(
+ "choice",
+ label=_("Choices"),
+ names=("choice",),
+ can_collapse=False,
+ ),
+ ]
+ )
+
+
class QAPIModule(SphinxDirective):
"""
Directive to mark description of a new module.
@@ -465,6 +482,7 @@ class QAPIDomain(Domain):
"module": ObjType(_("module"), "mod", "obj"),
"command": ObjType(_("command"), "cmd", "obj"),
"enum": ObjType(_("enum"), "enum", "obj", "type"),
+ "alternate": ObjType(_("alternate"), "alt", "obj", "type"),
}
# Each of these provides a rST directive,
@@ -473,6 +491,7 @@ class QAPIDomain(Domain):
"module": QAPIModule,
"command": QAPICommand,
"enum": QAPIEnum,
+ "alternate": QAPIAlternate,
}
# These are all cross-reference roles; e.g.
@@ -482,6 +501,7 @@ class QAPIDomain(Domain):
"mod": QAPIXRefRole(),
"cmd": QAPIXRefRole(),
"enum": QAPIXRefRole(),
+ "alt": QAPIXRefRole(),
# reference any data type (excludes modules, commands, events)
"type": QAPIXRefRole(),
"obj": QAPIXRefRole(), # reference *any* type of QAPI object.
--
2.47.0
- [RFC PATCH v2 09/35] docs/qapi-domain: add QAPI xref roles, (continued)
- [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, 2024/12/12
- [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 <=
- [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
- [RFC PATCH v2 22/35] docs/qapi-domain: add qapi:union and qapi:branch directives, John Snow, 2024/12/12
- [RFC PATCH v2 23/35] docs/qapi-domain: add :deprecated: directive option, John Snow, 2024/12/12
- [RFC PATCH v2 24/35] docs/qapi-domain: add :unstable: directive option, John Snow, 2024/12/12
- [RFC PATCH v2 26/35] docs/qapi-domain: add warnings for malformed field lists, John Snow, 2024/12/12
- [RFC PATCH v2 27/35] docs/qapi-domain: add type cross-refs to field lists, John Snow, 2024/12/12
- [RFC PATCH v2 25/35] docs/qapi-domain: add :ifcond: directive option, John Snow, 2024/12/12
- [RFC PATCH v2 30/35] docs/qapi-domain: implement error context reporting fix, John Snow, 2024/12/12
- [RFC PATCH v2 28/35] docs/qapi-domain: add CSS styling, John Snow, 2024/12/12