[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 15/27] docs/qapi-domain: add qapi:event directive
|
From: |
John Snow |
|
Subject: |
[PATCH 15/27] docs/qapi-domain: add qapi:event directive |
|
Date: |
Fri, 19 Apr 2024 00:38:03 -0400 |
Adds the .. qapi:event:: directive, object, and :qapi:event:`name`
cross-referencing role.
Adds the :memb type name: field list syntax for documenting event data
members. As this syntax and phrasing will be shared with Structs and
Unions as well, add the field list definition to a shared abstract
class.
As per usual, QAPI cross-referencing for types in the member field list
will be added in a forthcoming commit.
NOTE 1: The "str?" type annotation syntax sneaks into this commit in the
demonstration doc. It isn't processed yet, so just ignore it for
now. The non-RFC version of this series won't include the sandbox doc,
so that inconsistency will sort itself out later. (Skip ahead to the
commit that adds XRef support for TypedField and GroupedField lists to
learn what the deal is there and leave feedback on that syntax.)
NOTE 2: We already have a QMP lexer, turn it on for example blocks in this
sample demo.
Signed-off-by: John Snow <jsnow@redhat.com>
---
docs/qapi/index.rst | 40 ++++++++++++++++++++++++++++++++++++++
docs/sphinx/qapi-domain.py | 25 ++++++++++++++++++++++++
2 files changed, 65 insertions(+)
diff --git a/docs/qapi/index.rst b/docs/qapi/index.rst
index 9bfe4d9f454..d81bccfb06a 100644
--- a/docs/qapi/index.rst
+++ b/docs/qapi/index.rst
@@ -2,6 +2,12 @@
QAPI Domain Test
----------------
+.. this sets the code-highlighting language to QMP for this *document*.
+ I wonder if I can set a domain default...?
+
+.. highlight:: QMP
+
+
.. qapi:module:: foo-module
:no-index:
@@ -134,3 +140,37 @@ Explicit cross-referencing syntax for QAPI modules is
available with
:choice str local: name of the bitmap, attached to the same node as
target bitmap.
:choice BlockDirtyBitmap external: bitmap with specified node
+
+.. qapi:event:: BLOCK_JOB_COMPLETED
+ :since: 1.1
+
+ Emitted when a block job has completed.
+
+ :memb JobType type: job type
+ :memb str device: The job identifier. Originally the device name but
+ other values are allowed since QEMU 2.7
+ :memb int len: maximum progress value
+ :memb int offset: current progress value. On success this is equal to
+ len. On failure this is less than len
+ :memb int speed: rate limit, bytes per second
+ :memb str? error: error message. Only present on failure. This field
+ contains a human-readable error message. There are no semantics
+ other than that streaming has failed and clients should not try to
+ interpret the error string
+
+ Example::
+
+ <- {
+ "event": "BLOCK_JOB_COMPLETED",
+ "data": {
+ "type": "stream",
+ "device": "virtio-disk0",
+ "len": 10737418240,
+ "offset": 10737418240,
+ "speed": 0
+ },
+ "timestamp": {
+ "seconds": 1267061043,
+ "microseconds": 959568
+ }
+ }
diff --git a/docs/sphinx/qapi-domain.py b/docs/sphinx/qapi-domain.py
index c6eb6324594..74dc578b3c7 100644
--- a/docs/sphinx/qapi-domain.py
+++ b/docs/sphinx/qapi-domain.py
@@ -321,6 +321,28 @@ class QAPIAlternate(QAPIObject):
)
+class QAPIObjectWithMembers(QAPIObject):
+ """Base class for Events/Structs/Unions"""
+
+ doc_field_types = QAPIObject.doc_field_types.copy()
+ doc_field_types.extend(
+ [
+ TypedField(
+ "member",
+ label=_("Members"),
+ names=("memb",),
+ can_collapse=True,
+ ),
+ ]
+ )
+
+
+class QAPIEvent(QAPIObjectWithMembers):
+ """Description of a QAPI Event."""
+
+ pass
+
+
class QAPIModule(SphinxDirective):
"""
Directive to mark description of a new module.
@@ -473,6 +495,7 @@ class QAPIDomain(Domain):
object_types: Dict[str, ObjType] = {
"module": ObjType(_("module"), "mod", "obj"),
"command": ObjType(_("command"), "cmd", "obj"),
+ "event": ObjType(_("event"), "event", "obj"),
"enum": ObjType(_("enum"), "enum", "obj", "type"),
"alternate": ObjType(_("alternate"), "alt", "obj", "type"),
}
@@ -482,6 +505,7 @@ class QAPIDomain(Domain):
directives = {
"module": QAPIModule,
"command": QAPICommand,
+ "event": QAPIEvent,
"enum": QAPIEnum,
"alternate": QAPIAlternate,
}
@@ -492,6 +516,7 @@ class QAPIDomain(Domain):
roles = {
"mod": QAPIXRefRole(),
"cmd": QAPIXRefRole(),
+ "event": QAPIXRefRole(),
"enum": QAPIXRefRole(),
"alt": QAPIXRefRole(),
"type": QAPIXRefRole(), # reference any data type (excludes modules,
commands, events)
--
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, 2024/04/19
- [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 <=
- [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
- [PATCH 09/27] docs/qapi-domain: add "Arguments:" field lists, John Snow, 2024/04/19
- [PATCH 11/27] docs/qapi-domain: add "Errors:" field lists, John Snow, 2024/04/19