2017-03-20 14:11:54 +01:00
|
|
|
# -*- Mode: Python -*-
|
2020-07-29 20:50:24 +02:00
|
|
|
# vim: filetype=python
|
|
|
|
#
|
2017-03-20 14:11:54 +01: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 08:47:00 +01:00
|
|
|
{ 'pragma': {
|
|
|
|
'doc-required': true,
|
|
|
|
'documentation-exceptions': [ 'Enum', 'Variant1', 'Alternate', 'cmd' ] } }
|
2017-03-20 14:11:54 +01:00
|
|
|
|
|
|
|
##
|
|
|
|
# = Section
|
2024-02-16 15:58:33 +01:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2017-03-20 14:11:54 +01:00
|
|
|
# == Subsection
|
|
|
|
#
|
2020-09-25 17:23:07 +01:00
|
|
|
# *with emphasis*
|
2017-03-20 14:11:54 +01:00
|
|
|
# @var {in braces}
|
2020-09-25 17:22:58 +01:00
|
|
|
#
|
2017-03-20 14:11:54 +01:00
|
|
|
# * List item one
|
2020-09-25 17:22:58 +01:00
|
|
|
# * Two, multiple
|
2017-03-20 14:11:54 +01:00
|
|
|
# lines
|
|
|
|
#
|
2020-09-25 17:22:58 +01:00
|
|
|
# * Three
|
|
|
|
# Still in list
|
|
|
|
#
|
|
|
|
# Not in list
|
2017-03-20 14:11:54 +01:00
|
|
|
#
|
|
|
|
# - Second list
|
2020-09-25 17:22:58 +01:00
|
|
|
# Note: still in list
|
2017-03-20 14:11:54 +01:00
|
|
|
#
|
|
|
|
# Note: not in list
|
2020-09-25 17:22:58 +01:00
|
|
|
#
|
2017-03-20 14:11:54 +01:00
|
|
|
# 1. Third list
|
|
|
|
# is numbered
|
|
|
|
#
|
2020-09-25 17:22:58 +01:00
|
|
|
# 2. another item
|
2017-03-20 14:11:54 +01: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}
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# @Enum:
|
2021-09-30 16:57:07 -04:00
|
|
|
#
|
2023-04-28 12:54:22 +02:00
|
|
|
# @one: The _one_ {and only}, description on the same line
|
2017-03-20 14:11:54 +01:00
|
|
|
#
|
2020-03-17 12:54:37 +01:00
|
|
|
# Features:
|
|
|
|
# @enum-feat: Also _one_ {and only}
|
2021-10-25 06:24:02 +02:00
|
|
|
# @enum-member-feat: a member feature
|
2020-03-17 12:54:37 +01:00
|
|
|
#
|
2017-03-20 14:11:54 +01:00
|
|
|
# @two is undocumented
|
|
|
|
##
|
2021-09-17 16:31:12 +02:00
|
|
|
{ 'enum': 'Enum',
|
2021-10-25 06:24:02 +02:00
|
|
|
'data': [ { 'name': 'one', 'if': 'IFONE',
|
|
|
|
'features': [ 'enum-member-feat' ] },
|
|
|
|
'two' ],
|
2020-03-17 12:54:37 +01:00
|
|
|
'features': [ 'enum-feat' ],
|
2021-08-04 12:31:05 +04:00
|
|
|
'if': 'IFCOND' }
|
2017-03-20 14:11:54 +01:00
|
|
|
|
|
|
|
##
|
|
|
|
# @Base:
|
2021-09-30 16:57:07 -04:00
|
|
|
#
|
2017-03-20 14:11:54 +01:00
|
|
|
# @base1:
|
2024-02-05 08:46:58 +01:00
|
|
|
# description starts on a new line,
|
|
|
|
# minimally indented
|
2017-03-20 14:11:54 +01:00
|
|
|
##
|
2021-08-04 12:31:01 +04:00
|
|
|
{ 'struct': 'Base', 'data': { 'base1': 'Enum' },
|
|
|
|
'if': { 'all': ['IFALL1', 'IFALL2'] } }
|
2017-03-20 14:11:54 +01:00
|
|
|
|
|
|
|
##
|
|
|
|
# @Variant1:
|
2021-09-30 16:57:07 -04:00
|
|
|
#
|
2017-03-20 14:11:54 +01:00
|
|
|
# A paragraph
|
|
|
|
#
|
2023-04-28 12:54:21 +02:00
|
|
|
# Another paragraph
|
|
|
|
#
|
|
|
|
# @var1 is undocumented
|
2019-10-18 10:14:53 +02:00
|
|
|
#
|
|
|
|
# Features:
|
|
|
|
# @variant1-feat: a feature
|
2020-03-17 12:54:45 +01:00
|
|
|
# @member-feat: a member feature
|
2017-03-20 14:11:54 +01:00
|
|
|
##
|
2018-12-13 16:37:21 +04:00
|
|
|
{ 'struct': 'Variant1',
|
2019-10-18 10:14:53 +02:00
|
|
|
'features': [ 'variant1-feat' ],
|
2020-03-17 12:54:45 +01:00
|
|
|
'data': { 'var1': { 'type': 'str',
|
|
|
|
'features': [ 'member-feat' ],
|
2021-08-04 12:31:05 +04:00
|
|
|
'if': 'IFSTR' } } }
|
2017-03-20 14:11:54 +01:00
|
|
|
|
|
|
|
##
|
|
|
|
# @Variant2:
|
2021-09-30 16:57:07 -04:00
|
|
|
#
|
2017-03-20 14:11:54 +01:00
|
|
|
##
|
|
|
|
{ 'struct': 'Variant2', 'data': {} }
|
|
|
|
|
|
|
|
##
|
|
|
|
# @Object:
|
2021-09-30 16:57:07 -04:00
|
|
|
#
|
2020-03-17 12:54:37 +01:00
|
|
|
# Features:
|
|
|
|
# @union-feat1: a feature
|
2017-03-20 14:11:54 +01:00
|
|
|
##
|
|
|
|
{ 'union': 'Object',
|
2020-03-17 12:54:37 +01:00
|
|
|
'features': [ 'union-feat1' ],
|
2017-03-20 14:11:54 +01:00
|
|
|
'base': 'Base',
|
|
|
|
'discriminator': 'base1',
|
2021-08-04 12:31:02 +04:00
|
|
|
'data': { 'one': 'Variant1',
|
|
|
|
'two': { 'type': 'Variant2',
|
|
|
|
'if': { 'any': ['IFONE', 'IFTWO'] } } } }
|
2017-03-20 14:11:54 +01:00
|
|
|
|
2019-10-24 13:02:21 +02:00
|
|
|
##
|
|
|
|
# @Alternate:
|
2021-09-30 16:57:07 -04:00
|
|
|
#
|
2023-04-28 12:54:22 +02:00
|
|
|
# @i: description starts on the same line
|
|
|
|
# remainder indented the same
|
2020-09-25 17:22:58 +01:00
|
|
|
# @b is undocumented
|
2020-03-17 12:54:37 +01:00
|
|
|
#
|
|
|
|
# Features:
|
|
|
|
# @alt-feat: a feature
|
2019-10-24 13:02:21 +02:00
|
|
|
##
|
|
|
|
{ 'alternate': 'Alternate',
|
2020-03-17 12:54:37 +01:00
|
|
|
'features': [ 'alt-feat' ],
|
2021-08-04 12:31:04 +04:00
|
|
|
'data': { 'i': 'int', 'b': 'bool' },
|
2021-08-31 14:38:01 +02:00
|
|
|
'if': { 'not': { 'any': [ 'IFONE', 'IFTWO' ] } } }
|
2019-10-24 13:02:21 +02:00
|
|
|
|
2017-03-20 14:11:54 +01:00
|
|
|
##
|
|
|
|
# == Another subsection
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# @cmd:
|
2021-09-30 16:57:07 -04:00
|
|
|
#
|
2023-04-28 12:54:22 +02:00
|
|
|
# @arg1:
|
|
|
|
# description starts on a new line,
|
|
|
|
# indented
|
2017-03-20 14:11:54 +01: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 12:54:25 +02:00
|
|
|
# @arg2: description starts on the same line
|
|
|
|
# remainder indented differently
|
2019-10-18 10:14:53 +02:00
|
|
|
#
|
|
|
|
# Features:
|
|
|
|
# @cmd-feat1: a feature
|
|
|
|
# @cmd-feat2: another feature
|
2024-02-16 15:58:35 +01:00
|
|
|
#
|
2017-03-20 14:11:54 +01:00
|
|
|
# Note: @arg3 is undocumented
|
2024-02-16 15:58:35 +01:00
|
|
|
#
|
2017-03-20 14:11:54 +01:00
|
|
|
# Returns: @Object
|
2024-02-16 15:58:35 +01:00
|
|
|
#
|
2024-02-27 12:39:11 +01:00
|
|
|
# Errors: some
|
|
|
|
#
|
2017-03-20 14:11:54 +01:00
|
|
|
# TODO: frobnicate
|
2024-02-16 15:58:35 +01:00
|
|
|
#
|
2017-03-20 14:11:54 +01:00
|
|
|
# Notes:
|
2020-09-25 17:22:58 +01:00
|
|
|
#
|
2024-02-05 08:46:58 +01:00
|
|
|
# - Lorem ipsum dolor sit amet
|
|
|
|
# - Ut enim ad minim veniam
|
2017-03-20 14:11:54 +01:00
|
|
|
#
|
2024-02-05 08:46:58 +01:00
|
|
|
# Duis aute irure dolor
|
2024-02-16 15:58:35 +01:00
|
|
|
#
|
2017-03-20 14:11:54 +01:00
|
|
|
# Example:
|
|
|
|
#
|
2024-02-16 15:58:34 +01:00
|
|
|
# -> in
|
|
|
|
# <- out
|
2024-02-16 15:58:35 +01:00
|
|
|
#
|
2017-03-20 14:11:54 +01:00
|
|
|
# Examples:
|
2024-02-16 15:58:34 +01:00
|
|
|
# - *verbatim*
|
|
|
|
# - {braces}
|
2024-02-16 15:58:35 +01:00
|
|
|
#
|
2017-03-20 14:11:54 +01:00
|
|
|
# Since: 2.10
|
|
|
|
##
|
|
|
|
{ 'command': 'cmd',
|
|
|
|
'data': { 'arg1': 'int', '*arg2': 'str', 'arg3': 'bool' },
|
2019-10-18 10:14:53 +02:00
|
|
|
'returns': 'Object',
|
|
|
|
'features': [ 'cmd-feat1', 'cmd-feat2' ] }
|
2017-03-20 14:11:54 +01:00
|
|
|
|
|
|
|
##
|
|
|
|
# @cmd-boxed:
|
|
|
|
# If you're bored enough to read this, go see a video of boxed cats
|
2024-02-16 15:58:35 +01:00
|
|
|
#
|
2019-10-18 10:14:53 +02:00
|
|
|
# Features:
|
|
|
|
# @cmd-feat1: a feature
|
|
|
|
# @cmd-feat2: another feature
|
2024-02-16 15:58:35 +01:00
|
|
|
#
|
2017-03-20 14:11:54 +01:00
|
|
|
# Example:
|
|
|
|
#
|
2024-02-16 15:58:34 +01:00
|
|
|
# -> in
|
2017-03-20 14:11:54 +01:00
|
|
|
#
|
2024-02-16 15:58:34 +01:00
|
|
|
# <- out
|
2017-03-20 14:11:54 +01:00
|
|
|
##
|
|
|
|
{ 'command': 'cmd-boxed', 'boxed': true,
|
2019-10-18 10:14:53 +02:00
|
|
|
'data': 'Object',
|
|
|
|
'features': [ 'cmd-feat1', 'cmd-feat2' ] }
|
2019-10-24 13:02:20 +02:00
|
|
|
|
|
|
|
##
|
2021-03-23 10:40:10 +01:00
|
|
|
# @EVT_BOXED:
|
2021-09-30 16:57:07 -04:00
|
|
|
#
|
2020-03-17 12:54:37 +01:00
|
|
|
# Features:
|
|
|
|
# @feat3: a feature
|
2019-10-24 13:02:20 +02:00
|
|
|
##
|
2021-03-23 10:40:10 +01:00
|
|
|
{ 'event': 'EVT_BOXED', 'boxed': true,
|
2020-03-17 12:54:37 +01:00
|
|
|
'features': [ 'feat3' ],
|
2019-10-24 13:02:20 +02:00
|
|
|
'data': 'Object' }
|