From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: Konstantin Kostiuk <kkostiuk@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
Eric Blake <eblake@redhat.com>,
qemu-block@nongnu.org, Michael Roth <michael.roth@amd.com>,
Kevin Wolf <kwolf@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
John Snow <jsnow@redhat.com>
Subject: [PATCH 03/11] docs/qapi_domain: add namespace support to FQN
Date: Thu, 13 Mar 2025 00:43:04 -0400 [thread overview]
Message-ID: <20250313044312.189276-4-jsnow@redhat.com> (raw)
In-Reply-To: <20250313044312.189276-1-jsnow@redhat.com>
This patch adds a namespace component to the "Fully Qualified Name", in
the form of "domain:module.name". As there are no namespace directives
or options yet, this component will simply be empty as of this patch.
Signed-off-by: John Snow <jsnow@redhat.com>
---
docs/sphinx/qapi_domain.py | 35 +++++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 8 deletions(-)
diff --git a/docs/sphinx/qapi_domain.py b/docs/sphinx/qapi_domain.py
index 6b23fc73ef2..48a082d489a 100644
--- a/docs/sphinx/qapi_domain.py
+++ b/docs/sphinx/qapi_domain.py
@@ -178,15 +178,18 @@ def get_index_text(self, name: Signature) -> Tuple[str, str]:
# NB: this is used for the global index, not the QAPI index.
return ("single", f"{name} (QMP {self.objtype})")
- def _get_context(self) -> str:
+ def _get_context(self) -> Tuple[str, str]:
+ namespace = self.options.get(
+ "namespace", self.env.ref_context.get("qapi:namespace", "")
+ )
modname = self.options.get(
"module", self.env.ref_context.get("qapi:module", "")
)
- assert isinstance(modname, str)
- return modname
+
+ return namespace, modname
def _get_fqn(self, name: Signature) -> str:
- modname = self._get_context()
+ namespace, modname = self._get_context()
# If we're documenting a module, don't include the module as
# part of the FQN; we ARE the module!
@@ -195,6 +198,8 @@ def _get_fqn(self, name: Signature) -> str:
if modname:
name = f"{modname}.{name}"
+ if namespace:
+ name = f"{namespace}:{name}"
return name
def add_target_and_index(
@@ -227,13 +232,18 @@ def add_target_and_index(
)
@staticmethod
- def split_fqn(name: str) -> Tuple[str, str]:
+ def split_fqn(name: str) -> Tuple[str, str, str]:
+ if ":" in name:
+ ns, name = name.split(":")
+ else:
+ ns = ""
+
if "." in name:
module, name = name.split(".")
else:
module = ""
- return (module, name)
+ return (ns, module, name)
def _object_hierarchy_parts(
self, sig_node: desc_signature
@@ -251,7 +261,7 @@ def _toc_entry_name(self, sig_node: desc_signature) -> str:
return ""
config = self.env.app.config
- modname, name = toc_parts
+ namespace, modname, name = toc_parts
if config.toc_object_entries_show_parents == "domain":
ret = name
@@ -259,6 +269,10 @@ def _toc_entry_name(self, sig_node: desc_signature) -> str:
"qapi:module", ""
):
ret = f"{modname}.{name}"
+ if namespace and namespace != self.env.ref_context.get(
+ "qapi:namespace", ""
+ ):
+ ret = f"{namespace}:{ret}"
return ret
if config.toc_object_entries_show_parents == "hide":
return name
@@ -334,10 +348,15 @@ def handle_signature(self, sig: str, signode: desc_signature) -> Signature:
As such, the only argument here is "sig", which is just the QAPI
definition name.
"""
- modname = self._get_context()
+ # No module or domain info allowed in the signature!
+ assert ":" not in sig
+ assert "." not in sig
+ namespace, modname = self._get_context()
signode["fullname"] = self._get_fqn(sig)
+ signode["namespace"] = namespace
signode["module"] = modname
+
sig_prefix = self.get_signature_prefix()
if sig_prefix:
signode += addnodes.desc_annotation(
--
2.48.1
next prev parent reply other threads:[~2025-03-13 4:45 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-13 4:43 [PATCH 00/11] docs/qapi: enable new guest-agent and storage-daemon docs John Snow
2025-03-13 4:43 ` [PATCH 01/11] docs/qapi_domain: isolate TYPE_CHECKING imports John Snow
2025-03-13 4:43 ` [PATCH 02/11] docs/qapi-domain: always store fully qualified name in signode John Snow
2025-03-13 4:43 ` John Snow [this message]
2025-03-13 4:43 ` [PATCH 04/11] docs/qapi-domain: add :namespace: override option John Snow
2025-03-13 6:39 ` Markus Armbruster
2025-03-13 13:55 ` John Snow
2025-03-13 4:43 ` [PATCH 05/11] docs/qapi-domain: add qapi:namespace directive John Snow
2025-03-13 4:43 ` [PATCH 06/11] docs/qapidoc: add :namespace: option to qapi-doc directive John Snow
2025-03-13 4:43 ` [PATCH 07/11] docs/qapi_domain: add namespace support to cross-references John Snow
2025-03-13 6:47 ` Markus Armbruster
2025-03-13 13:58 ` John Snow
2025-03-13 14:40 ` Markus Armbruster
2025-03-13 15:10 ` John Snow
2025-03-13 15:57 ` Markus Armbruster
2025-03-13 16:57 ` John Snow
2025-03-13 18:30 ` Markus Armbruster
2025-03-13 18:59 ` John Snow
2025-03-14 7:08 ` Markus Armbruster
2025-03-14 7:20 ` Markus Armbruster
2025-03-13 4:43 ` [PATCH 08/11] docs/qapi-domain: add namespaced index support John Snow
2025-03-14 8:06 ` Markus Armbruster
2025-03-13 4:43 ` [PATCH 09/11] docs: add QAPI namespace "QMP" to qemu-qmp-ref John Snow
2025-03-14 7:27 ` Markus Armbruster
2025-03-13 4:43 ` [PATCH 10/11] docs: disambiguate references in qapi-domain.rst John Snow
2025-03-13 4:43 ` [PATCH 11/11] docs: enable transmogrifier for QSD and QGA John Snow
2025-03-13 6:54 ` Markus Armbruster
2025-03-13 14:02 ` John Snow
2025-03-13 15:27 ` Markus Armbruster
2025-03-14 9:21 ` [PATCH 00/11] docs/qapi: enable new guest-agent and storage-daemon docs Markus Armbruster
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=20250313044312.189276-4-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=kkostiuk@redhat.com \
--cc=kwolf@redhat.com \
--cc=michael.roth@amd.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).