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 07/12] docs/qapidoc: add :namespace: option to qapi-doc directive
Date: Fri, 14 Mar 2025 11:10:33 +0100	[thread overview]
Message-ID: <20250314101038.2408751-8-armbru@redhat.com> (raw)
In-Reply-To: <20250314101038.2408751-1-armbru@redhat.com>

From: John Snow <jsnow@redhat.com>

Add a :namespace: option to the qapi-doc directive, which inserts a
qapi:namespace directive into the start of the generated document. This,
in turn, associates all auto-generated definitions by this directive
with the specified namespace.

The source info for these generated lines are credited to the start of
the qapi-doc directive, which isn't precisely correct, but I wasn't sure
how to get it more accurate without some re-parsing shenanigans.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-ID: <20250313044312.189276-7-jsnow@redhat.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 docs/sphinx/qapidoc.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/docs/sphinx/qapidoc.py b/docs/sphinx/qapidoc.py
index 432fef04b0..661b2c4ed0 100644
--- a/docs/sphinx/qapidoc.py
+++ b/docs/sphinx/qapidoc.py
@@ -451,6 +451,12 @@ def visit_entity(self, ent: QAPISchemaDefinition) -> None:
         finally:
             self._curr_ent = None
 
+    def set_namespace(self, namespace: str, source: str, lineno: int) -> None:
+        self.add_line_raw(
+            f".. qapi:namespace:: {namespace}", source, lineno + 1
+        )
+        self.ensure_blank_line()
+
 
 class QAPISchemaGenDepVisitor(QAPISchemaVisitor):
     """A QAPI schema visitor which adds Sphinx dependencies each module
@@ -496,6 +502,7 @@ class QAPIDocDirective(NestedDirective):
     optional_arguments = 1
     option_spec = {
         "qapifile": directives.unchanged_required,
+        "namespace": directives.unchanged,
         "transmogrify": directives.flag,
     }
     has_content = False
@@ -510,6 +517,11 @@ def transmogrify(self, schema: QAPISchema) -> nodes.Element:
         vis = Transmogrifier()
         modules = set()
 
+        if "namespace" in self.options:
+            vis.set_namespace(
+                self.options["namespace"], *self.get_source_info()
+            )
+
         for doc in schema.docs:
             module_source = doc.info.fname
             if module_source not in modules:
-- 
2.48.1



  parent reply	other threads:[~2025-03-14 10:13 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 ` [PULL 06/12] docs/qapi-domain: add qapi:namespace directive Markus Armbruster
2025-03-14 10:10 ` Markus Armbruster [this message]
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-8-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).