Prechádzať zdrojové kódy

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 <jsnow@redhat.com>
Message-ID: <20250313044312.189276-6-jsnow@redhat.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
John Snow 5 mesiacov pred
rodič
commit
7c7247b252
2 zmenil súbory, kde vykonal 32 pridanie a 1 odobranie
  1. 19 1
      docs/devel/qapi-domain.rst
  2. 13 0
      docs/sphinx/qapi_domain.py

+ 19 - 1
docs/devel/qapi-domain.rst

@@ -464,7 +464,8 @@ removed in a future version.
 QAPI standard options
 QAPI standard options
 ---------------------
 ---------------------
 
 
-All QAPI directives -- *except* for module -- support these common options.
+All QAPI directives -- *except* for namespace and module -- support
+these common options.
 
 
 * ``:namespace: name`` -- This option allows you to override the
 * ``:namespace: name`` -- This option allows you to override the
   namespace association of a given definition.
   namespace association of a given definition.
@@ -482,6 +483,23 @@ All QAPI directives -- *except* for module -- support these common options.
   production code.
   production code.
 
 
 
 
+qapi:namespace
+--------------
+
+The ``qapi:namespace`` directive marks the start of a QAPI namespace. It
+does not take a content body, nor any options. All subsequent QAPI
+directives are associated with the most recent namespace. This affects
+the definition's "fully qualified name", allowing two different
+namespaces to create an otherwise identically named definition.
+
+Example::
+
+   .. qapi:namespace:: QMP
+
+
+This directive has no visible effect.
+
+
 qapi:module
 qapi:module
 -----------
 -----------
 
 

+ 13 - 0
docs/sphinx/qapi_domain.py

@@ -38,6 +38,7 @@
 from sphinx.locale import _, __
 from sphinx.locale import _, __
 from sphinx.roles import XRefRole
 from sphinx.roles import XRefRole
 from sphinx.util import logging
 from sphinx.util import logging
+from sphinx.util.docutils import SphinxDirective
 from sphinx.util.nodes import make_id, make_refnode
 from sphinx.util.nodes import make_id, make_refnode
 
 
 
 
@@ -645,6 +646,17 @@ def run(self) -> List[Node]:
         return ret
         return ret
 
 
 
 
+class QAPINamespace(SphinxDirective):
+    has_content = False
+    required_arguments = 1
+
+    def run(self) -> List[Node]:
+        namespace = self.arguments[0].strip()
+        self.env.ref_context["qapi:namespace"] = namespace
+
+        return []
+
+
 class QAPIIndex(Index):
 class QAPIIndex(Index):
     """
     """
     Index subclass to provide the QAPI definition index.
     Index subclass to provide the QAPI definition index.
@@ -726,6 +738,7 @@ class QAPIDomain(Domain):
     # Each of these provides a rST directive,
     # Each of these provides a rST directive,
     # e.g. .. qapi:module:: block-core
     # e.g. .. qapi:module:: block-core
     directives = {
     directives = {
+        "namespace": QAPINamespace,
         "module": QAPIModule,
         "module": QAPIModule,
         "command": QAPICommand,
         "command": QAPICommand,
         "event": QAPIEvent,
         "event": QAPIEvent,