qemu/tests/qapi-schema/doc-good.txt
John Snow 3c5f6114d9 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 (d461c27973), 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>
2024-07-17 10:20:54 +02:00

284 lines
2.9 KiB
Plaintext

Section
*******
Subsection
==========
*with emphasis* "var" {in braces}
* List item one
* Two, multiple lines
* Three Still in list
Not in list
* Second list Note: still in list
Note: not in list
1. Third list is numbered
2. another item
Returns: the King Since: the first age Notes:
1. Lorem ipsum dolor sit amet
2. Ut enim ad minim veniam
Duis aute irure dolor
Example:
-> in <- out Examples: - *verbatim* - {braces}
"Enum" (Enum)
-------------
Values
~~~~~~
"one" (**If: **"IFONE")
The _one_ {and only}, description on the same line
"two"
Not documented
Features
~~~~~~~~
"enum-feat"
Also _one_ {and only}
"enum-member-feat"
a member feature
"two" is undocumented
If
~~
"IFCOND"
"Base" (Object)
---------------
Members
~~~~~~~
"base1": "Enum"
description starts on a new line, minimally indented
If
~~
"IFALL1 and IFALL2"
"Variant1" (Object)
-------------------
A paragraph
Another paragraph
"var1" is undocumented
Members
~~~~~~~
"var1": "string" (**If: **"IFSTR")
Not documented
Features
~~~~~~~~
"variant1-feat"
a feature
"member-feat"
a member feature
"Variant2" (Object)
-------------------
"Object" (Object)
-----------------
Members
~~~~~~~
The members of "Base"
The members of "Variant1" when "base1" is ""one""
The members of "Variant2" when "base1" is ""two"" (**If: **"IFONE or
IFTWO")
Features
~~~~~~~~
"union-feat1"
a feature
"Alternate" (Alternate)
-----------------------
Members
~~~~~~~
"i": "int"
description starts on the same line remainder indented the same "b"
is undocumented
"b": "boolean"
Not documented
Features
~~~~~~~~
"alt-feat"
a feature
If
~~
"not (IFONE or IFTWO)"
Another subsection
==================
"cmd" (Command)
---------------
Arguments
~~~~~~~~~
"arg1": "int"
description starts on a new line, indented
"arg2": "string" (optional)
description starts on the same line remainder indented differently
"arg3": "boolean"
Not documented
Features
~~~~~~~~
"cmd-feat1"
a feature
"cmd-feat2"
another feature
Note:
"arg3" is undocumented
Returns
~~~~~~~
"Object"
Errors
~~~~~~
some
Notes:
* Lorem ipsum dolor sit amet
* Ut enim ad minim veniam
Duis aute irure dolor
Example: 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}
Note::
Ceci n'est pas une note
Since
~~~~~
2.10
"cmd-boxed" (Command)
---------------------
If you're bored enough to read this, go see a video of boxed cats
Arguments
~~~~~~~~~
The members of "Object"
Features
~~~~~~~~
"cmd-feat1"
a feature
"cmd-feat2"
another feature
Example::
-> "this example"
<- "has no title"
"EVT_BOXED" (Event)
-------------------
Arguments
~~~~~~~~~
The members of "Object"
Features
~~~~~~~~
"feat3"
a feature