aboutsummaryrefslogtreecommitdiff
path: root/docs/sphinx/qapi_domain.py
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2025-03-10 23:42:23 -0400
committerMarkus Armbruster <armbru@redhat.com>2025-03-11 10:10:57 +0100
commit6a41330206e0df32b93c371b551f89d393eda2c3 (patch)
tree8b8886ef92ce3352e8d76889fa9bc15d70f342ef /docs/sphinx/qapi_domain.py
parentd25808c2bc7921e5cd245111212ad7e3b6da3849 (diff)
downloadqemu-6a41330206e0df32b93c371b551f89d393eda2c3.zip
qemu-6a41330206e0df32b93c371b551f89d393eda2c3.tar.gz
qemu-6a41330206e0df32b93c371b551f89d393eda2c3.tar.bz2
docs/qapi-domain: add :ifcond: directive option
Add a special :ifcond: option that allows us to annotate the definition-level conditionals. The syntax of the argument is currently undefined, but it's possible we can apply better formatting in the future. Currently, we just display the ifcond string as preformatted text. Signed-off-by: Harmonie Snow <harmonie@gmail.com> Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-26-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'docs/sphinx/qapi_domain.py')
-rw-r--r--docs/sphinx/qapi_domain.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/docs/sphinx/qapi_domain.py b/docs/sphinx/qapi_domain.py
index 00fd11e..4531b5d 100644
--- a/docs/sphinx/qapi_domain.py
+++ b/docs/sphinx/qapi_domain.py
@@ -14,6 +14,7 @@ from typing import (
NamedTuple,
Optional,
Tuple,
+ Union,
cast,
)
@@ -217,6 +218,7 @@ class QAPIObject(QAPIDescription):
"module": directives.unchanged, # Override contextual module name
# These are QAPI originals:
"since": directives.unchanged,
+ "ifcond": directives.unchanged,
"deprecated": directives.flag,
"unstable": directives.flag,
}
@@ -288,9 +290,14 @@ class QAPIObject(QAPIDescription):
infopips = nodes.container()
infopips.attributes["classes"].append("qapi-infopips")
- def _add_pip(source: str, content: str, classname: str) -> None:
+ def _add_pip(
+ source: str, content: Union[str, List[nodes.Node]], classname: str
+ ) -> None:
node = nodes.container(source)
- node.append(nodes.Text(content))
+ if isinstance(content, str):
+ node.append(nodes.Text(content))
+ else:
+ node.extend(content)
node.attributes["classes"].extend(["qapi-infopip", classname])
infopips.append(node)
@@ -308,6 +315,18 @@ class QAPIObject(QAPIDescription):
"qapi-unstable",
)
+ if self.options.get("ifcond", ""):
+ ifcond = self.options["ifcond"]
+ _add_pip(
+ f":ifcond: {ifcond}",
+ [
+ nodes.emphasis("", "Availability"),
+ nodes.Text(": "),
+ nodes.literal(ifcond, ifcond),
+ ],
+ "qapi-ifcond",
+ )
+
if infopips.children:
contentnode.insert(0, infopips)