2017-03-20 13:11:54 +00:00
|
|
|
# -*- Mode: Python -*-
|
2020-07-29 18:50:24 +00:00
|
|
|
# vim: filetype=python
|
|
|
|
#
|
2017-03-20 13:11:54 +00:00
|
|
|
# Positive QAPI doc comment tests
|
|
|
|
|
qapi: Require member documentation (with loophole)
The QAPI generator forces you to document your stuff. Except for
command arguments, event data, and members of enum and object types:
these the generator silently "documents" as "Not documented".
We can't require proper documentation there without first fixing all
the offenders. We've always had too many offenders to pull that off.
Right now, we have more than 500. Worse, we seem to fix old ones no
faster than we add new ones: in the past year, we fixed 22 ones, but
added 26 new ones.
To help arrest the backsliding, make missing documentation an error
unless the command, type, or event is in listed in new pragma
documentation-exceptions.
List all the current offenders: 117 commands and types in qapi/, and 9
in qga/.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20240205074709.3613229-7-armbru@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2024-02-05 07:47:00 +00:00
|
|
|
{ 'pragma': {
|
|
|
|
'doc-required': true,
|
|
|
|
'documentation-exceptions': [ 'Enum', 'Variant1', 'Alternate', 'cmd' ] } }
|
2017-03-20 13:11:54 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
# = Section
|
2024-02-16 14:58:33 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2017-03-20 13:11:54 +00:00
|
|
|
# == Subsection
|
|
|
|
#
|
2020-09-25 16:23:07 +00:00
|
|
|
# *with emphasis*
|
2017-03-20 13:11:54 +00:00
|
|
|
# @var {in braces}
|
2020-09-25 16:22:58 +00:00
|
|
|
#
|
2017-03-20 13:11:54 +00:00
|
|
|
# * List item one
|
2020-09-25 16:22:58 +00:00
|
|
|
# * Two, multiple
|
2017-03-20 13:11:54 +00:00
|
|
|
# lines
|
|
|
|
#
|
2020-09-25 16:22:58 +00:00
|
|
|
# * Three
|
|
|
|
# Still in list
|
|
|
|
#
|
|
|
|
# Not in list
|
2017-03-20 13:11:54 +00:00
|
|
|
#
|
|
|
|
# - Second list
|
2020-09-25 16:22:58 +00:00
|
|
|
# Note: still in list
|
2017-03-20 13:11:54 +00:00
|
|
|
#
|
|
|
|
# Note: not in list
|
2020-09-25 16:22:58 +00:00
|
|
|
#
|
2017-03-20 13:11:54 +00:00
|
|
|
# 1. Third list
|
|
|
|
# is numbered
|
|
|
|
#
|
2020-09-25 16:22:58 +00:00
|
|
|
# 2. another item
|
2017-03-20 13:11:54 +00:00
|
|
|
#
|
|
|
|
# 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}
|
|
|
|
##
|
|
|
|
|
2024-06-26 22:21:12 +00:00
|
|
|
# Not a doc comment
|
|
|
|
|
2017-03-20 13:11:54 +00:00
|
|
|
##
|
|
|
|
# @Enum:
|
2021-09-30 20:57:07 +00:00
|
|
|
#
|
2023-04-28 10:54:22 +00:00
|
|
|
# @one: The _one_ {and only}, description on the same line
|
2017-03-20 13:11:54 +00:00
|
|
|
#
|
2020-03-17 11:54:37 +00:00
|
|
|
# Features:
|
|
|
|
# @enum-feat: Also _one_ {and only}
|
2021-10-25 04:24:02 +00:00
|
|
|
# @enum-member-feat: a member feature
|
2020-03-17 11:54:37 +00:00
|
|
|
#
|
2017-03-20 13:11:54 +00:00
|
|
|
# @two is undocumented
|
|
|
|
##
|
2021-09-17 14:31:12 +00:00
|
|
|
{ 'enum': 'Enum',
|
2021-10-25 04:24:02 +00:00
|
|
|
'data': [ { 'name': 'one', 'if': 'IFONE',
|
|
|
|
'features': [ 'enum-member-feat' ] },
|
|
|
|
'two' ],
|
2020-03-17 11:54:37 +00:00
|
|
|
'features': [ 'enum-feat' ],
|
2021-08-04 08:31:05 +00:00
|
|
|
'if': 'IFCOND' }
|
2017-03-20 13:11:54 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
# @Base:
|
2021-09-30 20:57:07 +00:00
|
|
|
#
|
2017-03-20 13:11:54 +00:00
|
|
|
# @base1:
|
2024-02-05 07:46:58 +00:00
|
|
|
# description starts on a new line,
|
|
|
|
# minimally indented
|
2017-03-20 13:11:54 +00:00
|
|
|
##
|
2021-08-04 08:31:01 +00:00
|
|
|
{ 'struct': 'Base', 'data': { 'base1': 'Enum' },
|
|
|
|
'if': { 'all': ['IFALL1', 'IFALL2'] } }
|
2017-03-20 13:11:54 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
# @Variant1:
|
2021-09-30 20:57:07 +00:00
|
|
|
#
|
2017-03-20 13:11:54 +00:00
|
|
|
# A paragraph
|
|
|
|
#
|
2023-04-28 10:54:21 +00:00
|
|
|
# Another paragraph
|
|
|
|
#
|
|
|
|
# @var1 is undocumented
|
2019-10-18 08:14:53 +00:00
|
|
|
#
|
|
|
|
# Features:
|
|
|
|
# @variant1-feat: a feature
|
2020-03-17 11:54:45 +00:00
|
|
|
# @member-feat: a member feature
|
2017-03-20 13:11:54 +00:00
|
|
|
##
|
2018-12-13 12:37:21 +00:00
|
|
|
{ 'struct': 'Variant1',
|
2019-10-18 08:14:53 +00:00
|
|
|
'features': [ 'variant1-feat' ],
|
2020-03-17 11:54:45 +00:00
|
|
|
'data': { 'var1': { 'type': 'str',
|
|
|
|
'features': [ 'member-feat' ],
|
2021-08-04 08:31:05 +00:00
|
|
|
'if': 'IFSTR' } } }
|
2017-03-20 13:11:54 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
# @Variant2:
|
2021-09-30 20:57:07 +00:00
|
|
|
#
|
2017-03-20 13:11:54 +00:00
|
|
|
##
|
|
|
|
{ 'struct': 'Variant2', 'data': {} }
|
|
|
|
|
|
|
|
##
|
|
|
|
# @Object:
|
2021-09-30 20:57:07 +00:00
|
|
|
#
|
2020-03-17 11:54:37 +00:00
|
|
|
# Features:
|
|
|
|
# @union-feat1: a feature
|
2017-03-20 13:11:54 +00:00
|
|
|
##
|
|
|
|
{ 'union': 'Object',
|
2020-03-17 11:54:37 +00:00
|
|
|
'features': [ 'union-feat1' ],
|
2017-03-20 13:11:54 +00:00
|
|
|
'base': 'Base',
|
|
|
|
'discriminator': 'base1',
|
2021-08-04 08:31:02 +00:00
|
|
|
'data': { 'one': 'Variant1',
|
|
|
|
'two': { 'type': 'Variant2',
|
|
|
|
'if': { 'any': ['IFONE', 'IFTWO'] } } } }
|
2017-03-20 13:11:54 +00:00
|
|
|
|
2019-10-24 11:02:21 +00:00
|
|
|
##
|
|
|
|
# @Alternate:
|
2021-09-30 20:57:07 +00:00
|
|
|
#
|
2023-04-28 10:54:22 +00:00
|
|
|
# @i: description starts on the same line
|
|
|
|
# remainder indented the same
|
2020-09-25 16:22:58 +00:00
|
|
|
# @b is undocumented
|
2020-03-17 11:54:37 +00:00
|
|
|
#
|
|
|
|
# Features:
|
|
|
|
# @alt-feat: a feature
|
2019-10-24 11:02:21 +00:00
|
|
|
##
|
|
|
|
{ 'alternate': 'Alternate',
|
2020-03-17 11:54:37 +00:00
|
|
|
'features': [ 'alt-feat' ],
|
2021-08-04 08:31:04 +00:00
|
|
|
'data': { 'i': 'int', 'b': 'bool' },
|
2021-08-31 12:38:01 +00:00
|
|
|
'if': { 'not': { 'any': [ 'IFONE', 'IFTWO' ] } } }
|
2019-10-24 11:02:21 +00:00
|
|
|
|
2017-03-20 13:11:54 +00:00
|
|
|
##
|
|
|
|
# == Another subsection
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# @cmd:
|
2021-09-30 20:57:07 +00:00
|
|
|
#
|
2023-04-28 10:54:22 +00:00
|
|
|
# @arg1:
|
|
|
|
# description starts on a new line,
|
|
|
|
# indented
|
2017-03-20 13:11:54 +00:00
|
|
|
#
|
qapi: Relax doc string @name: description indentation rules
The QAPI schema doc comment language provides special syntax for
command and event arguments, struct and union members, alternate
branches, enumeration values, and features: descriptions starting with
"@name:".
By convention, we format them like this:
# @name: Lorem ipsum dolor sit amet, consectetur adipiscing elit,
# sed do eiusmod tempor incididunt ut labore et dolore
# magna aliqua.
Okay for names as short as "name", but we have much longer ones. Their
description gets squeezed against the right margin, like this:
# @dirty-sync-missed-zero-copy: Number of times dirty RAM synchronization could
# not avoid copying dirty pages. This is between
# 0 and @dirty-sync-count * @multifd-channels.
# (since 7.1)
The description text is effectively just 50 characters wide. Easy
enough to read, but can be cumbersome to write.
The awkward squeeze against the right margin makes people go beyond it,
which produces two undesirables: arguments about style, and descriptions
that are unnecessarily hard to read, like this one:
# @postcopy-vcpu-blocktime: list of the postcopy blocktime per vCPU. This is
# only present when the postcopy-blocktime migration capability
# is enabled. (Since 3.0)
We could instead format it like
# @postcopy-vcpu-blocktime:
# list of the postcopy blocktime per vCPU. This is only present
# when the postcopy-blocktime migration capability is
# enabled. (Since 3.0)
or, since the commit before previous, like
# @postcopy-vcpu-blocktime:
# list of the postcopy blocktime per vCPU. This is only present
# when the postcopy-blocktime migration capability is
# enabled. (Since 3.0)
However, I'd rather have
# @postcopy-vcpu-blocktime: list of the postcopy blocktime per vCPU.
# This is only present when the postcopy-blocktime migration
# capability is enabled. (Since 3.0)
because this is how rST field and option lists work.
To get this, we need to let the first non-blank line after the
"@name:" line determine expected indentation.
This fills up the indentation pitfall mentioned in
docs/devel/qapi-code-gen.rst. A related pitfall still exists. Update
the text to show it.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20230428105429.1687850-14-armbru@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
[Work around lack of walrus operator in Python 3.7 and older]
2023-04-28 10:54:25 +00:00
|
|
|
# @arg2: description starts on the same line
|
|
|
|
# remainder indented differently
|
2019-10-18 08:14:53 +00:00
|
|
|
#
|
|
|
|
# Features:
|
|
|
|
# @cmd-feat1: a feature
|
|
|
|
# @cmd-feat2: another feature
|
2024-02-16 14:58:35 +00:00
|
|
|
#
|
qapi: convert "Note" sections to plain rST
We do not need a dedicated section for notes. By eliminating a specially
parsed section, these notes can be treated as normal rST paragraphs in
the new QMP reference manual, and can be placed and styled much more
flexibly.
Convert all existing "Note" and "Notes" sections to pure rST. As part of
the conversion, capitalize the first letter of each sentence and add
trailing punctuation where appropriate to ensure notes look sensible and
consistent in rendered HTML documentation. Markup is also re-aligned to
the de-facto standard of 3 spaces for directives.
Update docs/devel/qapi-code-gen.rst to reflect the new paradigm, and
update the QAPI parser to prohibit "Note" sections while suggesting a
new syntax. The exact formatting to use is a matter of taste, but a good
candidate is simply:
.. note:: lorem ipsum ...
... dolor sit amet ...
... consectetur adipiscing elit ...
... but there are other choices, too. The Sphinx readthedocs theme
offers theming for the following forms (capitalization unimportant); all
are adorned with a (!) symbol () in the title bar for rendered HTML
docs.
See
https://sphinx-rtd-theme.readthedocs.io/en/stable/demo/demo.html#admonitions
for examples of each directive/admonition in use.
These are rendered in orange:
.. Attention:: ...
.. Caution:: ...
.. WARNING:: ...
These are rendered in red:
.. DANGER:: ...
.. Error:: ...
These are rendered in green:
.. Hint:: ...
.. Important:: ...
.. Tip:: ...
These are rendered in blue:
.. Note:: ...
.. admonition:: custom title
admonition body text
This patch uses ".. note::" almost everywhere, with just two "caution"
directives. Several instances of "Notes:" have been converted to
merely ".. note::", or multiple ".. note::" where appropriate.
".. admonition:: notes" is used in a few places where we had an
ordered list of multiple notes that would not make sense as
standalone/separate admonitions. Two "Note:" following "Example:"
have been turned into ordinary paragraphs within the example.
NOTE: Because qapidoc.py does not attempt to preserve source ordering of
sections, the conversion of Notes from a "tagged section" to an
"untagged section" means that rendering order for some notes *may
change* as a result of this patch. The forthcoming qapidoc.py rewrite
strictly preserves source ordering in the rendered documentation, so
this issue will be rectified in the new generator.
Signed-off-by: John Snow <jsnow@redhat.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com> [for block*.json]
Message-ID: <20240626222128.406106-11-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Commit message clarified slightly, period added to one more note]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2024-06-26 22:21:16 +00:00
|
|
|
# .. note:: @arg3 is undocumented
|
2024-02-16 14:58:35 +00:00
|
|
|
#
|
2017-03-20 13:11:54 +00:00
|
|
|
# Returns: @Object
|
2024-02-16 14:58:35 +00:00
|
|
|
#
|
2024-02-27 11:39:11 +00:00
|
|
|
# Errors: some
|
|
|
|
#
|
2017-03-20 13:11:54 +00:00
|
|
|
# TODO: frobnicate
|
2024-02-16 14:58:35 +00:00
|
|
|
#
|
qapi: convert "Note" sections to plain rST
We do not need a dedicated section for notes. By eliminating a specially
parsed section, these notes can be treated as normal rST paragraphs in
the new QMP reference manual, and can be placed and styled much more
flexibly.
Convert all existing "Note" and "Notes" sections to pure rST. As part of
the conversion, capitalize the first letter of each sentence and add
trailing punctuation where appropriate to ensure notes look sensible and
consistent in rendered HTML documentation. Markup is also re-aligned to
the de-facto standard of 3 spaces for directives.
Update docs/devel/qapi-code-gen.rst to reflect the new paradigm, and
update the QAPI parser to prohibit "Note" sections while suggesting a
new syntax. The exact formatting to use is a matter of taste, but a good
candidate is simply:
.. note:: lorem ipsum ...
... dolor sit amet ...
... consectetur adipiscing elit ...
... but there are other choices, too. The Sphinx readthedocs theme
offers theming for the following forms (capitalization unimportant); all
are adorned with a (!) symbol () in the title bar for rendered HTML
docs.
See
https://sphinx-rtd-theme.readthedocs.io/en/stable/demo/demo.html#admonitions
for examples of each directive/admonition in use.
These are rendered in orange:
.. Attention:: ...
.. Caution:: ...
.. WARNING:: ...
These are rendered in red:
.. DANGER:: ...
.. Error:: ...
These are rendered in green:
.. Hint:: ...
.. Important:: ...
.. Tip:: ...
These are rendered in blue:
.. Note:: ...
.. admonition:: custom title
admonition body text
This patch uses ".. note::" almost everywhere, with just two "caution"
directives. Several instances of "Notes:" have been converted to
merely ".. note::", or multiple ".. note::" where appropriate.
".. admonition:: notes" is used in a few places where we had an
ordered list of multiple notes that would not make sense as
standalone/separate admonitions. Two "Note:" following "Example:"
have been turned into ordinary paragraphs within the example.
NOTE: Because qapidoc.py does not attempt to preserve source ordering of
sections, the conversion of Notes from a "tagged section" to an
"untagged section" means that rendering order for some notes *may
change* as a result of this patch. The forthcoming qapidoc.py rewrite
strictly preserves source ordering in the rendered documentation, so
this issue will be rectified in the new generator.
Signed-off-by: John Snow <jsnow@redhat.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com> [for block*.json]
Message-ID: <20240626222128.406106-11-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Commit message clarified slightly, period added to one more note]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2024-06-26 22:21:16 +00:00
|
|
|
# .. admonition:: Notes
|
2020-09-25 16:22:58 +00:00
|
|
|
#
|
2024-02-05 07:46:58 +00:00
|
|
|
# - Lorem ipsum dolor sit amet
|
|
|
|
# - Ut enim ad minim veniam
|
2017-03-20 13:11:54 +00:00
|
|
|
#
|
2024-02-05 07:46:58 +00:00
|
|
|
# Duis aute irure dolor
|
2024-02-16 14:58:35 +00:00
|
|
|
#
|
2017-03-20 13:11:54 +00:00
|
|
|
# Example:
|
|
|
|
#
|
2024-02-16 14:58:34 +00:00
|
|
|
# -> in
|
|
|
|
# <- out
|
2024-02-16 14:58:35 +00:00
|
|
|
#
|
2017-03-20 13:11:54 +00:00
|
|
|
# Examples:
|
2024-02-16 14:58:34 +00:00
|
|
|
# - *verbatim*
|
|
|
|
# - {braces}
|
2024-02-16 14:58:35 +00:00
|
|
|
#
|
2024-06-26 22:21:19 +00:00
|
|
|
# Note::
|
|
|
|
# Ceci n'est pas une note
|
|
|
|
#
|
2017-03-20 13:11:54 +00:00
|
|
|
# Since: 2.10
|
|
|
|
##
|
|
|
|
{ 'command': 'cmd',
|
|
|
|
'data': { 'arg1': 'int', '*arg2': 'str', 'arg3': 'bool' },
|
2019-10-18 08:14:53 +00:00
|
|
|
'returns': 'Object',
|
|
|
|
'features': [ 'cmd-feat1', 'cmd-feat2' ] }
|
2017-03-20 13:11:54 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
# @cmd-boxed:
|
|
|
|
# If you're bored enough to read this, go see a video of boxed cats
|
2024-02-16 14:58:35 +00:00
|
|
|
#
|
2019-10-18 08:14:53 +00:00
|
|
|
# Features:
|
|
|
|
# @cmd-feat1: a feature
|
|
|
|
# @cmd-feat2: another feature
|
2024-02-16 14:58:35 +00:00
|
|
|
#
|
2017-03-20 13:11:54 +00:00
|
|
|
# Example:
|
|
|
|
#
|
2024-02-16 14:58:34 +00:00
|
|
|
# -> in
|
2017-03-20 13:11:54 +00:00
|
|
|
#
|
2024-02-16 14:58:34 +00:00
|
|
|
# <- out
|
2017-03-20 13:11:54 +00:00
|
|
|
##
|
|
|
|
{ 'command': 'cmd-boxed', 'boxed': true,
|
2019-10-18 08:14:53 +00:00
|
|
|
'data': 'Object',
|
|
|
|
'features': [ 'cmd-feat1', 'cmd-feat2' ] }
|
2019-10-24 11:02:20 +00:00
|
|
|
|
|
|
|
##
|
2021-03-23 09:40:10 +00:00
|
|
|
# @EVT_BOXED:
|
2021-09-30 20:57:07 +00:00
|
|
|
#
|
2020-03-17 11:54:37 +00:00
|
|
|
# Features:
|
|
|
|
# @feat3: a feature
|
2019-10-24 11:02:20 +00:00
|
|
|
##
|
2021-03-23 09:40:10 +00:00
|
|
|
{ 'event': 'EVT_BOXED', 'boxed': true,
|
2020-03-17 11:54:37 +00:00
|
|
|
'features': [ 'feat3' ],
|
2019-10-24 11:02:20 +00:00
|
|
|
'data': 'Object' }
|