[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 13/27] docs/qapi-domain: add qapi:enum directive
|
From: |
John Snow |
|
Subject: |
[PATCH 13/27] docs/qapi-domain: add qapi:enum directive |
|
Date: |
Fri, 19 Apr 2024 00:38:01 -0400 |
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/qapi/index.rst | 14 ++++++++++++++
docs/sphinx/qapi-domain.py | 24 ++++++++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/docs/qapi/index.rst b/docs/qapi/index.rst
index 39fe4dd2dae..cf794e6e739 100644
--- a/docs/qapi/index.rst
+++ b/docs/qapi/index.rst
@@ -113,3 +113,17 @@ Explicit cross-referencing syntax for QAPI modules is
available with
At the moment, the order of grouped sections is based on the order in
which each group was encountered. This example will render Arguments
first, and then Features; but the order can be any that you choose.
+
+.. qapi:enum:: BitmapSyncMode
+ :since: 4.2
+
+ An enumeration of possible behaviors for the synchronization of a
+ bitmap when used for data copy operations.
+
+ :value on-success: The bitmap is only synced when the operation is
+ successful. This is the behavior always used for
+ ``INCREMENTAL`` backups.
+ :value never: The bitmap is never synchronized with the operation, and
+ is treated solely as a read-only manifest of blocks to copy.
+ :value always: The bitmap is always synchronized with the operation,
+ regardless of whether or not the operation was successful.
diff --git a/docs/sphinx/qapi-domain.py b/docs/sphinx/qapi-domain.py
index 5d44dba6cd3..6759c39290d 100644
--- a/docs/sphinx/qapi-domain.py
+++ b/docs/sphinx/qapi-domain.py
@@ -289,6 +289,22 @@ class QAPICommand(QAPIObject):
)
+class QAPIEnum(QAPIObject):
+ """Description of a QAPI Enum."""
+
+ doc_field_types = QAPIObject.doc_field_types.copy()
+ doc_field_types.extend(
+ [
+ GroupedField(
+ "value",
+ label=_("Values"),
+ names=("value",),
+ can_collapse=True,
+ )
+ ]
+ )
+
+
class QAPIModule(SphinxDirective):
"""
Directive to mark description of a new module.
@@ -434,9 +450,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 ReST directive,
@@ -444,6 +465,7 @@ class QAPIDomain(Domain):
directives = {
"module": QAPIModule,
"command": QAPICommand,
+ "enum": QAPIEnum,
}
# These are all cross-reference roles; e.g.
@@ -452,6 +474,8 @@ class QAPIDomain(Domain):
roles = {
"mod": QAPIXRefRole(),
"cmd": QAPIXRefRole(),
+ "enum": QAPIXRefRole(),
+ "type": QAPIXRefRole(), # reference any data type (excludes modules,
commands, events)
"obj": QAPIXRefRole(), # reference *any* type of QAPI object.
}
--
2.44.0
- [PATCH 00/27] Add qapi-domain Sphinx extension, John Snow, 2024/04/19
- [PATCH 03/27] docs/qapi-module: add QAPI domain object registry, John Snow, 2024/04/19
- [PATCH 04/27] docs/qapi-domain: add QAPI index, John Snow, 2024/04/19
- [PATCH 01/27] docs/sphinx: create QAPI domain extension stub, John Snow, 2024/04/19
- [PATCH 10/27] docs/qapi-domain: add "Features:" field lists, John Snow, 2024/04/19
- [PATCH 13/27] docs/qapi-domain: add qapi:enum directive,
John Snow <=
- [PATCH 16/27] docs/qapi-domain: add qapi:struct directive, John Snow, 2024/04/19
- [PATCH 15/27] docs/qapi-domain: add qapi:event directive, John Snow, 2024/04/19
- [PATCH 22/27] docs/qapi-domain: add warnings for malformed field lists, John Snow, 2024/04/19
- [PATCH 17/27] docs/qapi-domain: add qapi:union and qapi:branch directives, John Snow, 2024/04/19
- [PATCH 23/27] docs/qapi-domain: RFC patch - delete malformed field lists, John Snow, 2024/04/19
- [PATCH 21/27] docs/qapi-domain: RFC patch - add malformed field list entries, John Snow, 2024/04/19
- [PATCH 06/27] docs/qapi-domain: add QAPI xref roles, John Snow, 2024/04/19
- [PATCH 05/27] docs/qapi-domain: add resolve_any_xref(), John Snow, 2024/04/19
- [PATCH 07/27] docs/qapi-domain: add qapi:command directive, John Snow, 2024/04/19
- [PATCH 08/27] docs/qapi-domain: add :since: directive option, John Snow, 2024/04/19