[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v2 18/35] docs/qapi-domain: add qapi:enum directive
From: |
John Snow |
Subject: |
[RFC PATCH v2 18/35] docs/qapi-domain: add qapi:enum directive |
Date: |
Thu, 12 Dec 2024 20:12:47 -0500 |
Add the .. qapi:enum:: directive, object, and :qapi:enum:`name`
cross-reference role.
Add the :value name: field list for documenting Enum values.
Of note, also introduce a new "type" role that is intended to be used by
other QAPI object directives to cross-reference arbitrary QAPI type
names, but will exclude commands, events, and modules from
consideration.
Signed-off-by: John Snow <jsnow@redhat.com>
---
docs/sphinx/qapi-domain.py | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/docs/sphinx/qapi-domain.py b/docs/sphinx/qapi-domain.py
index c46c87168bd..e37e300e4e6 100644
--- a/docs/sphinx/qapi-domain.py
+++ b/docs/sphinx/qapi-domain.py
@@ -287,6 +287,23 @@ class QAPICommand(QAPIObject):
)
+class QAPIEnum(QAPIObject):
+ """Description of a QAPI Enum."""
+
+ doc_field_types = QAPIObject.doc_field_types.copy()
+ doc_field_types.extend(
+ [
+ # :value name: descr
+ GroupedField(
+ "value",
+ label=_("Values"),
+ names=("value",),
+ can_collapse=False,
+ )
+ ]
+ )
+
+
class QAPIModule(SphinxDirective):
"""
Directive to mark description of a new module.
@@ -440,9 +457,14 @@ class QAPIDomain(Domain):
# This table associates cross-reference object types (key) with an
# ObjType instance, which defines the valid cross-reference roles
# for each object type.
+ #
+ # e.g., the :qapi:type: cross-reference role can refer to enum,
+ # struct, union, or alternate objects; but :qapi:obj: can refer to
+ # anything. Each object also gets its own targeted cross-reference role.
object_types: Dict[str, ObjType] = {
"module": ObjType(_("module"), "mod", "obj"),
"command": ObjType(_("command"), "cmd", "obj"),
+ "enum": ObjType(_("enum"), "enum", "obj", "type"),
}
# Each of these provides a rST directive,
@@ -450,6 +472,7 @@ class QAPIDomain(Domain):
directives = {
"module": QAPIModule,
"command": QAPICommand,
+ "enum": QAPIEnum,
}
# These are all cross-reference roles; e.g.
@@ -458,6 +481,9 @@ class QAPIDomain(Domain):
roles = {
"mod": QAPIXRefRole(),
"cmd": QAPIXRefRole(),
+ "enum": 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 06/35] docs/qapi-domain: add QAPI domain object registry, (continued)
- [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, 2024/12/12
- [RFC PATCH v2 18/35] docs/qapi-domain: add qapi:enum directive,
John Snow <=
- [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
- [RFC PATCH v2 29/35] docs/qapi-domain: warn when QAPI domain xrefs fail to resolve, John Snow, 2024/12/12