Skip to content

Commit 7c7247b

Browse files
jnsnowMarkus Armbruster
authored andcommitted
docs/qapi-domain: add qapi:namespace directive
Add a new directive that marks the beginning of a QAPI "namespace", for example; "QMP", "QGA" or "QSD". This directive will associate all subsequent QAPI directives in a document with the specified namespace. This does not change the visual display of any of the definitions or index entries, but does change the "Fully Qualified Name" inside the QAPI domain's object table. This allows for two different "namespaces" to define entities with otherwise identical names -- which will come in handy for documenting both QEMU QMP and the QEMU Storage Daemon. Signed-off-by: John Snow <[email protected]> Message-ID: <[email protected]> Acked-by: Markus Armbruster <[email protected]> Signed-off-by: Markus Armbruster <[email protected]>
1 parent 9ca404f commit 7c7247b

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

docs/devel/qapi-domain.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,8 @@ removed in a future version.
464464
QAPI standard options
465465
---------------------
466466

467-
All QAPI directives -- *except* for module -- support these common options.
467+
All QAPI directives -- *except* for namespace and module -- support
468+
these common options.
468469

469470
* ``:namespace: name`` -- This option allows you to override the
470471
namespace association of a given definition.
@@ -482,6 +483,23 @@ All QAPI directives -- *except* for module -- support these common options.
482483
production code.
483484

484485

486+
qapi:namespace
487+
--------------
488+
489+
The ``qapi:namespace`` directive marks the start of a QAPI namespace. It
490+
does not take a content body, nor any options. All subsequent QAPI
491+
directives are associated with the most recent namespace. This affects
492+
the definition's "fully qualified name", allowing two different
493+
namespaces to create an otherwise identically named definition.
494+
495+
Example::
496+
497+
.. qapi:namespace:: QMP
498+
499+
500+
This directive has no visible effect.
501+
502+
485503
qapi:module
486504
-----------
487505

docs/sphinx/qapi_domain.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from sphinx.locale import _, __
3939
from sphinx.roles import XRefRole
4040
from sphinx.util import logging
41+
from sphinx.util.docutils import SphinxDirective
4142
from sphinx.util.nodes import make_id, make_refnode
4243

4344

@@ -645,6 +646,17 @@ def run(self) -> List[Node]:
645646
return ret
646647

647648

649+
class QAPINamespace(SphinxDirective):
650+
has_content = False
651+
required_arguments = 1
652+
653+
def run(self) -> List[Node]:
654+
namespace = self.arguments[0].strip()
655+
self.env.ref_context["qapi:namespace"] = namespace
656+
657+
return []
658+
659+
648660
class QAPIIndex(Index):
649661
"""
650662
Index subclass to provide the QAPI definition index.
@@ -726,6 +738,7 @@ class QAPIDomain(Domain):
726738
# Each of these provides a rST directive,
727739
# e.g. .. qapi:module:: block-core
728740
directives = {
741+
"namespace": QAPINamespace,
729742
"module": QAPIModule,
730743
"command": QAPICommand,
731744
"event": QAPIEvent,

0 commit comments

Comments
 (0)