aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2024-07-16 22:13:11 -0400
committerMarkus Armbruster <armbru@redhat.com>2024-07-17 10:20:54 +0200
commit3c5f6114d9ffc70bc9b1a7cc0dddd72a911f966d (patch)
treebce7c24d6c09a3e5b6d91c68407473c645814f51 /tests
parent6f07c59fb16c68e91de82c086ce6c27d9e4748ca (diff)
downloadqemu-3c5f6114d9ffc70bc9b1a7cc0dddd72a911f966d.zip
qemu-3c5f6114d9ffc70bc9b1a7cc0dddd72a911f966d.tar.gz
qemu-3c5f6114d9ffc70bc9b1a7cc0dddd72a911f966d.tar.bz2
qapi: remove "Example" doc section
Fully eliminate the "Example" sections in QAPI doc blocks now that they have all been converted to arbitrary rST syntax using the ".. qmp-example::" directive. Update tests to match. Migrating to the new syntax --------------------------- The old "Example:" or "Examples:" section syntax is now caught as an error, but "Example::" is stil permitted as explicit rST syntax for an un-lexed, generic preformatted text block. ('Example' is not special in this case, any sentence that ends with "::" will start an indented code block in rST.) Arbitrary rST for Examples is now possible, but it's strongly recommended that documentation authors use the ".. qmp-example::" directive for consistent visual formatting in rendered HTML docs. The ":title:" directive option may be used to add extra information into the title bar for the example. The ":annotated:" option can be used to write arbitrary rST instead, with nested "::" blocks applying QMP formatting where desired. Other choices available are ".. code-block:: QMP" which will not create an "Example:" box, or the short-form "::" code-block syntax which will not apply QMP highlighting when used outside of the qmp-example directive. Why? ---- This patch has several benefits: 1. Example sections can now be written more arbitrarily, mixing explanatory paragraphs and code blocks however desired. 2. Example sections can now use fully arbitrary rST. 3. All code blocks are now lexed and validated as QMP; increasing usability of the docs and ensuring validity of example snippets. (To some extent - This patch only gaurantees it lexes correctly, not that it's valid under the JSON or QMP grammars. It will catch most small mistakes, however.) 4. Each qmp-example can be titled or annotated independently without bypassing the QMP lexer/validator. (i.e. code blocks are now for *code* only, so we don't have to sacrifice exposition for having lexically valid examples.) NOTE: As with the "Notes" conversion (d461c279737), this patch (and the three preceding) may change the rendering order for Examples in the current generator. The forthcoming qapidoc rewrite will fix this by always generating documentation in source order. Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20240717021312.606116-10-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/qapi-schema/doc-good.json19
-rw-r--r--tests/qapi-schema/doc-good.out26
-rw-r--r--tests/qapi-schema/doc-good.txt23
3 files changed, 40 insertions, 28 deletions
diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.json
index b565895..f64bf38 100644
--- a/tests/qapi-schema/doc-good.json
+++ b/tests/qapi-schema/doc-good.json
@@ -172,12 +172,17 @@
#
# Duis aute irure dolor
#
-# Example:
+# .. qmp-example::
+# :title: Ideal fast-food burger situation
#
-# -> in
-# <- out
+# -> "in"
+# <- "out"
#
-# Examples:
+# Examples::
+#
+# - Not a QMP code block
+# - Merely a preformatted code block literal
+# It isn't even an rST list.
# - *verbatim*
# - {braces}
#
@@ -199,11 +204,11 @@
# @cmd-feat1: a feature
# @cmd-feat2: another feature
#
-# Example:
+# .. qmp-example::
#
-# -> in
+# -> "this example"
#
-# <- out
+# <- "has no title"
##
{ 'command': 'cmd-boxed', 'boxed': true,
'data': 'Object',
diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
index a8e9456..6d24f11 100644
--- a/tests/qapi-schema/doc-good.out
+++ b/tests/qapi-schema/doc-good.out
@@ -184,13 +184,21 @@ frobnicate
- Ut enim ad minim veniam
Duis aute irure dolor
- section=Example
- -> in
- <- out
- section=Examples
+
+.. qmp-example::
+ :title: Ideal fast-food burger situation
+
+ -> "in"
+ <- "out"
+
+Examples::
+
+ - Not a QMP code block
+ - Merely a preformatted code block literal
+ It isn't even an rST list.
- *verbatim*
- {braces}
- section=None
+
Note::
Ceci n'est pas une note
section=Since
@@ -202,10 +210,12 @@ If you're bored enough to read this, go see a video of boxed cats
a feature
feature=cmd-feat2
another feature
- section=Example
- -> in
+ section=None
+.. qmp-example::
+
+ -> "this example"
- <- out
+ <- "has no title"
doc symbol=EVT_BOXED
body=
diff --git a/tests/qapi-schema/doc-good.txt b/tests/qapi-schema/doc-good.txt
index 30d457e..cb37db6 100644
--- a/tests/qapi-schema/doc-good.txt
+++ b/tests/qapi-schema/doc-good.txt
@@ -217,17 +217,16 @@ Notes:
Duis aute irure dolor
+Example: Ideal fast-food burger situation:
-Example
-~~~~~~~
-
- -> in
- <- out
-
+ -> "in"
+ <- "out"
-Examples
-~~~~~~~~
+Examples:
+ - Not a QMP code block
+ - Merely a preformatted code block literal
+ It isn't even an rST list.
- *verbatim*
- {braces}
@@ -261,13 +260,11 @@ Features
"cmd-feat2"
another feature
+Example::
-Example
-~~~~~~~
-
- -> in
+ -> "this example"
- <- out
+ <- "has no title"
"EVT_BOXED" (Event)