qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: stefanha@redhat.com, John Snow <jsnow@redhat.com>
Subject: [PULL 06/12] docs/qapi-domain: add qapi:namespace directive
Date: Fri, 14 Mar 2025 11:10:32 +0100	[thread overview]
Message-ID: <20250314101038.2408751-7-armbru@redhat.com> (raw)
In-Reply-To: <20250314101038.2408751-1-armbru@redhat.com>

From: John Snow <jsnow@redhat.com>

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>
---
 docs/devel/qapi-domain.rst | 20 +++++++++++++++++++-
 docs/sphinx/qapi_domain.py | 13 +++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/docs/devel/qapi-domain.rst b/docs/devel/qapi-domain.rst
index 51b283277e..73e13ab45c 100644
--- a/docs/devel/qapi-domain.rst
+++ b/docs/devel/qapi-domain.rst
@@ -464,7 +464,8 @@ removed in a future version.
 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 association of a given definition.
@@ -482,6 +483,23 @@ All QAPI directives -- *except* for module -- support these common options.
   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
 -----------
 
diff --git a/docs/sphinx/qapi_domain.py b/docs/sphinx/qapi_domain.py
index 6485c43206..a204af9b06 100644
--- a/docs/sphinx/qapi_domain.py
+++ b/docs/sphinx/qapi_domain.py
@@ -38,6 +38,7 @@
 from sphinx.locale import _, __
 from sphinx.roles import XRefRole
 from sphinx.util import logging
+from sphinx.util.docutils import SphinxDirective
 from sphinx.util.nodes import make_id, make_refnode
 
 
@@ -645,6 +646,17 @@ def run(self) -> List[Node]:
         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):
     """
     Index subclass to provide the QAPI definition index.
@@ -726,6 +738,7 @@ class QAPIDomain(Domain):
     # Each of these provides a rST directive,
     # e.g. .. qapi:module:: block-core
     directives = {
+        "namespace": QAPINamespace,
         "module": QAPIModule,
         "command": QAPICommand,
         "event": QAPIEvent,
-- 
2.48.1



  parent reply	other threads:[~2025-03-14 10:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-14 10:10 [PULL 00/12] QAPI patches patches for 2025-03-14 Markus Armbruster
2025-03-14 10:10 ` [PULL 01/12] qapi/block-core: Improve x-blockdev-change documentation Markus Armbruster
2025-03-14 10:10 ` [PULL 02/12] docs/qapi_domain: isolate TYPE_CHECKING imports Markus Armbruster
2025-03-14 10:10 ` [PULL 03/12] docs/qapi-domain: always store fully qualified name in signode Markus Armbruster
2025-03-14 10:10 ` [PULL 04/12] docs/qapi_domain: add namespace support to FQN Markus Armbruster
2025-03-14 10:10 ` [PULL 05/12] docs/qapi-domain: add :namespace: override option Markus Armbruster
2025-03-14 10:10 ` Markus Armbruster [this message]
2025-03-14 10:10 ` [PULL 07/12] docs/qapidoc: add :namespace: option to qapi-doc directive Markus Armbruster
2025-03-14 10:10 ` [PULL 08/12] docs/qapi_domain: add namespace support to cross-references Markus Armbruster
2025-03-14 10:10 ` [PULL 09/12] docs/qapi-domain: add namespaced index support Markus Armbruster
2025-03-14 10:10 ` [PULL 10/12] docs: add QAPI namespace "QMP" to qemu-qmp-ref Markus Armbruster
2025-03-14 10:10 ` [PULL 11/12] docs: disambiguate references in qapi-domain.rst Markus Armbruster
2025-03-14 10:10 ` [PULL 12/12] docs: enable transmogrifier for QSD and QGA Markus Armbruster
2025-03-16 10:09 ` [PULL 00/12] QAPI patches patches for 2025-03-14 Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250314101038.2408751-7-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).