qapi doc generation (whole version, squashed)
v5 cover qapi doc generation (whole version, squashed)
Add a qapi2texi script to generate the documentation from the qapi schemas.
The 15th patch in this series is a squashed version of the documentation move from qmp-commands.txt to the schemas. The whole version (not sent on the ML to avoid spamming) is in the following git
branch: https://github.com/elmarco/qemu/commits/qapi-doc
PDF preview:
https://fedorapeople.org/~elmarco/qemu-qmp-ref.pdf
v5:
- many parser and generator fixes and improvements after v4 review:
- simplified current section handling by using a Section object
- adding a line is more stateful: either freeform or symbol comment
- always check_docs() when parsing with QAPISchema
- simplified some code and comments
- do not break current section on empty line, but break after a non indented paragraph in an argument section. This seems to reflects the way documentation is written:
##
# @foo:
# @arg: fluctuat nec mergitur
# - continues here
#
# Since: 1853
#
# Body
#
##
Other sections (Note/Examples etc) are not indented (it seems), but could use a similar rule. I prefer to keep this only for args, for styling reasons (bikeshedding?).
- better handling of flat-union in generator
- list all enum values (even when not documented)
- added qapi-doc parsing tests and more error checking
- pep8/pylint fixes
- some more schema doc fixes
- do not move logo to docs/
v4:
- more device_add schema fixes
- do not merge docs/qmp-intro.txt in qemu-qmp-ref.texi
- remove needless @ifinfo, add GPL copying text
- added qemu logo to pdf
- added some r-b tags
v3:
- many improvements to the doc parser:
- throws an error in various malformated conditions
- allows multiple meta-sections, except for "Since:" and "Return:"
- build a list of docs, instead of attaching docs to expressions
- accept() breaks on new doc block, and get_doc() returns a QAPIDoc
- fix more documentation to fit the new parser
- use a master texi file that includes the generated file, instead of templated texi file
- texi fixes after Markus review
- only build and install html and man pages by default
- fix .gitignore
v2:
- change licence to be lgpl2+
- fix some comments & commit message
- add more code comments
- improve the doc parsing to treat only "Since" as a special case not requiring ":" (common notation in the doc)
- include some early schema doc fixes (to fix generated doc)
- include the squashed version of the doc move
- include the man page and installation build changes
Marc-André Lureau (17):
qapi: improve device_add schema
qga/schema: fix double-return in doc qga/schema: improve guest-set-vcpus Returns: section
qapi: fix schema symbol sections
qapi: fix missing symbol @prefix
qapi: fix various symbols mismatch in documentation
qapi: use one symbol per line
qapi: add missing colon-ending for section name
qapi: add some sections in docs
qapi: improve TransactionAction doc
docs: add master qapi texi files
qapi: rename QAPIExprError/QAPILineError
qapi: add qapi2texi script
texi2pod: learn quotation, deftp and deftypefn (SQUASHED) move doc to schema
docs: add qemu logo
build-sys: add qapi doc generation targets
Makefile | 57 +- tests/Makefile.include | 17 + scripts/qapi.py | 361 ++- scripts/qapi2texi.py | 331 +++ scripts/texi2pod.pl | 53 +- .gitignore | 11 +- docs/qapi-code-gen.txt | 54 +- docs/qemu-ga-ref.texi | 82 + docs/qemu-qmp-ref.texi | 82 + docs/qemu_logo.pdf | Bin 0 -> 9117 bytes docs/qmp-commands.txt | 3824 -------------------------- docs/qmp-events.txt | 731 ----- docs/qmp-intro.txt | 3 +- qapi-schema.json | 1662 +++++++++-- qapi/block-core.json | 894 +++++- qapi/block.json | 82 +- qapi/common.json | 52 +- qapi/crypto.json | 41 +- qapi/event.json | 304 +- qapi/introspect.json | 28 +- qapi/rocker.json | 63 +- qapi/trace.json | 25 +- qga/qapi-schema.json | 64 +- tests/qapi-schema/doc-bad-args.err | 1 + tests/qapi-schema/doc-bad-args.exit | 1 + tests/qapi-schema/doc-bad-args.json | 6 + tests/qapi-schema/doc-bad-args.out | 0 tests/qapi-schema/doc-bad-symbol.err | 1 + tests/qapi-schema/doc-bad-symbol.exit | 1 + tests/qapi-schema/doc-bad-symbol.json | 4 + tests/qapi-schema/doc-bad-symbol.out | 0 tests/qapi-schema/doc-duplicated-arg.err | 1 + tests/qapi-schema/doc-duplicated-arg.exit | 1 + tests/qapi-schema/doc-duplicated-arg.json | 5 + tests/qapi-schema/doc-duplicated-arg.out | 0 tests/qapi-schema/doc-duplicated-return.err | 1 + tests/qapi-schema/doc-duplicated-return.exit | 1 + tests/qapi-schema/doc-duplicated-return.json | 6 + tests/qapi-schema/doc-duplicated-return.out | 0 tests/qapi-schema/doc-duplicated-since.err | 1 + tests/qapi-schema/doc-duplicated-since.exit | 1 + tests/qapi-schema/doc-duplicated-since.json | 6 + tests/qapi-schema/doc-duplicated-since.out | 0 tests/qapi-schema/doc-empty-arg.err | 1 + tests/qapi-schema/doc-empty-arg.exit | 1 + tests/qapi-schema/doc-empty-arg.json | 4 + tests/qapi-schema/doc-empty-arg.out | 0 tests/qapi-schema/doc-empty-section.err | 1 + tests/qapi-schema/doc-empty-section.exit | 1 + tests/qapi-schema/doc-empty-section.json | 6 + tests/qapi-schema/doc-empty-section.out | 0 tests/qapi-schema/doc-empty-symbol.err | 1 + tests/qapi-schema/doc-empty-symbol.exit | 1 + tests/qapi-schema/doc-empty-symbol.json | 3 + tests/qapi-schema/doc-empty-symbol.out | 0 tests/qapi-schema/doc-invalid-end.err | 1 + tests/qapi-schema/doc-invalid-end.exit | 1 + tests/qapi-schema/doc-invalid-end.json | 3 + tests/qapi-schema/doc-invalid-end.out | 0 tests/qapi-schema/doc-invalid-end2.err | 1 + tests/qapi-schema/doc-invalid-end2.exit | 1 + tests/qapi-schema/doc-invalid-end2.json | 3 + tests/qapi-schema/doc-invalid-end2.out | 0 tests/qapi-schema/doc-invalid-return.err | 1 + tests/qapi-schema/doc-invalid-return.exit | 1 + tests/qapi-schema/doc-invalid-return.json | 5 + tests/qapi-schema/doc-invalid-return.out | 0 tests/qapi-schema/doc-invalid-section.err | 1 + tests/qapi-schema/doc-invalid-section.exit | 1 + tests/qapi-schema/doc-invalid-section.json | 4 + tests/qapi-schema/doc-invalid-section.out | 0 tests/qapi-schema/doc-invalid-start.err | 1 + tests/qapi-schema/doc-invalid-start.exit | 1 + tests/qapi-schema/doc-invalid-start.json | 3 + tests/qapi-schema/doc-invalid-start.out | 0 tests/qapi-schema/doc-missing-expr.err | 1 + tests/qapi-schema/doc-missing-expr.exit | 1 + tests/qapi-schema/doc-missing-expr.json | 3 + tests/qapi-schema/doc-missing-expr.out | 0 tests/qapi-schema/doc-missing-space.err | 1 + tests/qapi-schema/doc-missing-space.exit | 1 + tests/qapi-schema/doc-missing-space.json | 4 + tests/qapi-schema/doc-missing-space.out | 0 tests/qapi-schema/qapi-schema-test.json | 58 + tests/qapi-schema/qapi-schema-test.out | 49 + tests/qapi-schema/test-qapi.py | 12 + 86 files changed, 3922 insertions(+), 5113 deletions(-) create mode 100755 scripts/qapi2texi.py create mode 100644 docs/qemu-ga-ref.texi create mode 100644 docs/qemu-qmp-ref.texi create mode 100644 docs/qemu_logo.pdf delete mode 100644 docs/qmp-commands.txt delete mode 100644 docs/qmp-events.txt create mode 100644 tests/qapi-schema/doc-bad-args.err create mode 100644 tests/qapi-schema/doc-bad-args.exit create mode 100644 tests/qapi-schema/doc-bad-args.json create mode 100644 tests/qapi-schema/doc-bad-args.out create mode 100644 tests/qapi-schema/doc-bad-symbol.err create mode 100644 tests/qapi-schema/doc-bad-symbol.exit create mode 100644 tests/qapi-schema/doc-bad-symbol.json create mode 100644 tests/qapi-schema/doc-bad-symbol.out create mode 100644 tests/qapi-schema/doc-duplicated-arg.err create mode 100644 tests/qapi-schema/doc-duplicated-arg.exit create mode 100644 tests/qapi-schema/doc-duplicated-arg.json create mode 100644 tests/qapi-schema/doc-duplicated-arg.out create mode 100644 tests/qapi-schema/doc-duplicated-return.err create mode 100644 tests/qapi-schema/doc-duplicated-return.exit create mode 100644 tests/qapi-schema/doc-duplicated-return.json create mode 100644 tests/qapi-schema/doc-duplicated-return.out create mode 100644 tests/qapi-schema/doc-duplicated-since.err create mode 100644 tests/qapi-schema/doc-duplicated-since.exit create mode 100644 tests/qapi-schema/doc-duplicated-since.json create mode 100644 tests/qapi-schema/doc-duplicated-since.out create mode 100644 tests/qapi-schema/doc-empty-arg.err create mode 100644 tests/qapi-schema/doc-empty-arg.exit create mode 100644 tests/qapi-schema/doc-empty-arg.json create mode 100644 tests/qapi-schema/doc-empty-arg.out create mode 100644 tests/qapi-schema/doc-empty-section.err create mode 100644 tests/qapi-schema/doc-empty-section.exit create mode 100644 tests/qapi-schema/doc-empty-section.json create mode 100644 tests/qapi-schema/doc-empty-section.out create mode 100644 tests/qapi-schema/doc-empty-symbol.err create mode 100644 tests/qapi-schema/doc-empty-symbol.exit create mode 100644 tests/qapi-schema/doc-empty-symbol.json create mode 100644 tests/qapi-schema/doc-empty-symbol.out create mode 100644 tests/qapi-schema/doc-invalid-end.err create mode 100644 tests/qapi-schema/doc-invalid-end.exit create mode 100644 tests/qapi-schema/doc-invalid-end.json create mode 100644 tests/qapi-schema/doc-invalid-end.out create mode 100644 tests/qapi-schema/doc-invalid-end2.err create mode 100644 tests/qapi-schema/doc-invalid-end2.exit create mode 100644 tests/qapi-schema/doc-invalid-end2.json create mode 100644 tests/qapi-schema/doc-invalid-end2.out create mode 100644 tests/qapi-schema/doc-invalid-return.err create mode 100644 tests/qapi-schema/doc-invalid-return.exit create mode 100644 tests/qapi-schema/doc-invalid-return.json create mode 100644 tests/qapi-schema/doc-invalid-return.out create mode 100644 tests/qapi-schema/doc-invalid-section.err create mode 100644 tests/qapi-schema/doc-invalid-section.exit create mode 100644 tests/qapi-schema/doc-invalid-section.json create mode 100644 tests/qapi-schema/doc-invalid-section.out create mode 100644 tests/qapi-schema/doc-invalid-start.err create mode 100644 tests/qapi-schema/doc-invalid-start.exit create mode 100644 tests/qapi-schema/doc-invalid-start.json create mode 100644 tests/qapi-schema/doc-invalid-start.out create mode 100644 tests/qapi-schema/doc-missing-expr.err create mode 100644 tests/qapi-schema/doc-missing-expr.exit create mode 100644 tests/qapi-schema/doc-missing-expr.json create mode 100644 tests/qapi-schema/doc-missing-expr.out create mode 100644 tests/qapi-schema/doc-missing-space.err create mode 100644 tests/qapi-schema/doc-missing-space.exit create mode 100644 tests/qapi-schema/doc-missing-space.json create mode 100644 tests/qapi-schema/doc-missing-space.out
Signature · 1 line
2.10.0
PATCH v5 1/17 qapi: improve device_add schema
'device_add' is still incomplete for now, but we can fix a few arguments:
- 'bus' is a common argument, regardless of the device
- 'id' is an optionnal argument
--- qapi-schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
qapi-schema.json +2 -2
@@ -2287,7 +2287,7 @@ # # @bus: #optional the device's parent bus (device tree path) # -# @id: the device's ID, must be unique +# @id: #optional the device's ID, must be unique # # Additional arguments depend on the type. #
@@ -2317,7 +2317,7 @@ # Since: 0.13 ## { 'command': 'device_add', - 'data': {'driver': 'str', 'id': 'str'}, + 'data': {'driver': 'str', '*bus': 'str', '*id': 'str'}, 'gen': false } # so we can get the additional arguments ##
Signature · 1 line
2.10.0
Re: [Qemu-devel] [PATCH v5 01/17] qapi: improve device_add schema
Quoted 6 lines · Marc-André Lureau
'
device_add' is still incomplete for now, but we can fix a few arguments:
- 'bus' is a common argument, regardless of the device
- 'id' is an optionnal argumentSigned-off-by Marc-André Lureau <[email protected]>
Re: [Qemu-devel] [PATCH v5 01/17] qapi: improve device_add schema
In reply to Marc-André LureauQuoted 4 lines · Marc-André Lureau
'
device_add' is still incomplete for now, but we can fix a few arguments:
- 'bus' is a common argument, regardless of the device
- 'id' is an optionnal argument
s/optionnal/optional/
Quoted 6 lines
Signed-off-by Marc-André Lureau <[email protected]>--- qapi-schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v5 2/17 qga/schema: fix double-return in doc
In reply to Marc-André Lureauguest-get-memory-block-info documentation should have only one "Returns:".
--- qga/qapi-schema.json | 1 - 1 file changed, 1 deletion(-)
qga/qapi-schema.json +0 -1
@@ -952,7 +952,6 @@ # # Get information relating to guest memory blocks. # -# Returns: memory block size in bytes. # Returns: @GuestMemoryBlockInfo # # Since 2.3
Signature · 1 line
2.10.0
Re: [Qemu-devel] [PATCH v5 02/17] qga/schema: fix double-return in doc
Quoted 5 lines · Marc-André Lureau
guest-get-memory-block-info documentation should have only one "Returns:".
Signed-off-by Marc-André Lureau <[email protected]>Reviewed-by Eric Blake <[email protected]>
PATCH v5 3/17 qga/schema: improve guest-set-vcpus Returns: section
In reply to Marc-André LureauThe documentation parser we are going to add finishes a section after an empty line.
Fix the Returns: section of guest-set-vcpus, and itemize the possible return values.
--- qga/qapi-schema.json | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
qga/qapi-schema.json +4 -8
@@ -696,22 +696,18 @@ # # Returns: The length of the initial sublist that has been successfully # processed. The guest agent maximizes this value. Possible cases: -# -# 0: if the @vcpus list was empty on input. Guest state +# - 0: if the @vcpus list was empty on input. Guest state # has not been changed. Otherwise, -# -# Error: processing the first node of @vcpus failed for the +# - Error: processing the first node of @vcpus failed for the # reason returned. Guest state has not been changed. # Otherwise, -# -# < length(@vcpus): more than zero initial nodes have been processed, +# - < length(@vcpus): more than zero initial nodes have been processed, # but not the entire @vcpus list. Guest state has # changed accordingly. To retrieve the error # (assuming it persists), repeat the call with the # successfully processed initial sublist removed. # Otherwise, -# -# length(@vcpus): call successful. +# - length(@vcpus): call successful. # # Since: 1.5 ##
Signature · 1 line
2.10.0
Re: [Qemu-devel] [PATCH v5 03/17] qga/schema: improve guest-set-vcpus Returns: section
Quoted 2 lines · Marc-André Lureau
The documentation parser we are going to add finishes a section after an empty line.
Is this still true?
Quoted 4 lines
Fix the Returns: section of guest-set-vcpus, and itemize the possible return values.
Signed-off-by Marc-André Lureau <[email protected]>
Patch looks good.
Re: [Qemu-devel] [PATCH v5 03/17] qga/schema: improve guest-set-vcpus Returns: section
Hi
----- Original Message -----
Quoted 6 lines
Quoted 2 lines · Marc-André Lureau
The documentation parser we are going to add finishes a section after an empty line.
Is this still true?
No longer true, the parser only breaks on argument empty line, as explained in cover letter.
I'll bring back the empty lines.
Quoted 8 lines
Quoted 5 lines
Fix the Returns: section of guest-set-vcpus, and itemize the possible return values.
Signed-off-by Marc-André Lureau <[email protected]>Patch looks good.
Re: [Qemu-devel] [PATCH v5 03/17] qga/schema: improve guest-set-vcpus Returns: section
Quoted 5 lines · Marc-André Lureau
Hi
----- Original Message -----
Quoted 2 lines
Marc-André Lureau <[email protected]> writes:
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
The documentation parser we are going to add finishes a section after an empty line.
Is this still true?
No longer true, the parser only breaks on argument empty line, as explained in cover letter.
I'll bring back the empty lines.
Feel free to keep them out, and justify your change with a consistency argument.
[...]
PATCH v5 4/17 qapi: fix schema symbol sections
In reply to Marc-André LureauAccording to docs/qapi-code-gen.txt, there needs to be '##' to start a and end a symbol section, that's also what the documentation parser expects.
--- qapi-schema.json | 18 +++++++++++++----- qapi/block-core.json | 1 + qga/qapi-schema.json | 3 +++ 3 files changed, 17 insertions(+), 5 deletions(-)
qapi-schema.json +13 -5
@@ -65,6 +65,7 @@ { 'enum': 'LostTickPolicy', 'data': ['discard', 'delay', 'merge', 'slew' ] } +## # @add_client # # Allow client connections for VNC, Spice and socket based
@@ -442,6 +443,7 @@ 'cache-miss': 'int', 'cache-miss-rate': 'number', 'overflow': 'int' } } +## # @MigrationStatus: # # An enumeration of migration status.
@@ -627,6 +629,7 @@ ## { 'command': 'query-migrate-capabilities', 'returns': ['MigrationCapabilityStatus']} +## # @MigrationParameter # # Migration parameters enumeration
@@ -685,7 +688,7 @@ 'tls-creds', 'tls-hostname', 'max-bandwidth', 'downtime-limit', 'x-checkpoint-delay' ] } -# +## # @migrate-set-parameters # # Set various migration parameters. See MigrationParameters for details.
@@ -697,7 +700,7 @@ { 'command': 'migrate-set-parameters', 'boxed': true, 'data': 'MigrationParameters' } -# +## # @MigrationParameters # # Optional members can be omitted on input ('migrate-set-parameters')
@@ -795,6 +798,7 @@ # command. # # Since: 2.5 +## { 'command': 'migrate-start-postcopy' } ##
@@ -2252,6 +2256,7 @@ ## { 'command': 'migrate-incoming', 'data': {'uri': 'str' } } +## # @xen-save-devices-state: # # Save the state of all devices to file. The RAM and the block devices
@@ -3482,6 +3487,7 @@ 'modelb': 'CpuModelInfo' }, 'returns': 'CpuModelBaselineInfo' } +## # @AddfdInfo: # # Information about a file descriptor that was added to an fd set.
@@ -4530,14 +4536,16 @@ ## { 'command': 'query-memory-devices', 'returns': ['MemoryDeviceInfo'] } -## @ACPISlotType +## +# @ACPISlotType # # @DIMM: memory slot # @CPU: logical CPU slot (since 2.7) -# +## { 'enum': 'ACPISlotType', 'data': [ 'DIMM', 'CPU' ] } -## @ACPIOSTInfo +## +# @ACPIOSTInfo # # OSPM Status Indication for a device # For description of possible values of @source and @status fields
qapi/block-core.json +1 -0
@@ -2809,6 +2809,7 @@ 'offset': 'int', 'speed' : 'int' } } +## # @PreallocMode # # Preallocation mode of QEMU image file
qga/qapi-schema.json +3 -0
@@ -833,6 +833,7 @@ { 'command': 'guest-set-user-password', 'data': { 'username': 'str', 'password': 'str', 'crypted': 'bool' } } +## # @GuestMemoryBlock: # # @phys-index: Arbitrary guest-specific unique identifier of the MEMORY BLOCK.
@@ -932,6 +933,7 @@ 'data': {'mem-blks': ['GuestMemoryBlock'] }, 'returns': ['GuestMemoryBlockResponse'] } +## # @GuestMemoryBlockInfo: # # @size: the size (in bytes) of the guest memory blocks,
@@ -955,6 +957,7 @@ { 'command': 'guest-get-memory-block-info', 'returns': 'GuestMemoryBlockInfo' } +## # @GuestExecStatus: # # @exited: true if process has already terminated.
Signature · 1 line
2.10.0
Re: [Qemu-devel] [PATCH v5 04/17] qapi: fix schema symbol sections
Quoted 6 lines · Marc-André Lureau
According to
docs/qapi-code-gen.txt, there needs to be '##' to start a and end a symbol section, that's also what the documentation parser expects.Signed-off-by Marc-André Lureau <[email protected]>Reviewed-by Eric Blake <[email protected]>
PATCH v5 5/17 qapi: fix missing symbol @prefix
In reply to Marc-André Lureau--- qapi-schema.json | 4 ++-- qapi/block-core.json | 4 ++-- qapi/crypto.json | 36 ++++++++++++++++++------------------ 3 files changed, 22 insertions(+), 22 deletions(-)
qapi-schema.json +2 -2
@@ -4650,7 +4650,7 @@ { 'include': 'qapi/rocker.json' } ## -# ReplayMode: +# @ReplayMode: # # Mode of the replay subsystem. #
@@ -4718,7 +4718,7 @@ { 'command': 'query-gic-capabilities', 'returns': ['GICCapability'] } ## -# CpuInstanceProperties +# @CpuInstanceProperties # # List of properties to be used for hotplugging a CPU instance, # it should be passed by management with device_add command when
qapi/block-core.json +2 -2
@@ -1144,7 +1144,7 @@ 'data': 'DriveMirror' } ## -# DriveMirror +# @DriveMirror # # A set of parameters describing drive mirror setup. #
@@ -1368,7 +1368,7 @@ 'data': 'BlockIOThrottle' } ## -# BlockIOThrottle +# @BlockIOThrottle # # A set of parameters describing block throttling. #
qapi/crypto.json +18 -18
@@ -3,7 +3,7 @@ # QAPI crypto definitions ## -# QCryptoTLSCredsEndpoint: +# @QCryptoTLSCredsEndpoint: # # The type of network endpoint that will be using the credentials. # Most types of credential require different setup / structures
@@ -22,7 +22,7 @@ ## -# QCryptoSecretFormat: +# @QCryptoSecretFormat: # # The data format that the secret is provided in #
@@ -36,7 +36,7 @@ ## -# QCryptoHashAlgorithm: +# @QCryptoHashAlgorithm: # # The supported algorithms for computing content digests #
@@ -55,7 +55,7 @@ ## -# QCryptoCipherAlgorithm: +# @QCryptoCipherAlgorithm: # # The supported algorithms for content encryption ciphers #
@@ -82,7 +82,7 @@ ## -# QCryptoCipherMode: +# @QCryptoCipherMode: # # The supported modes for content encryption ciphers #
@@ -98,7 +98,7 @@ ## -# QCryptoIVGenAlgorithm: +# @QCryptoIVGenAlgorithm: # # The supported algorithms for generating initialization # vectors for full disk encryption. The 'plain' generator
@@ -116,7 +116,7 @@ 'data': ['plain', 'plain64', 'essiv']} ## -# QCryptoBlockFormat: +# @QCryptoBlockFormat: # # The supported full disk encryption formats #
@@ -131,7 +131,7 @@ 'data': ['qcow', 'luks']} ## -# QCryptoBlockOptionsBase: +# @QCryptoBlockOptionsBase: # # The common options that apply to all full disk # encryption formats
@@ -144,7 +144,7 @@ 'data': { 'format': 'QCryptoBlockFormat' }} ## -# QCryptoBlockOptionsQCow: +# @QCryptoBlockOptionsQCow: # # The options that apply to QCow/QCow2 AES-CBC encryption format #
@@ -158,7 +158,7 @@ 'data': { '*key-secret': 'str' }} ## -# QCryptoBlockOptionsLUKS: +# @QCryptoBlockOptionsLUKS: # # The options that apply to LUKS encryption format #
@@ -172,7 +172,7 @@ ## -# QCryptoBlockCreateOptionsLUKS: +# @QCryptoBlockCreateOptionsLUKS: # # The options that apply to LUKS encryption format initialization #
@@ -202,7 +202,7 @@ ## -# QCryptoBlockOpenOptions: +# @QCryptoBlockOpenOptions: # # The options that are available for all encryption formats # when opening an existing volume
@@ -217,7 +217,7 @@ ## -# QCryptoBlockCreateOptions: +# @QCryptoBlockCreateOptions: # # The options that are available for all encryption formats # when initializing a new volume
@@ -232,7 +232,7 @@ ## -# QCryptoBlockInfoBase: +# @QCryptoBlockInfoBase: # # The common information that applies to all full disk # encryption formats
@@ -246,7 +246,7 @@ ## -# QCryptoBlockInfoLUKSSlot: +# @QCryptoBlockInfoLUKSSlot: # # Information about the LUKS block encryption key # slot options
@@ -266,7 +266,7 @@ ## -# QCryptoBlockInfoLUKS: +# @QCryptoBlockInfoLUKS: # # Information about the LUKS block encryption options #
@@ -294,7 +294,7 @@ 'slots': [ 'QCryptoBlockInfoLUKSSlot' ] }} ## -# QCryptoBlockInfoQCow: +# @QCryptoBlockInfoQCow: # # Information about the QCow block encryption options #
@@ -305,7 +305,7 @@ ## -# QCryptoBlockInfo: +# @QCryptoBlockInfo: # # Information about the block encryption options #
Signature · 1 line
2.10.0
Re: [Qemu-devel] [PATCH v5 05/17] qapi: fix missing symbol @prefix
Quoted 2 lines · Marc-André Lureau
Signed-off-by Marc-André Lureau <[email protected]>Reviewed-by Eric Blake <[email protected]>
PATCH v5 6/17 qapi: fix various symbols mismatch in documentation
In reply to Marc-André LureauThere are various mismatch:
- invalid symbols
- section and member symbols mismatch
- enum or union values vs 'type'
The documentation parser catches all these cases.
--- qapi-schema.json | 20 +++++++++----------- qapi/block-core.json | 4 ---- qapi/common.json | 6 +++--- qapi/rocker.json | 2 +- qga/qapi-schema.json | 6 +++--- 5 files changed, 16 insertions(+), 22 deletions(-)
qapi-schema.json +9 -11
@@ -693,8 +693,6 @@ # # Set various migration parameters. See MigrationParameters for details. # -# @x-checkpoint-delay: the delay time between two checkpoints. (Since 2.8) -# # Since: 2.4 ## { 'command': 'migrate-set-parameters', 'boxed': true,
@@ -1171,7 +1169,7 @@ '*service': 'str', '*auth': 'str', '*clients': ['VncClientInfo']} } ## -# @VncPriAuth: +# @VncPrimaryAuth: # # vnc primary authentication method. #
@@ -3174,7 +3172,7 @@ # # @alias: #optional an alias for the machine name # -# @default: #optional whether the machine is default +# @is-default: #optional whether the machine is default # # @cpu-max: maximum number of CPUs supported by the machine type # (since 1.5.0)
@@ -3727,7 +3725,6 @@ # # @device: The name of the special file for the device, # i.e. /dev/ttyS0 on Unix or COM1: on Windows -# @type: What kind of device this is. # # Since: 1.4 ##
@@ -3992,7 +3989,7 @@ # # A union referencing different TPM backend types' configuration options # -# @passthrough: The configuration options for the TPM passthrough type +# @type: 'passthrough' The configuration options for the TPM passthrough type # # Since: 1.5 ##
@@ -4000,7 +3997,7 @@ 'data': { 'passthrough' : 'TPMPassthroughOptions' } } ## -# @TpmInfo: +# @TPMInfo: # # Information about the TPM #
@@ -4344,10 +4341,11 @@ # # Input event union. # -# @key: Input event of Keyboard -# @btn: Input event of pointer buttons -# @rel: Input event of relative pointer motion -# @abs: Input event of absolute pointer motion +# @type: the input type, one of: +# - 'key': Input event of Keyboard +# - 'btn': Input event of pointer buttons +# - 'rel': Input event of relative pointer motion +# - 'abs': Input event of absolute pointer motion # # Since: 2.0 ##
qapi/block-core.json +0 -4
@@ -2160,10 +2160,6 @@ # # @type: Transport type used for gluster connection # -# @unix: socket file -# -# @tcp: host address and port number -# # This is similar to SocketAddress, only distinction: # # 1. GlusterServer is a flat union, SocketAddress is a simple union.
qapi/common.json +3 -3
@@ -34,11 +34,11 @@ # # A three-part version number. # -# @qemu.major: The major version number. +# @major: The major version number. # -# @qemu.minor: The minor version number. +# @minor: The minor version number. # -# @qemu.micro: The micro version number. +# @micro: The micro version number. # # Since: 2.4 ##
qapi/rocker.json +1 -1
@@ -1,5 +1,5 @@ ## -# @Rocker: +# @RockerSwitch: # # Rocker switch information. #
qga/qapi-schema.json +3 -3
@@ -203,7 +203,7 @@ # # Open a file in the guest and retrieve a file handle for it # -# @filepath: Full path to the file in the guest to open. +# @path: Full path to the file in the guest to open. # # @mode: #optional open mode, as per fopen(), "r" is the default. #
@@ -378,7 +378,7 @@ 'data': { 'handle': 'int' } } ## -# @GuestFsFreezeStatus +# @GuestFsfreezeStatus # # An enumeration of filesystem freeze states #
@@ -766,7 +766,7 @@ # @GuestDiskAddress: # # @pci-controller: controller's PCI address -# @type: bus type +# @bus-type: bus type # @bus: bus id # @target: target id # @unit: unit id
Signature · 1 line
2.10.0
Re: [Qemu-devel] [PATCH v5 06/17] qapi: fix various symbols mismatch in documentation
Quoted 8 lines · Marc-André Lureau
There are various mismatch:
- invalid symbols
- section and member symbols mismatch
- enum or union values vs 'type'The documentation parser catches all these cases.
Signed-off-by Marc-André Lureau <[email protected]>
Union documentation needs work, but that's out of scope for this patch.
PATCH v5 7/17 qapi: use one symbol per line
In reply to Marc-André LureauThe documentation parser we are going to add only handles a single symbol per line.
--- qapi-schema.json | 10 +++++++--- qapi/block-core.json | 8 ++++++-- 2 files changed, 13 insertions(+), 5 deletions(-)
qapi-schema.json +7 -3
@@ -3610,15 +3610,19 @@ ## # @QKeyCode: # +# @unmapped: since 2.0 +# @pause: since 2.0 +# @ro: since 2.4 +# @kp_comma: since 2.4 +# @kp_equals: since 2.6 +# @power: since 2.6 +# # An enumeration of key name. # # This is used by the send-key command. # # Since: 1.3.0 # -# 'unmapped' and 'pause' since 2.0 -# 'ro' and 'kp_comma' since 2.4 -# 'kp_equals' and 'power' since 2.6 ## { 'enum': 'QKeyCode', 'data': [ 'unmapped',
qapi/block-core.json +6 -2
@@ -1712,9 +1712,13 @@ # # Drivers that are supported in block device operations. # -# @host_device, @host_cdrom: Since 2.1 +# @host_device: Since 2.1 +# @host_cdrom: Since 2.1 # @gluster: Since 2.7 -# @nbd, @nfs, @replication, @ssh: Since 2.8 +# @nbd: Since 2.8 +# @nfs: Since 2.8 +# @replication: Since 2.8 +# @ssh: Since 2.8 # # Since: 2.0 ##
Signature · 1 line
2.10.0
Re: [Qemu-devel] [PATCH v5 07/17] qapi: use one symbol per line
Quoted 4 lines · Marc-André Lureau
The documentation parser we are going to add only handles a single symbol per line.
Signed-off-by Marc-André Lureau <[email protected]>
PATCH v5 8/17 qapi: add missing colon-ending for section name
In reply to Marc-André LureauThe documentation parser we are going to add expects a section name to end with ':', otherwise the comment is treated as free-form text body.
--- qapi-schema.json | 300 +++++++++++++++++++++++++-------------------------- qapi/block-core.json | 196 ++++++++++++++++----------------- qapi/block.json | 16 +-- qapi/common.json | 8 +- qapi/event.json | 58 +++++----- qapi/introspect.json | 28 ++--- qapi/trace.json | 8 +- qga/qapi-schema.json | 44 ++++---- 8 files changed, 329 insertions(+), 329 deletions(-)
qapi-schema.json +150 -150
@@ -66,7 +66,7 @@ 'data': ['discard', 'delay', 'merge', 'slew' ] } ## -# @add_client +# @add_client: # # Allow client connections for VNC, Spice and socket based # character devices to be passed in to QEMU via SCM_RIGHTS.
@@ -97,7 +97,7 @@ # # @name: #optional The name of the guest # -# Since 0.14.0 +# Since: 0.14.0 ## { 'struct': 'NameInfo', 'data': {'*name': 'str'} }
@@ -108,7 +108,7 @@ # # Returns: @NameInfo of the guest # -# Since 0.14.0 +# Since: 0.14.0 ## { 'command': 'query-name', 'returns': 'NameInfo' }
@@ -137,7 +137,7 @@ { 'command': 'query-kvm', 'returns': 'KvmInfo' } ## -# @RunState +# @RunState: # # An enumeration of VM run states. #
@@ -235,7 +235,7 @@ # # Returns: The @UuidInfo for the guest # -# Since 0.14.0 +# Since: 0.14.0 ## { 'command': 'query-uuid', 'returns': 'UuidInfo' }
@@ -382,7 +382,7 @@ { 'command': 'query-events', 'returns': ['EventInfo'] } ## -# @MigrationStats +# @MigrationStats: # # Detailed migration status. #
@@ -396,7 +396,7 @@ # # @skipped: number of skipped zero pages (since 1.5) # -# @normal : number of normal pages (since 1.2) +# @normal: number of normal pages (since 1.2) # # @normal-bytes: number of normal bytes sent (since 1.2) #
@@ -420,7 +420,7 @@ 'postcopy-requests' : 'int' } } ## -# @XBZRLECacheStats +# @XBZRLECacheStats: # # Detailed XBZRLE migration cache statistics #
@@ -474,7 +474,7 @@ 'active', 'postcopy-active', 'completed', 'failed', 'colo' ] } ## -# @MigrationInfo +# @MigrationInfo: # # Information about current migration process. #
@@ -534,7 +534,7 @@ '*error-desc': 'str'} } ## -# @query-migrate +# @query-migrate: # # Returns information about current migration process. #
@@ -545,7 +545,7 @@ { 'command': 'query-migrate', 'returns': 'MigrationInfo' } ## -# @MigrationCapability +# @MigrationCapability: # # Migration capabilities enumeration #
@@ -593,7 +593,7 @@ 'compress', 'events', 'postcopy-ram', 'x-colo'] } ## -# @MigrationCapabilityStatus +# @MigrationCapabilityStatus: # # Migration capability information #
@@ -607,7 +607,7 @@ 'data': { 'capability' : 'MigrationCapability', 'state' : 'bool' } } ## -# @migrate-set-capabilities +# @migrate-set-capabilities: # # Enable/Disable the following migration capabilities (like xbzrle) #
@@ -619,7 +619,7 @@ 'data': { 'capabilities': ['MigrationCapabilityStatus'] } } ## -# @query-migrate-capabilities +# @query-migrate-capabilities: # # Returns information about the current migration capabilities status #
@@ -630,7 +630,7 @@ { 'command': 'query-migrate-capabilities', 'returns': ['MigrationCapabilityStatus']} ## -# @MigrationParameter +# @MigrationParameter: # # Migration parameters enumeration #
@@ -689,7 +689,7 @@ 'downtime-limit', 'x-checkpoint-delay' ] } ## -# @migrate-set-parameters +# @migrate-set-parameters: # # Set various migration parameters. See MigrationParameters for details. #
@@ -699,7 +699,7 @@ 'data': 'MigrationParameters' } ## -# @MigrationParameters +# @MigrationParameters: # # Optional members can be omitted on input ('migrate-set-parameters') # but most members will always be present on output
@@ -758,7 +758,7 @@ '*x-checkpoint-delay': 'int'} } ## -# @query-migrate-parameters +# @query-migrate-parameters: # # Returns information about the current migration parameters #
@@ -770,7 +770,7 @@ 'returns': 'MigrationParameters' } ## -# @client_migrate_info +# @client_migrate_info: # # Set migration information for remote display. This makes the server # ask the client to automatically reconnect using the new parameters
@@ -789,7 +789,7 @@ '*tls-port': 'int', '*cert-subject': 'str' } } ## -# @migrate-start-postcopy +# @migrate-start-postcopy: # # Followup to a migration command to switch the migration to postcopy mode. # The postcopy-ram capability must be set before the original migration
@@ -800,7 +800,7 @@ { 'command': 'migrate-start-postcopy' } ## -# @COLOMessage +# @COLOMessage: # # The message transmission between Primary side and Secondary side. #
@@ -826,7 +826,7 @@ 'vmstate-loaded' ] } ## -# @COLOMode +# @COLOMode: # # The colo mode #
@@ -842,7 +842,7 @@ 'data': [ 'unknown', 'primary', 'secondary'] } ## -# @FailoverStatus +# @FailoverStatus: # # An enumeration of COLO failover status #
@@ -860,7 +860,7 @@ 'data': [ 'none', 'require', 'active', 'completed'] } ## -# @x-colo-lost-heartbeat +# @x-colo-lost-heartbeat: # # Tell qemu that heartbeat is lost, request it to do takeover procedures. # If this command is sent to the PVM, the Primary side will exit COLO mode.
@@ -954,7 +954,7 @@ # # @pc: the 64-bit instruction pointer # -# Since 2.6 +# Since: 2.6 ## { 'struct': 'CpuInfoX86', 'data': { 'pc': 'int' } }
@@ -967,7 +967,7 @@ # # @npc: the NPC component of the instruction pointer # -# Since 2.6 +# Since: 2.6 ## { 'struct': 'CpuInfoSPARC', 'data': { 'pc': 'int', 'npc': 'int' } }
@@ -978,7 +978,7 @@ # # @nip: the instruction pointer # -# Since 2.6 +# Since: 2.6 ## { 'struct': 'CpuInfoPPC', 'data': { 'nip': 'int' } }
@@ -989,7 +989,7 @@ # # @PC: the instruction pointer # -# Since 2.6 +# Since: 2.6 ## { 'struct': 'CpuInfoMIPS', 'data': { 'PC': 'int' } }
@@ -1000,7 +1000,7 @@ # # @PC: the instruction pointer # -# Since 2.6 +# Since: 2.6 ## { 'struct': 'CpuInfoTricore', 'data': { 'PC': 'int' } }
@@ -1009,7 +1009,7 @@ # # No additional information is available about the virtual CPU # -# Since 2.6 +# Since: 2.6 # ## { 'struct': 'CpuInfoOther', 'data': { } }
@@ -1044,7 +1044,7 @@ # # Returns a list of information about each iothread. # -# Note this list excludes the QEMU main loop thread, which is not declared +# Note: this list excludes the QEMU main loop thread, which is not declared # using the -object iothread command-line option. It is always the main thread # of the process. #
@@ -1055,7 +1055,7 @@ { 'command': 'query-iothreads', 'returns': ['IOThreadInfo'] } ## -# @NetworkAddressFamily +# @NetworkAddressFamily: # # The network address family #
@@ -1075,7 +1075,7 @@ 'data': [ 'ipv4', 'ipv6', 'unix', 'vsock', 'unknown' ] } ## -# @VncBasicInfo +# @VncBasicInfo: # # The basic information for vnc network connection #
@@ -1098,7 +1098,7 @@ 'websocket': 'bool' } } ## -# @VncServerInfo +# @VncServerInfo: # # The network connection information for server #
@@ -1248,7 +1248,7 @@ { 'command': 'query-vnc-servers', 'returns': ['VncInfo2'] } ## -# @SpiceBasicInfo +# @SpiceBasicInfo: # # The basic information for SPICE network connection #
@@ -1266,7 +1266,7 @@ 'family': 'NetworkAddressFamily' } } ## -# @SpiceServerInfo +# @SpiceServerInfo: # # Information about a SPICE server #
@@ -1279,7 +1279,7 @@ 'data': { '*auth': 'str' } } ## -# @SpiceChannel +# @SpiceChannel: # # Information about a SPICE client channel. #
@@ -1304,7 +1304,7 @@ 'tls': 'bool'} } ## -# @SpiceQueryMouseMode +# @SpiceQueryMouseMode: # # An enumeration of Spice mouse states. #
@@ -1323,7 +1323,7 @@ 'data': [ 'client', 'server', 'unknown' ] } ## -# @SpiceInfo +# @SpiceInfo: # # Information about the SPICE session. #
@@ -1362,7 +1362,7 @@ 'mouse-mode': 'SpiceQueryMouseMode', '*channels': ['SpiceChannel']} } ## -# @query-spice +# @query-spice: # # Returns information about the current SPICE server #
@@ -1412,7 +1412,7 @@ { 'struct': 'PciMemoryRange', 'data': {'base': 'int', 'limit': 'int'} } ## -# @PciMemoryRegion +# @PciMemoryRegion: # # Information about a PCI device I/O region. #
@@ -1621,7 +1621,7 @@ { 'command': 'cpu', 'data': {'index': 'int'} } ## -# @cpu-add +# @cpu-add: # # Adds CPU with specified ID #
@@ -1629,7 +1629,7 @@ # # Returns: Nothing on success # -# Since 1.5 +# Since: 1.5 ## { 'command': 'cpu-add', 'data': {'id': 'int'} }
@@ -1760,17 +1760,17 @@ { 'command': 'balloon', 'data': {'value': 'int'} } ## -# @Abort +# @Abort: # # This action can be used to test transaction failure. # # Since: 1.6 -### +## { 'struct': 'Abort', 'data': { } } ## -# @ActionCompletionMode +# @ActionCompletionMode: # # An enumeration of Transactional completion modes. #
@@ -1790,12 +1790,12 @@ 'data': [ 'individual', 'grouped' ] } ## -# @TransactionAction +# @TransactionAction: # # A discriminated record of operations that can be performed with # @transaction. # -# Since 1.1 +# Since: 1.1 # # drive-backup since 1.6 # abort since 1.6
@@ -1818,7 +1818,7 @@ } } ## -# @TransactionProperties +# @TransactionProperties: # # Optional arguments to modify the behavior of a Transaction. #
@@ -1835,7 +1835,7 @@ } ## -# @transaction +# @transaction: # # Executes a number of transactionable QMP commands atomically. If any # operation fails, then the entire set of actions will be abandoned and the
@@ -1855,7 +1855,7 @@ # information on only one failed operation returned in an error condition, and # subsequent actions will not have been attempted. # -# Since 1.1 +# Since: 1.1 ## { 'command': 'transaction', 'data': { 'actions': [ 'TransactionAction' ],
@@ -1892,7 +1892,7 @@ 'returns': 'str' } ## -# @migrate_cancel +# @migrate_cancel: # # Cancel the current executing migration process. #
@@ -1905,7 +1905,7 @@ { 'command': 'migrate_cancel' } ## -# @migrate_set_downtime +# @migrate_set_downtime: # # Set maximum tolerated downtime for migration. #
@@ -1920,7 +1920,7 @@ { 'command': 'migrate_set_downtime', 'data': {'value': 'number'} } ## -# @migrate_set_speed +# @migrate_set_speed: # # Set maximum speed for migration. #
@@ -1935,7 +1935,7 @@ { 'command': 'migrate_set_speed', 'data': {'value': 'int'} } ## -# @migrate-set-cache-size +# @migrate-set-cache-size: # # Set XBZRLE cache size #
@@ -1951,7 +1951,7 @@ { 'command': 'migrate-set-cache-size', 'data': {'value': 'int'} } ## -# @query-migrate-cache-size +# @query-migrate-cache-size: # # query XBZRLE cache size #
@@ -2216,7 +2216,7 @@ 'returns': [ 'DevicePropertyInfo' ] } ## -# @migrate +# @migrate: # # Migrates the current running guest to another Virtual Machine. #
@@ -2237,7 +2237,7 @@ 'data': {'uri': 'str', '*blk': 'bool', '*inc': 'bool', '*detach': 'bool' } } ## -# @migrate-incoming +# @migrate-incoming: # # Start an incoming migration, the qemu must have been started # with -incoming defer
@@ -2271,7 +2271,7 @@ { 'command': 'xen-save-devices-state', 'data': {'filename': 'str'} } ## -# @xen-set-global-dirty-log +# @xen-set-global-dirty-log: # # Enable or disable the global dirty log mode. #
@@ -2363,7 +2363,7 @@ 'data': [ 'elf', 'kdump-zlib', 'kdump-lzo', 'kdump-snappy' ] } ## -# @dump-guest-memory +# @dump-guest-memory: # # Dump guest's memory to vmcore. It is a synchronous operation that can take # very long depending on the amount of guest memory.
@@ -2417,7 +2417,7 @@ '*format': 'DumpGuestMemoryFormat'} } ## -# @DumpStatus +# @DumpStatus: # # Describe the status of a long-running background guest memory dump. #
@@ -2429,13 +2429,13 @@ # # @failed: the last dump has failed. # -# Since 2.6 +# Since: 2.6 ## { 'enum': 'DumpStatus', 'data': [ 'none', 'active', 'completed', 'failed' ] } ## -# @DumpQueryResult +# @DumpQueryResult: # # The result format for 'query-dump'. #
@@ -2445,7 +2445,7 @@ # # @total: total bytes to be written in latest dump (uncompressed) # -# Since 2.6 +# Since: 2.6 ## { 'struct': 'DumpQueryResult', 'data': { 'status': 'DumpStatus',
@@ -2453,7 +2453,7 @@ 'total': 'int' } } ## -# @query-dump +# @query-dump: # # Query latest dump status. #
@@ -2488,7 +2488,7 @@ 'returns': 'DumpGuestMemoryCapability' } ## -# @dump-skeys +# @dump-skeys: # # Dump guest's storage keys #
@@ -2575,17 +2575,17 @@ { 'command': 'object-del', 'data': {'id': 'str'} } ## -# @NetdevNoneOptions +# @NetdevNoneOptions: # # Use it alone to have zero network devices. # -# Since 1.2 +# Since: 1.2 ## { 'struct': 'NetdevNoneOptions', 'data': { } } ## -# @NetLegacyNicOptions +# @NetLegacyNicOptions: # # Create a new Network Interface Card. #
@@ -2599,7 +2599,7 @@ # # @vectors: #optional number of MSI-x vectors, 0 to disable MSI-X # -# Since 1.2 +# Since: 1.2 ## { 'struct': 'NetLegacyNicOptions', 'data': {
@@ -2610,18 +2610,18 @@ '*vectors': 'uint32' } } ## -# @String +# @String: # # A fat type wrapping 'str', to be embedded in lists. # -# Since 1.2 +# Since: 1.2 ## { 'struct': 'String', 'data': { 'str': 'str' } } ## -# @NetdevUserOptions +# @NetdevUserOptions: # # Use the user mode network stack which requires no administrator privilege to # run.
@@ -2678,7 +2678,7 @@ # # @guestfwd: #optional forward guest TCP connections # -# Since 1.2 +# Since: 1.2 ## { 'struct': 'NetdevUserOptions', 'data': {
@@ -2704,7 +2704,7 @@ '*guestfwd': ['String'] } } ## -# @NetdevTapOptions +# @NetdevTapOptions: # # Connect the host TAP network interface name to the VLAN. #
@@ -2741,7 +2741,7 @@ # @poll-us: #optional maximum number of microseconds that could # be spent on busy polling for tap (since 2.7) # -# Since 1.2 +# Since: 1.2 ## { 'struct': 'NetdevTapOptions', 'data': {
@@ -2762,7 +2762,7 @@ '*poll-us': 'uint32'} } ## -# @NetdevSocketOptions +# @NetdevSocketOptions: # # Connect the VLAN to a remote VLAN in another QEMU virtual machine using a TCP # socket connection.
@@ -2779,7 +2779,7 @@ # # @udp: #optional UDP unicast address and port number # -# Since 1.2 +# Since: 1.2 ## { 'struct': 'NetdevSocketOptions', 'data': {
@@ -2791,7 +2791,7 @@ '*udp': 'str' } } ## -# @NetdevL2TPv3Options +# @NetdevL2TPv3Options: # # Connect the VLAN to Ethernet over L2TPv3 Static tunnel #
@@ -2827,7 +2827,7 @@ # @offset: #optional additional offset - allows the insertion of # additional application-specific data before the packet payload # -# Since 2.1 +# Since: 2.1 ## { 'struct': 'NetdevL2TPv3Options', 'data': {
@@ -2847,7 +2847,7 @@ '*offset': 'uint32' } } ## -# @NetdevVdeOptions +# @NetdevVdeOptions: # # Connect the VLAN to a vde switch running on the host. #
@@ -2859,7 +2859,7 @@ # # @mode: #optional permissions for socket # -# Since 1.2 +# Since: 1.2 ## { 'struct': 'NetdevVdeOptions', 'data': {
@@ -2869,7 +2869,7 @@ '*mode': 'uint16' } } ## -# @NetdevDumpOptions +# @NetdevDumpOptions: # # Dump VLAN network traffic to a file. #
@@ -2878,7 +2878,7 @@ # # @file: #optional dump file path (default is qemu-vlan0.pcap) # -# Since 1.2 +# Since: 1.2 ## { 'struct': 'NetdevDumpOptions', 'data': {
@@ -2886,7 +2886,7 @@ '*file': 'str' } } ## -# @NetdevBridgeOptions +# @NetdevBridgeOptions: # # Connect a host TAP network interface to a host bridge device. #
@@ -2894,7 +2894,7 @@ # # @helper: #optional command to execute to configure bridge # -# Since 1.2 +# Since: 1.2 ## { 'struct': 'NetdevBridgeOptions', 'data': {
@@ -2902,20 +2902,20 @@ '*helper': 'str' } } ## -# @NetdevHubPortOptions +# @NetdevHubPortOptions: # # Connect two or more net clients through a software hub. # # @hubid: hub identifier number # -# Since 1.2 +# Since: 1.2 ## { 'struct': 'NetdevHubPortOptions', 'data': { 'hubid': 'int32' } } ## -# @NetdevNetmapOptions +# @NetdevNetmapOptions: # # Connect a client to a netmap-enabled NIC or to a VALE switch port #
@@ -2928,7 +2928,7 @@ # # @devname: #optional path of the netmap device (default: '/dev/netmap'). # -# Since 2.0 +# Since: 2.0 ## { 'struct': 'NetdevNetmapOptions', 'data': {
@@ -2936,7 +2936,7 @@ '*devname': 'str' } } ## -# @NetdevVhostUserOptions +# @NetdevVhostUserOptions: # # Vhost-user network backend #
@@ -2947,7 +2947,7 @@ # @queues: #optional number of queues to be created for multiqueue vhost-user # (default: 1) (Since 2.5) # -# Since 2.1 +# Since: 2.1 ## { 'struct': 'NetdevVhostUserOptions', 'data': {
@@ -2956,18 +2956,18 @@ '*queues': 'int' } } ## -# @NetClientDriver +# @NetClientDriver: # # Available netdev drivers. # -# Since 2.7 +# Since: 2.7 ## { 'enum': 'NetClientDriver', 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', 'dump', 'bridge', 'hubport', 'netmap', 'vhost-user' ] } ## -# @Netdev +# @Netdev: # # Captures the configuration of a network device. #
@@ -2975,7 +2975,7 @@ # # @type: Specify the driver used for interpreting remaining arguments. # -# Since 1.2 +# Since: 1.2 # # 'l2tpv3' - since 2.1 ##
@@ -2997,7 +2997,7 @@ 'vhost-user': 'NetdevVhostUserOptions' } } ## -# @NetLegacy +# @NetLegacy: # # Captures the configuration of a network device; legacy. #
@@ -3009,7 +3009,7 @@ # # @opts: device type specific properties (legacy) # -# Since 1.2 +# Since: 1.2 ## { 'struct': 'NetLegacy', 'data': {
@@ -3019,11 +3019,11 @@ 'opts': 'NetLegacyOptions' } } ## -# @NetLegacyOptions +# @NetLegacyOptions: # # Like Netdev, but for use only by the legacy command line options # -# Since 1.2 +# Since: 1.2 ## { 'union': 'NetLegacyOptions', 'data': {
@@ -3040,7 +3040,7 @@ 'vhost-user': 'NetdevVhostUserOptions' } } ## -# @NetFilterDirection +# @NetFilterDirection: # # Indicates whether a netfilter is attached to a netdev's transmit queue or # receive queue or both.
@@ -3054,13 +3054,13 @@ # @tx: the filter is attached to the transmit queue of the netdev, # where it will receive packets sent by the netdev. # -# Since 2.5 +# Since: 2.5 ## { 'enum': 'NetFilterDirection', 'data': [ 'all', 'rx', 'tx' ] } ## -# @InetSocketAddress +# @InetSocketAddress: # # Captures a socket address or address range in the Internet namespace. #
@@ -3076,7 +3076,7 @@ # @ipv6: whether to accept IPv6 addresses, default try both IPv4 and IPv6 # #optional # -# Since 1.3 +# Since: 1.3 ## { 'struct': 'InetSocketAddress', 'data': {
@@ -3087,30 +3087,30 @@ '*ipv6': 'bool' } } ## -# @UnixSocketAddress +# @UnixSocketAddress: # # Captures a socket address in the local ("Unix socket") namespace. # # @path: filesystem path to use # -# Since 1.3 +# Since: 1.3 ## { 'struct': 'UnixSocketAddress', 'data': { 'path': 'str' } } ## -# @VsockSocketAddress +# @VsockSocketAddress: # # Captures a socket address in the vsock namespace. # # @cid: unique host identifier # @port: port # -# Note that string types are used to allow for possible future hostname or +# Note: string types are used to allow for possible future hostname or # service resolution support. # -# Since 2.8 +# Since: 2.8 ## { 'struct': 'VsockSocketAddress', 'data': {
@@ -3118,11 +3118,11 @@ 'port': 'str' } } ## -# @SocketAddress +# @SocketAddress: # # Captures the address of a socket, which could also be a named file descriptor # -# Since 1.3 +# Since: 1.3 ## { 'union': 'SocketAddress', 'data': {
@@ -3273,7 +3273,7 @@ '*props': 'any' } } ## -# @CpuModelExpansionType +# @CpuModelExpansionType: # # An enumeration of CPU model expansion types. #
@@ -3296,7 +3296,7 @@ ## -# @CpuModelExpansionInfo +# @CpuModelExpansionInfo: # # The result of a cpu model expansion. #
@@ -3370,7 +3370,7 @@ 'data': [ 'incompatible', 'identical', 'superset', 'subset' ] } ## -# @CpuModelCompareInfo +# @CpuModelCompareInfo: # # The result of a CPU model comparison. #
@@ -3434,7 +3434,7 @@ 'returns': 'CpuModelCompareInfo' } ## -# @CpuModelBaselineInfo +# @CpuModelBaselineInfo: # # The result of a CPU model baseline. #
@@ -3644,7 +3644,7 @@ 'kp_comma', 'kp_equals', 'power' ] } ## -# @KeyValue +# @KeyValue: # # Represents a keyboard key. #
@@ -4030,7 +4030,7 @@ { 'command': 'query-tpm', 'returns': ['TPMInfo'] } ## -# @AcpiTableOptions +# @AcpiTableOptions: # # Specify an ACPI table on the command line to load. #
@@ -4073,7 +4073,7 @@ # ACPI table header. At least one file is required. This field excludes # @file. # -# Since 1.5 +# Since: 1.5 ## { 'struct': 'AcpiTableOptions', 'data': {
@@ -4101,7 +4101,7 @@ # @size: accepts a number followed by an optional suffix (K)ilo, # (M)ega, (G)iga, (T)era # -# Since 1.5 +# Since: 1.5 ## { 'enum': 'CommandLineParameterType', 'data': ['string', 'boolean', 'number', 'size'] }
@@ -4119,7 +4119,7 @@ # # @default: #optional default value string (since 2.1) # -# Since 1.5 +# Since: 1.5 ## { 'struct': 'CommandLineParameterInfo', 'data': { 'name': 'str',
@@ -4136,7 +4136,7 @@ # # @parameters: an array of @CommandLineParameterInfo # -# Since 1.5 +# Since: 1.5 ## { 'struct': 'CommandLineOptionInfo', 'data': { 'option': 'str', 'parameters': ['CommandLineParameterInfo'] } }
@@ -4151,13 +4151,13 @@ # Returns: list of @CommandLineOptionInfo for all options (or for the given # @option). Returns an error if the given @option doesn't exist. # -# Since 1.5 +# Since: 1.5 ## {'command': 'query-command-line-options', 'data': { '*option': 'str' }, 'returns': ['CommandLineOptionInfo'] } ## -# @X86CPURegister32 +# @X86CPURegister32: # # A X86 32-bit register #
@@ -4167,7 +4167,7 @@ 'data': [ 'EAX', 'EBX', 'ECX', 'EDX', 'ESP', 'EBP', 'ESI', 'EDI' ] } ## -# @X86CPUFeatureWordInfo +# @X86CPUFeatureWordInfo: # # Information about a X86 CPU feature word #
@@ -4189,11 +4189,11 @@ 'features': 'int' } } ## -# @DummyForceArrays +# @DummyForceArrays: # # Not used by QMP; hack to let us use X86CPUFeatureWordInfoList internally # -# Since 2.5 +# Since: 2.5 ## { 'struct': 'DummyForceArrays', 'data': { 'unused': ['X86CPUFeatureWordInfo'] } }
@@ -4243,7 +4243,7 @@ # # @multicast-table: a list of multicast macaddr string # -# Since 1.6 +# Since: 1.6 ## { 'struct': 'RxFilterInfo', 'data': {
@@ -4278,7 +4278,7 @@ 'returns': ['RxFilterInfo'] } ## -# @InputButton +# @InputButton: # # Button of a pointer input device (mouse, tablet). #
@@ -4288,7 +4288,7 @@ 'data' : [ 'left', 'middle', 'right', 'wheel-up', 'wheel-down' ] } ## -# @InputAxis +# @InputAxis: # # Position axis of a pointer input device (mouse, tablet). #
@@ -4298,7 +4298,7 @@ 'data' : [ 'x', 'y' ] } ## -# @InputKeyEvent +# @InputKeyEvent: # # Keyboard input event. #
@@ -4312,7 +4312,7 @@ 'down' : 'bool' } } ## -# @InputBtnEvent +# @InputBtnEvent: # # Pointer button input event. #
@@ -4326,7 +4326,7 @@ 'down' : 'bool' } } ## -# @InputMoveEvent +# @InputMoveEvent: # # Pointer motion input event. #
@@ -4341,7 +4341,7 @@ 'value' : 'int' } } ## -# @InputEvent +# @InputEvent: # # Input event union. #
@@ -4360,7 +4360,7 @@ 'abs' : 'InputMoveEvent' } } ## -# @input-send-event +# @input-send-event: # # Send input event(s) to guest. #
@@ -4390,18 +4390,18 @@ 'events' : [ 'InputEvent' ] } } ## -# @NumaOptions +# @NumaOptions: # # A discriminated record of NUMA options. (for OptsVisitor) # -# Since 2.1 +# Since: 2.1 ## { 'union': 'NumaOptions', 'data': { 'node': 'NumaNodeOptions' }} ## -# @NumaNodeOptions +# @NumaNodeOptions: # # Create a guest NUMA node. (for OptsVisitor) #
@@ -4427,7 +4427,7 @@ '*memdev': 'str' }} ## -# @HostMemPolicy +# @HostMemPolicy: # # Host memory policy types #
@@ -4441,7 +4441,7 @@ # @interleave: memory allocations are interleaved across the set # of host nodes specified # -# Since 2.1 +# Since: 2.1 ## { 'enum': 'HostMemPolicy', 'data': [ 'default', 'preferred', 'bind', 'interleave' ] }
@@ -4530,7 +4530,7 @@ { 'union': 'MemoryDeviceInfo', 'data': {'dimm': 'PCDIMMDeviceInfo'} } ## -# @query-memory-devices +# @query-memory-devices: # # Lists available memory devices and their state #
@@ -4539,7 +4539,7 @@ { 'command': 'query-memory-devices', 'returns': ['MemoryDeviceInfo'] } ## -# @ACPISlotType +# @ACPISlotType: # # @DIMM: memory slot # @CPU: logical CPU slot (since 2.7)
@@ -4547,7 +4547,7 @@ { 'enum': 'ACPISlotType', 'data': [ 'DIMM', 'CPU' ] } ## -# @ACPIOSTInfo +# @ACPIOSTInfo: # # OSPM Status Indication for a device # For description of possible values of @source and @status fields
@@ -4573,7 +4573,7 @@ 'status': 'int' } } ## -# @query-acpi-ospm-status +# @query-acpi-ospm-status: # # Lists ACPI OSPM status of ACPI device objects, # which might be reported via _OST method
@@ -4583,7 +4583,7 @@ { 'command': 'query-acpi-ospm-status', 'returns': ['ACPIOSTInfo'] } ## -# @WatchdogExpirationAction +# @WatchdogExpirationAction: # # An enumeration of the actions taken when the watchdog device's timer is # expired
@@ -4611,7 +4611,7 @@ 'inject-nmi' ] } ## -# @IoOperationType +# @IoOperationType: # # An enumeration of the I/O operation types #
@@ -4625,7 +4625,7 @@ 'data': [ 'read', 'write' ] } ## -# @GuestPanicAction +# @GuestPanicAction: # # An enumeration of the actions taken when guest OS panic is detected #
@@ -4637,7 +4637,7 @@ 'data': [ 'pause', 'poweroff' ] } ## -# @rtc-reset-reinjection +# @rtc-reset-reinjection: # # This command will reset the RTC interrupt reinjection backlog. # Can be used if another mechanism to synchronize guest time
@@ -4720,7 +4720,7 @@ { 'command': 'query-gic-capabilities', 'returns': ['GICCapability'] } ## -# @CpuInstanceProperties +# @CpuInstanceProperties: # # List of properties to be used for hotplugging a CPU instance, # it should be passed by management with device_add command when
@@ -4748,7 +4748,7 @@ } ## -# @HotpluggableCPU +# @HotpluggableCPU: # # @type: CPU object type for usage with device_add command # @props: list of properties to be used for hotplugging CPU
@@ -4767,7 +4767,7 @@ } ## -# @query-hotpluggable-cpus +# @query-hotpluggable-cpus: # # Returns: a list of HotpluggableCPU objects. #
qapi/block-core.json +98 -98
743 lines not on this page · raw message
qapi/block.json +8 -8
@@ -40,7 +40,7 @@ 'data': ['auto', 'none', 'lba', 'large', 'rechs']} ## -# @FloppyDriveType +# @FloppyDriveType: # # Type of Floppy drive to be emulated by the Floppy Disk Controller. #
@@ -56,7 +56,7 @@ 'data': ['144', '288', '120', 'none', 'auto']} ## -# @BlockdevSnapshotInternal +# @BlockdevSnapshotInternal: # # @device: the device name or node-name of a root node to generate the snapshot # from
@@ -73,7 +73,7 @@ 'data': { 'device': 'str', 'name': 'str' } } ## -# @blockdev-snapshot-internal-sync +# @blockdev-snapshot-internal-sync: # # Synchronously take an internal snapshot of a block device, when the format # of the image used supports it.
@@ -87,13 +87,13 @@ # If the format of the image used does not support it, # BlockFormatFeatureNotSupported # -# Since 1.7 +# Since: 1.7 ## { 'command': 'blockdev-snapshot-internal-sync', 'data': 'BlockdevSnapshotInternal' } ## -# @blockdev-snapshot-delete-internal-sync +# @blockdev-snapshot-delete-internal-sync: # # Synchronously delete an internal snapshot of a block device, when the format # of the image used support it. The snapshot is identified by name or id or
@@ -114,7 +114,7 @@ # BlockFormatFeatureNotSupported # If @id and @name are both not specified, GenericError # -# Since 1.7 +# Since: 1.7 ## { 'command': 'blockdev-snapshot-delete-internal-sync', 'data': { 'device': 'str', '*id': 'str', '*name': 'str'},
@@ -190,7 +190,7 @@ { 'command': 'nbd-server-stop' } ## -# @DEVICE_TRAY_MOVED +# @DEVICE_TRAY_MOVED: # # Emitted whenever the tray of a removable device is moved by the guest or by # HMP/QMP commands
@@ -209,7 +209,7 @@ 'data': { 'device': 'str', 'id': 'str', 'tray-open': 'bool' } } ## -# @QuorumOpType +# @QuorumOpType: # # An enumeration of the quorum operation types #
qapi/common.json +4 -4
@@ -3,7 +3,7 @@ # QAPI common definitions ## -# @QapiErrorClass +# @QapiErrorClass: # # QEMU error classes #
@@ -30,7 +30,7 @@ 'DeviceNotActive', 'DeviceNotFound', 'KVMMissingCap' ] } ## -# @VersionTriple +# @VersionTriple: # # A three-part version number. #
@@ -101,7 +101,7 @@ { 'command': 'query-commands', 'returns': ['CommandInfo'] } ## -# @OnOffAuto +# @OnOffAuto: # # An enumeration of three options: on, off, and auto #
@@ -117,7 +117,7 @@ 'data': [ 'auto', 'on', 'off' ] } ## -# @OnOffSplit +# @OnOffSplit: # # An enumeration of three values: on, off, and split #
qapi/event.json +29 -29
230 lines not on this page · raw message
qapi/introspect.json +14 -14
@@ -11,7 +11,7 @@ # See the COPYING file in the top-level directory. ## -# @query-qmp-schema +# @query-qmp-schema: # # Command query-qmp-schema exposes the QMP wire ABI as an array of # SchemaInfo. This lets QMP clients figure out what commands and
@@ -49,7 +49,7 @@ 'gen': false } # just to simplify qmp_query_json() ## -# @SchemaMetaType +# @SchemaMetaType: # # This is a @SchemaInfo's meta type, i.e. the kind of entity it # describes.
@@ -75,7 +75,7 @@ 'command', 'event' ] } ## -# @SchemaInfo +# @SchemaInfo: # # @name: the entity's name, inherited from @base. # Commands and events have the name defined in the QAPI schema.
@@ -105,7 +105,7 @@ 'event': 'SchemaInfoEvent' } } ## -# @SchemaInfoBuiltin +# @SchemaInfoBuiltin: # # Additional SchemaInfo members for meta-type 'builtin'. #
@@ -117,7 +117,7 @@ 'data': { 'json-type': 'JSONType' } } ## -# @JSONType +# @JSONType: # # The four primitive and two structured types according to RFC 7159 # section 1, plus 'int' (split off 'number'), plus the obvious top
@@ -130,7 +130,7 @@ 'object', 'array', 'value' ] } ## -# @SchemaInfoEnum +# @SchemaInfoEnum: # # Additional SchemaInfo members for meta-type 'enum'. #
@@ -144,7 +144,7 @@ 'data': { 'values': ['str'] } } ## -# @SchemaInfoArray +# @SchemaInfoArray: # # Additional SchemaInfo members for meta-type 'array'. #
@@ -158,7 +158,7 @@ 'data': { 'element-type': 'str' } } ## -# @SchemaInfoObject +# @SchemaInfoObject: # # Additional SchemaInfo members for meta-type 'object'. #
@@ -183,7 +183,7 @@ '*variants': [ 'SchemaInfoObjectVariant' ] } } ## -# @SchemaInfoObjectMember +# @SchemaInfoObjectMember: # # An object member. #
@@ -206,7 +206,7 @@ # @default's type must be null or match @type ## -# @SchemaInfoObjectVariant +# @SchemaInfoObjectVariant: # # The variant members for a value of the type tag. #
@@ -221,7 +221,7 @@ 'data': { 'case': 'str', 'type': 'str' } } ## -# @SchemaInfoAlternate +# @SchemaInfoAlternate: # # Additional SchemaInfo members for meta-type 'alternate'. #
@@ -237,7 +237,7 @@ 'data': { 'members': [ 'SchemaInfoAlternateMember' ] } } ## -# @SchemaInfoAlternateMember +# @SchemaInfoAlternateMember: # # An alternate member. #
@@ -249,7 +249,7 @@ 'data': { 'type': 'str' } } ## -# @SchemaInfoCommand +# @SchemaInfoCommand: # # Additional SchemaInfo members for meta-type 'command'. #
@@ -266,7 +266,7 @@ 'data': { 'arg-type': 'str', 'ret-type': 'str' } } ## -# @SchemaInfoEvent +# @SchemaInfoEvent: # # Additional SchemaInfo members for meta-type 'event'. #
qapi/trace.json +4 -4
@@ -17,7 +17,7 @@ # # @enabled: The event is dynamically enabled. # -# Since 2.2 +# Since: 2.2 ## { 'enum': 'TraceEventState', 'data': ['unavailable', 'disabled', 'enabled'] }
@@ -34,7 +34,7 @@ # An event is per-vCPU if it has the "vcpu" property in the "trace-events" # files. # -# Since 2.2 +# Since: 2.2 ## { 'struct': 'TraceEventInfo', 'data': {'name': 'str', 'state': 'TraceEventState', 'vcpu': 'bool'} }
@@ -58,7 +58,7 @@ # exact match, @vcpu is given and the event does not have the "vcpu" property, # an error is returned. # -# Since 2.2 +# Since: 2.2 ## { 'command': 'trace-event-get-state', 'data': {'name': 'str', '*vcpu': 'int'},
@@ -83,7 +83,7 @@ # match, @vcpu is given and the event does not have the "vcpu" property, an # error is returned. # -# Since 2.2 +# Since: 2.2 ## { 'command': 'trace-event-set-state', 'data': {'name': 'str', 'enable': 'bool', '*ignore-unavailable': 'bool',
qga/qapi-schema.json +22 -22
175 lines not on this page · raw message
Signature · 1 line
2.10.0
Re: [Qemu-devel] [PATCH v5 08/17] qapi: add missing colon-ending for section name
Quoted 4 lines · Marc-André Lureau
The documentation parser we are going to add expects a section name to end with ':', otherwise the comment is treated as free-form text body.
Signed-off-by Marc-André Lureau <[email protected]>
PATCH v5 9/17 qapi: add some sections in docs
In reply to Marc-André LureauAdd some more section titles to organize the produced documents.
--- qapi-schema.json | 4 ++++ qapi/block-core.json | 6 ++++-- qapi/block.json | 10 ++++++++-- qapi/common.json | 6 ++++-- qapi/crypto.json | 5 ++++- qapi/event.json | 6 ++++++ qapi/rocker.json | 4 ++++ qapi/trace.json | 3 +++ 8 files changed, 37 insertions(+), 7 deletions(-)
qapi-schema.json +4 -0
@@ -20,6 +20,10 @@ # QAPI introspection { 'include': 'qapi/introspect.json' } +## +# = QMP commands +## + ## # @qmp_capabilities: #
qapi/block-core.json +4 -2
@@ -1,6 +1,8 @@ # -*- Mode: Python -*- -# -# QAPI block core definitions (vm unrelated) + +## +# == QAPI block core definitions (vm unrelated) +## # QAPI common definitions { 'include': 'common.json' }
qapi/block.json +8 -2
@@ -1,10 +1,16 @@ # -*- Mode: Python -*- -# -# QAPI block definitions (vm related) + +## +# = QAPI block definitions +## # QAPI block core definitions { 'include': 'block-core.json' } +## +# == QAPI block definitions (vm unrelated) +## + ## # @BiosAtaTranslation: #
qapi/common.json +4 -2
@@ -1,6 +1,8 @@ # -*- Mode: Python -*- -# -# QAPI common definitions + +## +# = QAPI common definitions +## ## # @QapiErrorClass:
qapi/crypto.json +4 -1
@@ -1,6 +1,9 @@ # -*- Mode: Python -*- # -# QAPI crypto definitions + +## +# = QAPI crypto definitions +## ## # @QCryptoTLSCredsEndpoint:
qapi/event.json +6 -0
@@ -1,3 +1,9 @@ +# -*- Mode: Python -*- + +## +# = Events +## + ## # @SHUTDOWN: #
qapi/rocker.json +4 -0
@@ -1,4 +1,8 @@ ## +# = Rocker API +## + +## # @RockerSwitch: # # Rocker switch information.
qapi/trace.json +3 -0
@@ -5,6 +5,9 @@ # This work is licensed under the terms of the GNU GPL, version 2 or later. # See the COPYING file in the top-level directory. +## +# = Tracing commands +## ## # @TraceEventState:
Signature · 1 line
2.10.0
Re: [Qemu-devel] [PATCH v5 09/17] qapi: add some sections in docs
Quoted 1 line · Marc-André Lureau
Add some more section titles to organize the produced documents.
Either move this after the doc generator gets added, or say something like "to organize the documentation we're going to generate".
Quoted 1 line
Signed-off-by Marc-André Lureau <[email protected]>
With that:
Re: [Qemu-devel] [PATCH v5 09/17] qapi: add some sections in docs
In reply to Marc-André LureauSecond thoughts...
Quoted 102 lines · Marc-André Lureau
Add some more section titles to organize the produced documents.
Signed-off-by Marc-André Lureau <[email protected]>--- qapi-schema.json | 4 ++++ qapi/block-core.json | 6 ++++-- qapi/block.json | 10 ++++++++-- qapi/common.json | 6 ++++-- qapi/crypto.json | 5 ++++- qapi/event.json | 6 ++++++ qapi/rocker.json | 4 ++++ qapi/trace.json | 3 +++ 8 files changed, 37 insertions(+), 7 deletions(-)qapi-schema.json +4
-0@@ -20,6 +20,10 @@ # QAPI introspection { 'include': 'qapi/introspect.json' } +## +# = QMP commands +## + ## # @qmp_capabilities: #qapi/block-core.json +4
-2@@ -1,6 +1,8 @@ # -*- Mode: Python -*- -# -# QAPI block core definitions (vm unrelated) + +## +# == QAPI block core definitions (vm unrelated) +## # QAPI common definitions { 'include': 'common.json' }qapi/block.json +8
-2@@ -1,10 +1,16 @@ # -*- Mode: Python -*- -# -# QAPI block definitions (vm related) + +## +# = QAPI block definitions +## # QAPI block core definitions { 'include': 'block-core.json' } +## +# == QAPI block definitions (vm unrelated) +## + ## # @BiosAtaTranslation: #qapi/common.json +4
-2@@ -1,6 +1,8 @@ # -*- Mode: Python -*- -# -# QAPI common definitions + +## +# = QAPI common definitions +## ## # @QapiErrorClass:qapi/crypto.json +4
-1@@ -1,6 +1,9 @@ # -*- Mode: Python -*- # -# QAPI crypto definitions + +## +# = QAPI crypto definitions +## ## # @QCryptoTLSCredsEndpoint:qapi/event.json +0
-0
qapi/event.json line 6
Quoted 6 lines
qapi/event.json +6
-0@@ -1,3 +1,9 @@ +# -*- Mode: Python -*- + +## +# = Events +## +
This suggests *all* events are in this section, which isn't the case. "Other events"? "Core events"? Dunno...
qapi/rocker.json line 2
Quoted 10 lines
qapi/event.json +0
-0## # @SHUTDOWN: #qapi/rocker.json +1
-0@@ -1,4 +1,8 @@ ## +# = Rocker API
What about "Rocker switch device"?
Quoted 20 lines
qapi/rocker.json +3
-0+## + +## # @RockerSwitch: # # Rocker switch information.qapi/trace.json +3
-0@@ -5,6 +5,9 @@ # This work is licensed under the terms of the GNU GPL, version 2 or later. # See the COPYING file in the top-level directory. +## +# = Tracing commands +## ## # @TraceEventState:
Re: [Qemu-devel] [PATCH v5 09/17] qapi: add some sections in docs
Hi
----- Original Message -----
Quoted 99 lines
Second thoughts...
Quoted 95 lines · Marc-André Lureau
Add some more section titles to organize the produced documents.
Signed-off-by Marc-André Lureau <[email protected]>--- qapi-schema.json | 4 ++++ qapi/block-core.json | 6 ++++-- qapi/block.json | 10 ++++++++-- qapi/common.json | 6 ++++-- qapi/crypto.json | 5 ++++- qapi/event.json | 6 ++++++ qapi/rocker.json | 4 ++++ qapi/trace.json | 3 +++ 8 files changed, 37 insertions(+), 7 deletions(-)qapi-schema.json +4
-0@@ -20,6 +20,10 @@ # QAPI introspection { 'include': 'qapi/introspect.json' } +## +# = QMP commands +## + ## # @qmp_capabilities: #qapi/block-core.json +4
-2@@ -1,6 +1,8 @@ # -*- Mode: Python -*- -# -# QAPI block core definitions (vm unrelated) + +## +# == QAPI block core definitions (vm unrelated) +## # QAPI common definitions { 'include': 'common.json' }qapi/block.json +8
-2@@ -1,10 +1,16 @@ # -*- Mode: Python -*- -# -# QAPI block definitions (vm related) + +## +# = QAPI block definitions +## # QAPI block core definitions { 'include': 'block-core.json' } +## +# == QAPI block definitions (vm unrelated) +## + ## # @BiosAtaTranslation: #qapi/common.json +4
-2@@ -1,6 +1,8 @@ # -*- Mode: Python -*- -# -# QAPI common definitions + +## +# = QAPI common definitions +## ## # @QapiErrorClass:qapi/crypto.json +4
-1@@ -1,6 +1,9 @@ # -*- Mode: Python -*- # -# QAPI crypto definitions + +## +# = QAPI crypto definitions +##
Quoted 16 lines
qapi/event.json line 6
Quoted 13 lines
qapi/crypto.json +0
-0## # @QCryptoTLSCredsEndpoint:qapi/event.json +6
-0@@ -1,3 +1,9 @@ +# -*- Mode: Python -*- + +## +# = Events +## +This suggests *all* events are in this section, which isn't the case. "Other events"? "Core events"? Dunno...
"Other events" sounds nice to me. I think we could improve the organization after.
Quoted 4 lines
Quoted 4 lines
qapi/event.json +0
-0## # @SHUTDOWN: #qapi/rocker.json +0
-0
Quoted 8 lines
qapi/rocker.json line 2
Quoted 6 lines
index ace2776..dd72e02 100644
qapi/rocker.json +1
-0@@ -1,4 +1,8 @@ ## +# = Rocker APIWhat about "Rocker switch device"?
ok
Quoted 23 lines
Quoted 22 lines
qapi/rocker.json +3
-0+## + +## # @RockerSwitch: # # Rocker switch information.qapi/trace.json +3
-0@@ -5,6 +5,9 @@ # This work is licensed under the terms of the GNU GPL, version 2 or later. # See the COPYING file in the top-level directory. +## +# = Tracing commands +## ### @TraceEventState:
PATCH v5 10/17 qapi: improve TransactionAction doc
In reply to Marc-André LureauTransactionAction is a flat union, document 'type' versions exhaustively, and sort list.
--- qapi-schema.json | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
qapi-schema.json +16 -15
@@ -1797,28 +1797,29 @@ # @TransactionAction: # # A discriminated record of operations that can be performed with -# @transaction. +# @transaction. Action @type can be: # -# Since: 1.1 +# - @abort: since 1.6 +# - @block-dirty-bitmap-add: since 2.5 +# - @block-dirty-bitmap-clear: since 2.5 +# - @blockdev-backup: since 2.3 +# - @blockdev-snapshot: since 2.5 +# - @blockdev-snapshot-internal-sync: since 1.7 +# - @blockdev-snapshot-sync: since 1.1 +# - @drive-backup: since 1.6 # -# drive-backup since 1.6 -# abort since 1.6 -# blockdev-snapshot-internal-sync since 1.7 -# blockdev-backup since 2.3 -# blockdev-snapshot since 2.5 -# block-dirty-bitmap-add since 2.5 -# block-dirty-bitmap-clear since 2.5 +# Since: 1.1 ## { 'union': 'TransactionAction', 'data': { - 'blockdev-snapshot': 'BlockdevSnapshot', - 'blockdev-snapshot-sync': 'BlockdevSnapshotSync', - 'drive-backup': 'DriveBackup', - 'blockdev-backup': 'BlockdevBackup', 'abort': 'Abort', - 'blockdev-snapshot-internal-sync': 'BlockdevSnapshotInternal', 'block-dirty-bitmap-add': 'BlockDirtyBitmapAdd', - 'block-dirty-bitmap-clear': 'BlockDirtyBitmap' + 'block-dirty-bitmap-clear': 'BlockDirtyBitmap', + 'blockdev-backup': 'BlockdevBackup', + 'blockdev-snapshot': 'BlockdevSnapshot', + 'blockdev-snapshot-internal-sync': 'BlockdevSnapshotInternal', + 'blockdev-snapshot-sync': 'BlockdevSnapshotSync', + 'drive-backup': 'DriveBackup' } } ##
Signature · 1 line
2.10.0
Re: [Qemu-devel] [PATCH v5 10/17] qapi: improve TransactionAction doc
Quoted 2 lines · Marc-André Lureau
TransactionAction is a flat union, document 'type' versions exhaustively, and sort list.
"and sort the members".
Quoted 2 lines
Signed-off-by Marc-André Lureau <[email protected]>
With that
PATCH v5 11/17 docs: add master qapi texi files
In reply to Marc-André LureauThe qapi2texi script generates a file to be included in a texi file. Add "QEMU QMP Reference Manual" and "QEMU Guest Agent Protocol Reference" master texi files.
--- docs/qemu-ga-ref.texi | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ docs/qemu-qmp-ref.texi | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 docs/qemu-ga-ref.texi create mode 100644 docs/qemu-qmp-ref.texi
docs/qemu-ga-ref.texi new file +78 -0
@@ -0,0 +1,78 @@ +\input texinfo +@setfilename qemu-ga-ref.info + +@exampleindent 0 +@paragraphindent 0 + +@settitle QEMU Guest Agent Protocol Reference + +@copying +This is the QEMU Guest Agent Protocol reference manual. + +Copyright @copyright{} 2016 The QEMU Project developers + +@quotation +This manual is free documentation: you can redistribute it and/or +modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 2 of the +License, or (at your option) any later version. + +This manual is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this manual. If not, see http://www.gnu.org/licenses/. +@end quotation +@end copying + +@dircategory QEMU +@direntry +* QEMU-GA-Ref: (qemu-ga-ref). QEMU Guest Agent Protocol Reference +@end direntry + +@titlepage +@title Guest Agent Protocol Reference Manual +@subtitle QEMU version @value{VERSION} +@page +@vskip 0pt plus 1filll +@insertcopying +@end titlepage + +@contents + +@ifnottex +@node Top +@top QEMU Guest Agent protocol reference +@end ifnottex + +@menu +* API Reference:: +* Commands and Events Index:: +* Data Types Index:: +@end menu + +@node API Reference +@chapter API Reference + +@c for texi2pod: +@c man begin DESCRIPTION + +@include qemu-ga-qapi.texi + +@c man end + +@c man begin SEEALSO +The HTML documentation of QEMU for more information. +@c man end + +@node Commands and Events Index +@unnumbered Commands and Events Index +@printindex fn + +@node Data Types Index +@unnumbered Data Types Index +@printindex tp + +@bye
docs/qemu-qmp-ref.texi new file +78 -0
78 lines not on this page · raw message
Signature · 1 line
2.10.0
Re: [Qemu-devel] [PATCH v5 11/17] docs: add master qapi texi files
Quoted 5 lines · Marc-André Lureau
The qapi2texi script generates a file to be included in a texi file. Add "QEMU QMP Reference Manual" and "QEMU Guest Agent Protocol Reference" master texi files.
Signed-off-by Marc-André Lureau <[email protected]>
PATCH v5 12/17 qapi: rename QAPIExprError/QAPILineError
In reply to Marc-André LureauThere is nothing specific about expressions in this exception, the following patch will use it without expressions.
--- scripts/qapi.py | 146 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 73 insertions(+), 73 deletions(-)
scripts/qapi.py +73 -73
@@ -110,11 +110,11 @@ class QAPISchemaError(Exception): "%s:%d:%d: %s" % (self.fname, self.line, self.col, self.msg) -class QAPIExprError(Exception): - def __init__(self, expr_info, msg): +class QAPILineError(Exception): + def __init__(self, info, msg): Exception.__init__(self) - assert expr_info - self.info = expr_info + assert info + self.info = info self.msg = msg def __str__(self):
@@ -140,24 +140,24 @@ class QAPISchemaParser(object): self.accept() while self.tok is not None: - expr_info = {'file': fname, 'line': self.line, - 'parent': self.incl_info} + info = {'file': fname, 'line': self.line, + 'parent': self.incl_info} expr = self.get_expr(False) if isinstance(expr, dict) and "include" in expr: if len(expr) != 1: - raise QAPIExprError(expr_info, + raise QAPILineError(info, "Invalid 'include' directive") include = expr["include"] if not isinstance(include, str): - raise QAPIExprError(expr_info, + raise QAPILineError(info, "Value of 'include' must be a string") incl_abs_fname = os.path.join(os.path.dirname(abs_fname), include) # catch inclusion cycle - inf = expr_info + inf = info while inf: if incl_abs_fname == os.path.abspath(inf['file']): - raise QAPIExprError(expr_info, "Inclusion loop for %s" + raise QAPILineError(info, "Inclusion loop for %s" % include) inf = inf['parent'] # skip multiple include of the same file
@@ -166,14 +166,14 @@ class QAPISchemaParser(object): try: fobj = open(incl_abs_fname, 'r') except IOError as e: - raise QAPIExprError(expr_info, + raise QAPILineError(info, '%s: %s' % (e.strerror, include)) exprs_include = QAPISchemaParser(fobj, previously_included, - expr_info) + info) self.exprs.extend(exprs_include.exprs) else: expr_elem = {'expr': expr, - 'info': expr_info} + 'info': info} self.exprs.append(expr_elem) def accept(self):
@@ -375,18 +375,18 @@ valid_name = re.compile('^(__[a-zA-Z0-9.-]+_)?' '[a-zA-Z][a-zA-Z0-9_-]*$') -def check_name(expr_info, source, name, allow_optional=False, +def check_name(info, source, name, allow_optional=False, enum_member=False): global valid_name membername = name if not isinstance(name, str): - raise QAPIExprError(expr_info, + raise QAPILineError(info, "%s requires a string name" % source) if name.startswith('*'): membername = name[1:] if not allow_optional: - raise QAPIExprError(expr_info, + raise QAPILineError(info, "%s does not allow optional name '%s'" % (source, name)) # Enum members can start with a digit, because the generated C
@@ -397,7 +397,7 @@ def check_name(expr_info, source, name, allow_optional=False, # and 'q_obj_*' implicit type names. if not valid_name.match(membername) or \ c_name(membername, False).startswith('q_'): - raise QAPIExprError(expr_info, + raise QAPILineError(info, "%s uses invalid name '%s'" % (source, name))
@@ -407,11 +407,11 @@ def add_name(name, info, meta, implicit=False): # FIXME should reject names that differ only in '_' vs. '.' # vs. '-', because they're liable to clash in generated C. if name in all_names: - raise QAPIExprError(info, + raise QAPILineError(info, "%s '%s' is already defined" % (all_names[name], name)) if not implicit and (name.endswith('Kind') or name.endswith('List')): - raise QAPIExprError(info, + raise QAPILineError(info, "%s '%s' should not end in '%s'" % (meta, name, name[-4:])) all_names[name] = meta
@@ -465,7 +465,7 @@ def is_enum(name): return find_enum(name) is not None -def check_type(expr_info, source, value, allow_array=False, +def check_type(info, source, value, allow_array=False, allow_dict=False, allow_optional=False, allow_metas=[]): global all_names
@@ -476,10 +476,10 @@ def check_type(expr_info, source, value, allow_array=False, # Check if array type for value is okay if isinstance(value, list): if not allow_array: - raise QAPIExprError(expr_info, + raise QAPILineError(info, "%s cannot be an array" % source) if len(value) != 1 or not isinstance(value[0], str): - raise QAPIExprError(expr_info, + raise QAPILineError(info, "%s: array type must contain single type name" % source) value = value[0]
@@ -487,58 +487,58 @@ def check_type(expr_info, source, value, allow_array=False, # Check if type name for value is okay if isinstance(value, str): if value not in all_names: - raise QAPIExprError(expr_info, + raise QAPILineError(info, "%s uses unknown type '%s'" % (source, value)) if not all_names[value] in allow_metas: - raise QAPIExprError(expr_info, + raise QAPILineError(info, "%s cannot use %s type '%s'" % (source, all_names[value], value)) return if not allow_dict: - raise QAPIExprError(expr_info, + raise QAPILineError(info, "%s should be a type name" % source) if not isinstance(value, OrderedDict): - raise QAPIExprError(expr_info, + raise QAPILineError(info, "%s should be a dictionary or type name" % source) # value is a dictionary, check that each member is okay for (key, arg) in value.items(): - check_name(expr_info, "Member of %s" % source, key, + check_name(info, "Member of %s" % source, key, allow_optional=allow_optional) if c_name(key, False) == 'u' or c_name(key, False).startswith('has_'): - raise QAPIExprError(expr_info, + raise QAPILineError(info, "Member of %s uses reserved name '%s'" % (source, key)) # Todo: allow dictionaries to represent default values of # an optional argument. - check_type(expr_info, "Member '%s' of %s" % (key, source), arg, + check_type(info, "Member '%s' of %s" % (key, source), arg, allow_array=True, allow_metas=['built-in', 'union', 'alternate', 'struct', 'enum']) -def check_command(expr, expr_info): +def check_command(expr, info): name = expr['command'] boxed = expr.get('boxed', False) args_meta = ['struct'] if boxed: args_meta += ['union', 'alternate'] - check_type(expr_info, "'data' for command '%s'" % name, + check_type(info, "'data' for command '%s'" % name, expr.get('data'), allow_dict=not boxed, allow_optional=True, allow_metas=args_meta) returns_meta = ['union', 'struct'] if name in returns_whitelist: returns_meta += ['built-in', 'alternate', 'enum'] - check_type(expr_info, "'returns' for command '%s'" % name, + check_type(info, "'returns' for command '%s'" % name, expr.get('returns'), allow_array=True, allow_optional=True, allow_metas=returns_meta) -def check_event(expr, expr_info): +def check_event(expr, info): global events name = expr['event'] boxed = expr.get('boxed', False)
@@ -547,12 +547,12 @@ def check_event(expr, expr_info): if boxed: meta += ['union', 'alternate'] events.append(name) - check_type(expr_info, "'data' for event '%s'" % name, + check_type(info, "'data' for event '%s'" % name, expr.get('data'), allow_dict=not boxed, allow_optional=True, allow_metas=meta) -def check_union(expr, expr_info): +def check_union(expr, info): name = expr['union'] base = expr.get('base') discriminator = expr.get('discriminator')
@@ -565,18 +565,18 @@ def check_union(expr, expr_info): enum_define = None allow_metas = ['built-in', 'union', 'alternate', 'struct', 'enum'] if base is not None: - raise QAPIExprError(expr_info, + raise QAPILineError(info, "Simple union '%s' must not have a base" % name) # Else, it's a flat union. else: # The object must have a string or dictionary 'base'. - check_type(expr_info, "'base' for union '%s'" % name, + check_type(info, "'base' for union '%s'" % name, base, allow_dict=True, allow_optional=True, allow_metas=['struct']) if not base: - raise QAPIExprError(expr_info, + raise QAPILineError(info, "Flat union '%s' must have a base" % name) base_members = find_base_members(base)
@@ -584,11 +584,11 @@ def check_union(expr, expr_info): # The value of member 'discriminator' must name a non-optional # member of the base struct. - check_name(expr_info, "Discriminator of flat union '%s'" % name, + check_name(info, "Discriminator of flat union '%s'" % name, discriminator) discriminator_type = base_members.get(discriminator) if not discriminator_type: - raise QAPIExprError(expr_info, + raise QAPILineError(info, "Discriminator '%s' is not a member of base " "struct '%s'" % (discriminator, base))
@@ -596,26 +596,26 @@ def check_union(expr, expr_info): allow_metas = ['struct'] # Do not allow string discriminator if not enum_define: - raise QAPIExprError(expr_info, + raise QAPILineError(info, "Discriminator '%s' must be of enumeration " "type" % discriminator) # Check every branch; don't allow an empty union if len(members) == 0: - raise QAPIExprError(expr_info, + raise QAPILineError(info, "Union '%s' cannot have empty 'data'" % name) for (key, value) in members.items(): - check_name(expr_info, "Member of union '%s'" % name, key) + check_name(info, "Member of union '%s'" % name, key) # Each value must name a known type - check_type(expr_info, "Member '%s' of union '%s'" % (key, name), + check_type(info, "Member '%s' of union '%s'" % (key, name), value, allow_array=not base, allow_metas=allow_metas) # If the discriminator names an enum type, then all members # of 'data' must also be members of the enum type. if enum_define: if key not in enum_define['enum_values']: - raise QAPIExprError(expr_info, + raise QAPILineError(info, "Discriminator value '%s' is not found in " "enum '%s'" % (key, enum_define["enum_name"]))
@@ -624,64 +624,64 @@ def check_union(expr, expr_info): if enum_define: for value in enum_define['enum_values']: if value not in members.keys(): - raise QAPIExprError(expr_info, + raise QAPILineError(info, "Union '%s' data missing '%s' branch" % (name, value)) -def check_alternate(expr, expr_info): +def check_alternate(expr, info): name = expr['alternate'] members = expr['data'] types_seen = {} # Check every branch; require at least two branches if len(members) < 2: - raise QAPIExprError(expr_info, + raise QAPILineError(info, "Alternate '%s' should have at least two branches " "in 'data'" % name) for (key, value) in members.items(): - check_name(expr_info, "Member of alternate '%s'" % name, key) + check_name(info, "Member of alternate '%s'" % name, key) # Ensure alternates have no type conflicts. - check_type(expr_info, "Member '%s' of alternate '%s'" % (key, name), + check_type(info, "Member '%s' of alternate '%s'" % (key, name), value, allow_metas=['built-in', 'union', 'struct', 'enum']) qtype = find_alternate_member_qtype(value) if not qtype: - raise QAPIExprError(expr_info, + raise QAPILineError(info, "Alternate '%s' member '%s' cannot use " "type '%s'" % (name, key, value)) if qtype in types_seen: - raise QAPIExprError(expr_info, + raise QAPILineError(info, "Alternate '%s' member '%s' can't " "be distinguished from member '%s'" % (name, key, types_seen[qtype])) types_seen[qtype] = key -def check_enum(expr, expr_info): +def check_enum(expr, info): name = expr['enum'] members = expr.get('data') prefix = expr.get('prefix') if not isinstance(members, list): - raise QAPIExprError(expr_info, + raise QAPILineError(info, "Enum '%s' requires an array for 'data'" % name) if prefix is not None and not isinstance(prefix, str): - raise QAPIExprError(expr_info, + raise QAPILineError(info, "Enum '%s' requires a string for 'prefix'" % name) for member in members: - check_name(expr_info, "Member of enum '%s'" % name, member, + check_name(info, "Member of enum '%s'" % name, member, enum_member=True) -def check_struct(expr, expr_info): +def check_struct(expr, info): name = expr['struct'] members = expr['data'] - check_type(expr_info, "'data' for struct '%s'" % name, members, + check_type(info, "'data' for struct '%s'" % name, members, allow_dict=True, allow_optional=True) - check_type(expr_info, "'base' for struct '%s'" % name, expr.get('base'), + check_type(info, "'base' for struct '%s'" % name, expr.get('base'), allow_metas=['struct'])
@@ -690,25 +690,25 @@ def check_keys(expr_elem, meta, required, optional=[]): info = expr_elem['info'] name = expr[meta] if not isinstance(name, str): - raise QAPIExprError(info, + raise QAPILineError(info, "'%s' key must have a string value" % meta) required = required + [meta] for (key, value) in expr.items(): if key not in required and key not in optional: - raise QAPIExprError(info, + raise QAPILineError(info, "Unknown key '%s' in %s '%s'" % (key, meta, name)) if (key == 'gen' or key == 'success-response') and value is not False: - raise QAPIExprError(info, + raise QAPILineError(info, "'%s' of %s '%s' should only use false value" % (key, meta, name)) if key == 'boxed' and value is not True: - raise QAPIExprError(info, + raise QAPILineError(info, "'%s' of %s '%s' should only use true value" % (key, meta, name)) for key in required: if key not in expr: - raise QAPIExprError(info, + raise QAPILineError(info, "Key '%s' is missing from %s '%s'" % (key, meta, name))
@@ -743,7 +743,7 @@ def check_exprs(exprs): check_keys(expr_elem, 'event', [], ['data', 'boxed']) add_name(expr['event'], info, 'event') else: - raise QAPIExprError(expr_elem['info'], + raise QAPILineError(expr_elem['info'], "Expression is missing metatype") # Try again for hidden UnionKind enum
@@ -978,7 +978,7 @@ class QAPISchemaObjectType(QAPISchemaType): def check(self, schema): if self.members is False: # check for cycles - raise QAPIExprError(self.info, + raise QAPILineError(self.info, "Object %s contains itself" % self.name) if self.members: return
@@ -1051,10 +1051,10 @@ class QAPISchemaMember(object): def check_clash(self, info, seen): cname = c_name(self.name) if cname.lower() != cname and self.owner not in case_whitelist: - raise QAPIExprError(info, + raise QAPILineError(info, "%s should not use uppercase" % self.describe()) if cname in seen: - raise QAPIExprError(info, + raise QAPILineError(info, "%s collides with %s" % (self.describe(), seen[cname].describe())) seen[cname] = self
@@ -1201,13 +1201,13 @@ class QAPISchemaCommand(QAPISchemaEntity): self.arg_type.check(schema) if self.boxed: if self.arg_type.is_empty(): - raise QAPIExprError(self.info, + raise QAPILineError(self.info, "Cannot use 'boxed' with empty type") else: assert not isinstance(self.arg_type, QAPISchemaAlternateType) assert not self.arg_type.variants elif self.boxed: - raise QAPIExprError(self.info, + raise QAPILineError(self.info, "Use of 'boxed' requires 'data'") if self._ret_type_name: self.ret_type = schema.lookup_type(self._ret_type_name)
@@ -1235,13 +1235,13 @@ class QAPISchemaEvent(QAPISchemaEntity): self.arg_type.check(schema) if self.boxed: if self.arg_type.is_empty(): - raise QAPIExprError(self.info, + raise QAPILineError(self.info, "Cannot use 'boxed' with empty type") else: assert not isinstance(self.arg_type, QAPISchemaAlternateType) assert not self.arg_type.variants elif self.boxed: - raise QAPIExprError(self.info, + raise QAPILineError(self.info, "Use of 'boxed' requires 'data'") def visit(self, visitor):
@@ -1258,7 +1258,7 @@ class QAPISchema(object): self._predefining = False self._def_exprs() self.check() - except (QAPISchemaError, QAPIExprError) as err: + except (QAPISchemaError, QAPILineError) as err: print >>sys.stderr, err exit(1)
Signature · 1 line
2.10.0
Re: [Qemu-devel] [PATCH v5 12/17] qapi: rename QAPIExprError/QAPILineError
Make the summary line "qapi: Rename QAPIExprError to QAPILineError".
Quoted 18 lines · Marc-André Lureau
There is nothing specific about expressions in this exception, the following patch will use it without expressions.
Signed-off-by Marc-André Lureau <[email protected]>--- scripts/qapi.py | 146 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 73 insertions(+), 73 deletions(-)scripts/qapi.py +0
-2@@ -110,11 +110,11 @@ class QAPISchemaError(Exception): "%s:%d:%d: %s" % (self.fname, self.line, self.col, self.msg) -class QAPIExprError(Exception): - def __init__(self, expr_info, msg):
scripts/qapi.py class QAPISchemaError(Exception): · line 120
Quoted 10 lines
scripts/qapi.py +4
-2+class QAPILineError(Exception): + def __init__(self, info, msg): Exception.__init__(self) - assert expr_info - self.info = expr_info + assert info + self.info = info self.msg = msg def __str__(self):
Since we're talking about misnamed / awkward error stuff:
* QAPISchemaError is really a parse error. __init__()'s schema argument isn't a QAPISchema, it's a QAPISchemaParser.
* Method __str__() is mostly duplicated.
How do you like the following untested sketch?
class QAPISchemaError(Exception):
def __init__(self, fname, line, col, incl_info, msg):
Exception.__init__(self)
self.fname = fname
self.line = line
self.col = col
self.info = incl_info
self.msg = msg
def __str__(self):
loc = "%s:%d" % (self.fname, self.line)
if self.col is not None:
loc += ":%s" % self.col
return error_path(self.info) + \
"%s: %s" % (loc, self.msg)
class QAPISchemaParseError(QAPISchemaError):
def __init__(self, parser, msg):
col = 1
for ch in parser.src[parser.line_pos:parser.pos]:
if ch == '\t':
col = (col + 7) % 8 + 1
else:
col += 1
QAPISchemaError.__init__(self, parser.fname, parser.line, parser.col,
parser.incl_info, msg)
class QAPISchemaSemanticError(Exception):
def __init__(self, info, msg):
QAPISchemaError(self, info['file'], info['line'], None,
info['parent'], msg)The class names are a bit long. If they result in awkward line breaks, let's shorten them some.
The "except (QAPISchemaError, QAPIExprError)" become just "except QAPISchemaError".
Could QAPISchemaParser.__init__() raise QAPISchemaParseError instead?
[...]
Re: [Qemu-devel] [PATCH v5 12/17] qapi: rename QAPIExprError/QAPILineError
----- Original Message -----
Quoted 2 lines
Make the summary line "qapi: Rename QAPIExprError to QAPILineError".
ok
Quoted 34 lines
Quoted 19 lines · Marc-André Lureau
There is nothing specific about expressions in this exception, the following patch will use it without expressions.
Signed-off-by Marc-André Lureau <[email protected]>--- scripts/qapi.py | 146 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 73 insertions(+), 73 deletions(-)scripts/qapi.py +0
-2@@ -110,11 +110,11 @@ class QAPISchemaError(Exception): "%s:%d:%d: %s" % (self.fname, self.line, self.col, self.msg) -class QAPIExprError(Exception): - def __init__(self, expr_info, msg):scripts/qapi.py class QAPISchemaError(Exception): · line 120
Quoted 10 lines
scripts/qapi.py +4
-2+class QAPILineError(Exception): + def __init__(self, info, msg): Exception.__init__(self) - assert expr_info - self.info = expr_info + assert info + self.info = info self.msg = msg def __str__(self):Since we're talking about misnamed / awkward error stuff:
Quoted 6 lines
* QAPISchemaError is really a parse error. __init__()'s schema argument isn't a QAPISchema, it's a QAPISchemaParser.
* Method
__str__()is mostly duplicated.How do you like the following untested sketch?
I like it, though I would consider it separately from this series. Here I systematically renamed the existing class ("line" since it's about location in file), your proposed change has more implications I don't really want to get into here.
Quoted 46 lines
class QAPISchemaError(Exception): def __init__(self, fname, line, col, incl_info, msg): Exception.__init__(self) self.fname = fname self.line = line self.col = col self.info = incl_info self.msg = msg def __str__(self): loc = "%s:%d" % (self.fname, self.line) if self.col is not None: loc += ":%s" % self.col return error_path(self.info) + \ "%s: %s" % (loc, self.msg) class QAPISchemaParseError(QAPISchemaError): def __init__(self, parser, msg): col = 1 for ch in parser.src[parser.line_pos:parser.pos]: if ch == '\t': col = (col + 7) % 8 + 1 else: col += 1 QAPISchemaError.__init__(self, parser.fname, parser.line, parser.col, parser.incl_info, msg) class QAPISchemaSemanticError(Exception): def __init__(self, info, msg): QAPISchemaError(self, info['file'], info['line'], None, info['parent'], msg)The class names are a bit long. If they result in awkward line breaks, let's shorten them some.
The "except (QAPISchemaError, QAPIExprError)" become just "except QAPISchemaError".
Could
QAPISchemaParser.__init__()raise QAPISchemaParseError instead?[...]
Re: [Qemu-devel] [PATCH v5 12/17] qapi: rename QAPIExprError/QAPILineError
Quoted 40 lines · Marc-André Lureau
----- Original Message -----
Quoted 2 lines
Make the summary line "qapi: Rename QAPIExprError to QAPILineError".
ok
Quoted 34 lines
Quoted 19 lines · Marc-André Lureau
There is nothing specific about expressions in this exception, the following patch will use it without expressions.
Signed-off-by Marc-André Lureau <[email protected]>--- scripts/qapi.py | 146 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 73 insertions(+), 73 deletions(-)scripts/qapi.py +0
-2@@ -110,11 +110,11 @@ class QAPISchemaError(Exception): "%s:%d:%d: %s" % (self.fname, self.line, self.col, self.msg) -class QAPIExprError(Exception): - def __init__(self, expr_info, msg):scripts/qapi.py class QAPISchemaError(Exception): · line 120
Quoted 10 lines
scripts/qapi.py +4
-2+class QAPILineError(Exception): + def __init__(self, info, msg): Exception.__init__(self) - assert expr_info - self.info = expr_info + assert info + self.info = info self.msg = msg def __str__(self):Since we're talking about misnamed / awkward error stuff:
Quoted 8 lines
Quoted 6 lines
* QAPISchemaError is really a parse error. __init__()'s schema argument isn't a QAPISchema, it's a QAPISchemaParser.
* Method
__str__()is mostly duplicated.How do you like the following untested sketch?
I like it, though I would consider it separately from this series.
Punting ideas we both like to later series is fair. But when we intend to rework the error classes later, renaming one of them now is perhaps not worth the churn.
Quoted 3 lines
Here I systematically renamed the existing class ("line" since it's about location in file), your proposed change has more implications I don't really want to get into here.
Well, QAPISchemaError is just as much about "location in file" as QAPIExprError. They just specify the location differently: one by reference to the parser's current location, and the other by an "info" dictionary.
[...]
PATCH v5 13/17 qapi: add qapi2texi script
In reply to Marc-André LureauAs the name suggests, the qapi2texi script converts JSON QAPI description into a texi file suitable for different target formats (info/man/txt/pdf/html...).
It parses the following kind of blocks:
Free-form:
##
# = Section
# == Subsection
#
# Some text foo with *emphasis*
# 1. with a list
# 2. like that
#
# And some code:
# | $ echo foo # | -> do this # | <- get that
#
##
Symbol:
##
# @symbol:
#
# Symbol body ditto ergo sum. Foo bar
# baz ding.
#
# @arg: foo
# @arg: #optional foo
#
# Returns: returns bla bla
# Or bla blah
#
# Since: version
# Notes: notes, comments can have
# - itemized list
# - like this
#
# Example:
#
# -> { "execute": "quit" }
# <- { "return": {} }
#
##That's roughly following the following EBNF grammar:
api_comment = "##\n" comment "##\n"
comment = freeform_comment | symbol_commentfreeform_comment = { "# " text "\n" | "#\n" }symbol_comment = "# @" name ":\n" { member | meta | freeform_comment }
member = "# @" name ':' [ text ] freeform_comment
meta = "# " ( "Returns:", "Since:", "Note:", "Notes:", "Example:", "Examples:" ) [ text ] freeform_comment text = free-text markdown-like, "#optional" for members
Thanks to the following json expressions, the documentation is enhanced with extra information about the type of arguments and return value expected.
--- tests/Makefile.include | 17 ++ scripts/qapi.py | 215 ++++++++++++++++- scripts/qapi2texi.py | 331 +++++++++++++++++++++++++++ docs/qapi-code-gen.txt | 54 ++++- tests/qapi-schema/doc-bad-args.err | 1 + tests/qapi-schema/doc-bad-args.exit | 1 + tests/qapi-schema/doc-bad-args.json | 6 + tests/qapi-schema/doc-bad-args.out | 0 tests/qapi-schema/doc-bad-symbol.err | 1 + tests/qapi-schema/doc-bad-symbol.exit | 1 + tests/qapi-schema/doc-bad-symbol.json | 4 + tests/qapi-schema/doc-bad-symbol.out | 0 tests/qapi-schema/doc-duplicated-arg.err | 1 + tests/qapi-schema/doc-duplicated-arg.exit | 1 + tests/qapi-schema/doc-duplicated-arg.json | 5 + tests/qapi-schema/doc-duplicated-arg.out | 0 tests/qapi-schema/doc-duplicated-return.err | 1 + tests/qapi-schema/doc-duplicated-return.exit | 1 + tests/qapi-schema/doc-duplicated-return.json | 6 + tests/qapi-schema/doc-duplicated-return.out | 0 tests/qapi-schema/doc-duplicated-since.err | 1 + tests/qapi-schema/doc-duplicated-since.exit | 1 + tests/qapi-schema/doc-duplicated-since.json | 6 + tests/qapi-schema/doc-duplicated-since.out | 0 tests/qapi-schema/doc-empty-arg.err | 1 + tests/qapi-schema/doc-empty-arg.exit | 1 + tests/qapi-schema/doc-empty-arg.json | 4 + tests/qapi-schema/doc-empty-arg.out | 0 tests/qapi-schema/doc-empty-section.err | 1 + tests/qapi-schema/doc-empty-section.exit | 1 + tests/qapi-schema/doc-empty-section.json | 6 + tests/qapi-schema/doc-empty-section.out | 0 tests/qapi-schema/doc-empty-symbol.err | 1 + tests/qapi-schema/doc-empty-symbol.exit | 1 + tests/qapi-schema/doc-empty-symbol.json | 3 + tests/qapi-schema/doc-empty-symbol.out | 0 tests/qapi-schema/doc-invalid-end.err | 1 + tests/qapi-schema/doc-invalid-end.exit | 1 + tests/qapi-schema/doc-invalid-end.json | 3 + tests/qapi-schema/doc-invalid-end.out | 0 tests/qapi-schema/doc-invalid-end2.err | 1 + tests/qapi-schema/doc-invalid-end2.exit | 1 + tests/qapi-schema/doc-invalid-end2.json | 3 + tests/qapi-schema/doc-invalid-end2.out | 0 tests/qapi-schema/doc-invalid-return.err | 1 + tests/qapi-schema/doc-invalid-return.exit | 1 + tests/qapi-schema/doc-invalid-return.json | 5 + tests/qapi-schema/doc-invalid-return.out | 0 tests/qapi-schema/doc-invalid-section.err | 1 + tests/qapi-schema/doc-invalid-section.exit | 1 + tests/qapi-schema/doc-invalid-section.json | 4 + tests/qapi-schema/doc-invalid-section.out | 0 tests/qapi-schema/doc-invalid-start.err | 1 + tests/qapi-schema/doc-invalid-start.exit | 1 + tests/qapi-schema/doc-invalid-start.json | 3 + tests/qapi-schema/doc-invalid-start.out | 0 tests/qapi-schema/doc-missing-expr.err | 1 + tests/qapi-schema/doc-missing-expr.exit | 1 + tests/qapi-schema/doc-missing-expr.json | 3 + tests/qapi-schema/doc-missing-expr.out | 0 tests/qapi-schema/doc-missing-space.err | 1 + tests/qapi-schema/doc-missing-space.exit | 1 + tests/qapi-schema/doc-missing-space.json | 4 + tests/qapi-schema/doc-missing-space.out | 0 tests/qapi-schema/qapi-schema-test.json | 58 +++++ tests/qapi-schema/qapi-schema-test.out | 49 ++++ tests/qapi-schema/test-qapi.py | 12 + 67 files changed, 817 insertions(+), 14 deletions(-) create mode 100755 scripts/qapi2texi.py create mode 100644 tests/qapi-schema/doc-bad-args.err create mode 100644 tests/qapi-schema/doc-bad-args.exit create mode 100644 tests/qapi-schema/doc-bad-args.json create mode 100644 tests/qapi-schema/doc-bad-args.out create mode 100644 tests/qapi-schema/doc-bad-symbol.err create mode 100644 tests/qapi-schema/doc-bad-symbol.exit create mode 100644 tests/qapi-schema/doc-bad-symbol.json create mode 100644 tests/qapi-schema/doc-bad-symbol.out create mode 100644 tests/qapi-schema/doc-duplicated-arg.err create mode 100644 tests/qapi-schema/doc-duplicated-arg.exit create mode 100644 tests/qapi-schema/doc-duplicated-arg.json create mode 100644 tests/qapi-schema/doc-duplicated-arg.out create mode 100644 tests/qapi-schema/doc-duplicated-return.err create mode 100644 tests/qapi-schema/doc-duplicated-return.exit create mode 100644 tests/qapi-schema/doc-duplicated-return.json create mode 100644 tests/qapi-schema/doc-duplicated-return.out create mode 100644 tests/qapi-schema/doc-duplicated-since.err create mode 100644 tests/qapi-schema/doc-duplicated-since.exit create mode 100644 tests/qapi-schema/doc-duplicated-since.json create mode 100644 tests/qapi-schema/doc-duplicated-since.out create mode 100644 tests/qapi-schema/doc-empty-arg.err create mode 100644 tests/qapi-schema/doc-empty-arg.exit create mode 100644 tests/qapi-schema/doc-empty-arg.json create mode 100644 tests/qapi-schema/doc-empty-arg.out create mode 100644 tests/qapi-schema/doc-empty-section.err create mode 100644 tests/qapi-schema/doc-empty-section.exit create mode 100644 tests/qapi-schema/doc-empty-section.json create mode 100644 tests/qapi-schema/doc-empty-section.out create mode 100644 tests/qapi-schema/doc-empty-symbol.err create mode 100644 tests/qapi-schema/doc-empty-symbol.exit create mode 100644 tests/qapi-schema/doc-empty-symbol.json create mode 100644 tests/qapi-schema/doc-empty-symbol.out create mode 100644 tests/qapi-schema/doc-invalid-end.err create mode 100644 tests/qapi-schema/doc-invalid-end.exit create mode 100644 tests/qapi-schema/doc-invalid-end.json create mode 100644 tests/qapi-schema/doc-invalid-end.out create mode 100644 tests/qapi-schema/doc-invalid-end2.err create mode 100644 tests/qapi-schema/doc-invalid-end2.exit create mode 100644 tests/qapi-schema/doc-invalid-end2.json create mode 100644 tests/qapi-schema/doc-invalid-end2.out create mode 100644 tests/qapi-schema/doc-invalid-return.err create mode 100644 tests/qapi-schema/doc-invalid-return.exit create mode 100644 tests/qapi-schema/doc-invalid-return.json create mode 100644 tests/qapi-schema/doc-invalid-return.out create mode 100644 tests/qapi-schema/doc-invalid-section.err create mode 100644 tests/qapi-schema/doc-invalid-section.exit create mode 100644 tests/qapi-schema/doc-invalid-section.json create mode 100644 tests/qapi-schema/doc-invalid-section.out create mode 100644 tests/qapi-schema/doc-invalid-start.err create mode 100644 tests/qapi-schema/doc-invalid-start.exit create mode 100644 tests/qapi-schema/doc-invalid-start.json create mode 100644 tests/qapi-schema/doc-invalid-start.out create mode 100644 tests/qapi-schema/doc-missing-expr.err create mode 100644 tests/qapi-schema/doc-missing-expr.exit create mode 100644 tests/qapi-schema/doc-missing-expr.json create mode 100644 tests/qapi-schema/doc-missing-expr.out create mode 100644 tests/qapi-schema/doc-missing-space.err create mode 100644 tests/qapi-schema/doc-missing-space.exit create mode 100644 tests/qapi-schema/doc-missing-space.json create mode 100644 tests/qapi-schema/doc-missing-space.out
tests/Makefile.include +17 -0
@@ -350,6 +350,21 @@ qapi-schema += base-cycle-direct.json qapi-schema += base-cycle-indirect.json qapi-schema += command-int.json qapi-schema += comments.json +qapi-schema += doc-bad-args.json +qapi-schema += doc-bad-symbol.json +qapi-schema += doc-duplicated-arg.json +qapi-schema += doc-duplicated-return.json +qapi-schema += doc-duplicated-since.json +qapi-schema += doc-empty-arg.json +qapi-schema += doc-empty-section.json +qapi-schema += doc-empty-symbol.json +qapi-schema += doc-invalid-end.json +qapi-schema += doc-invalid-end2.json +qapi-schema += doc-invalid-return.json +qapi-schema += doc-invalid-section.json +qapi-schema += doc-invalid-start.json +qapi-schema += doc-missing-expr.json +qapi-schema += doc-missing-space.json qapi-schema += double-data.json qapi-schema += double-type.json qapi-schema += duplicate-key.json
@@ -443,6 +458,8 @@ qapi-schema += union-optional-branch.json qapi-schema += union-unknown.json qapi-schema += unknown-escape.json qapi-schema += unknown-expr-key.json + + check-qapi-schema-y := $(addprefix tests/qapi-schema/, $(qapi-schema)) GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h \
scripts/qapi.py +211 -4
281 lines not on this page · raw message
scripts/qapi2texi.py new file +331 -0
331 lines not on this page · raw message
docs/qapi-code-gen.txt +44 -10
72 lines not on this page · raw message
tests/qapi-schema/doc-bad-args.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-bad-args.json:1: Members documentation is not a subset of API ['a', 'b'] > ['a']
tests/qapi-schema/doc-bad-args.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-bad-args.json new file +6 -0
@@ -0,0 +1,6 @@ +## +# @foo: +# @a: a +# @b: b +## +{ 'command': 'foo', 'data': {'a': 'int'} }
tests/qapi-schema/doc-bad-args.out new file +0 -0
tests/qapi-schema/doc-bad-symbol.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-bad-symbol.json:1: Definition of 'foo' follows documentation for 'food'
tests/qapi-schema/doc-bad-symbol.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-bad-symbol.json new file +4 -0
@@ -0,0 +1,4 @@ +## +# @food: +## +{ 'command': 'foo', 'data': {'a': 'int'} }
tests/qapi-schema/doc-bad-symbol.out new file +0 -0
tests/qapi-schema/doc-duplicated-arg.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-duplicated-arg.json:4:1: 'a' arg duplicated
tests/qapi-schema/doc-duplicated-arg.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-duplicated-arg.json new file +5 -0
@@ -0,0 +1,5 @@ +## +# @foo: +# @a: +# @a: +##
tests/qapi-schema/doc-duplicated-arg.out new file +0 -0
tests/qapi-schema/doc-duplicated-return.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-duplicated-return.json:5:1: Duplicated 'Returns' section
tests/qapi-schema/doc-duplicated-return.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-duplicated-return.json new file +6 -0
@@ -0,0 +1,6 @@ +## +# @foo: +# +# Returns: 0 +# Returns: 1 +##
tests/qapi-schema/doc-duplicated-return.out new file +0 -0
tests/qapi-schema/doc-duplicated-since.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-duplicated-since.json:5:1: Duplicated 'Since' section
tests/qapi-schema/doc-duplicated-since.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-duplicated-since.json new file +6 -0
@@ -0,0 +1,6 @@ +## +# @foo: +# +# Since: 0 +# Since: 1 +##
tests/qapi-schema/doc-duplicated-since.out new file +0 -0
tests/qapi-schema/doc-empty-arg.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-empty-arg.json:3:1: Invalid argument name
tests/qapi-schema/doc-empty-arg.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-empty-arg.json new file +4 -0
@@ -0,0 +1,4 @@ +## +# @foo: +# @: +##
tests/qapi-schema/doc-empty-arg.out new file +0 -0
tests/qapi-schema/doc-empty-section.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-empty-section.json:1: Empty doc section 'Note'
tests/qapi-schema/doc-empty-section.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-empty-section.json new file +6 -0
@@ -0,0 +1,6 @@ +## +# @foo: +# +# Note: +## +{ 'command': 'foo', 'data': {'a': 'int'} }
tests/qapi-schema/doc-empty-section.out new file +0 -0
tests/qapi-schema/doc-empty-symbol.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-empty-symbol.json:2:1: Invalid symbol
tests/qapi-schema/doc-empty-symbol.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-empty-symbol.json new file +3 -0
@@ -0,0 +1,3 @@ +## +# @: +##
tests/qapi-schema/doc-empty-symbol.out new file +0 -0
tests/qapi-schema/doc-invalid-end.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-end.json:3:2: Documentation comment must end with '##'
tests/qapi-schema/doc-invalid-end.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-invalid-end.json new file +3 -0
@@ -0,0 +1,3 @@ +## +# An invalid comment +#
tests/qapi-schema/doc-invalid-end.out new file +0 -0
tests/qapi-schema/doc-invalid-end2.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-end2.json:3:1: Junk after '##' at end of documentation comment
tests/qapi-schema/doc-invalid-end2.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-invalid-end2.json new file +3 -0
@@ -0,0 +1,3 @@ +## +# +## invalid
tests/qapi-schema/doc-invalid-end2.out new file +0 -0
tests/qapi-schema/doc-invalid-return.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-return.json:1: Invalid return documentation
tests/qapi-schema/doc-invalid-return.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-invalid-return.json new file +5 -0
@@ -0,0 +1,5 @@ +## +# @foo: +# Returns: blah +## +{ 'event': 'foo' }
tests/qapi-schema/doc-invalid-return.out new file +0 -0
tests/qapi-schema/doc-invalid-section.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-section.json:1: Document body cannot contain @NAME: sections
tests/qapi-schema/doc-invalid-section.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-invalid-section.json new file +4 -0
@@ -0,0 +1,4 @@ +## +# freeform +# @note: foo +##
tests/qapi-schema/doc-invalid-section.out new file +0 -0
tests/qapi-schema/doc-invalid-start.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-start.json:1:1: Junk after '##' at start of documentation comment
tests/qapi-schema/doc-invalid-start.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-invalid-start.json new file +3 -0
@@ -0,0 +1,3 @@ +## invalid +# +##
tests/qapi-schema/doc-invalid-start.out new file +0 -0
tests/qapi-schema/doc-missing-expr.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-missing-expr.json:1: 'bar' documention is not followed by the definition
tests/qapi-schema/doc-missing-expr.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-missing-expr.json new file +3 -0
@@ -0,0 +1,3 @@ +## +# @bar: +##
tests/qapi-schema/doc-missing-expr.out new file +0 -0
tests/qapi-schema/doc-missing-space.err new file +1 -0
@@ -0,0 +1 @@ +tests/qapi-schema/doc-missing-space.json:3:1: missing space after #
tests/qapi-schema/doc-missing-space.exit new file +1 -0
@@ -0,0 +1 @@ +1
tests/qapi-schema/doc-missing-space.json new file +4 -0
@@ -0,0 +1,4 @@ +## +# missing space: +#wef +##
tests/qapi-schema/doc-missing-space.out new file +0 -0
tests/qapi-schema/qapi-schema-test.json +58 -0
70 lines not on this page · raw message
tests/qapi-schema/qapi-schema-test.out +49 -0
52 lines not on this page · raw message
tests/qapi-schema/test-qapi.py +12 -0
@@ -55,3 +55,15 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): schema = QAPISchema(sys.argv[1]) schema.visit(QAPISchemaTestVisitor()) + +for doc in schema.docs: + if doc.symbol: + print 'doc symbol=%s expr=%s' % \ + (doc.symbol, doc.expr.items()[0]) + else: + print 'doc freeform' + for arg, section in doc.args.iteritems(): + print ' arg=%s\n%s' % (arg, section) + for section in doc.meta: + print ' meta=%s\n%s' % (section.name, section) + print ' body=\n%s' % doc.body
Signature · 1 line
2.10.0
Re: [Qemu-devel] [PATCH v5 13/17] qapi: add qapi2texi script
Quoted 25 lines · Marc-André Lureau
As the name suggests, the qapi2texi script converts JSON QAPI description into a texi file suitable for different target formats (info/man/txt/pdf/html...).
It parses the following kind of blocks:
Free-form:
##
# = Section
# == Subsection
#
# Some text foo with *emphasis*
# 1. with a list
# 2. like that
#
# And some code:# | $ echo foo # | -> do this # | <- get that#
##Symbol:
Quoted 8 lines
##
# @symbol:
#
# Symbol body ditto ergo sum. Foo bar# baz ding. # # @arg: foo # @arg: #optional foo
Let's not use @arg twice.
Terminology: I prefer to use "parameter" for formal parameters, and "argument" for actual arguments. This matches how The Python Language Reference uses the terms.
What about
# @param1: the frob to frobnicate
# @param2: #optional how hard to frobnicate
Quoted 3 lines
#
# Returns: returns bla bla
# Or bla blah
Repeating "returns" is awkward, and we don't do that in our schemas.
We need a period before "Or", or spell it "or".
What about
# Returns: the frobnicated frob.
# If frob isn't frobnicatable, GenericError.
Quoted 13 lines
#
# Since: version
# Notes: notes, comments can have
# - itemized list
# - like this
#
# Example:
#
# -> { "execute": "quit" }
# <- { "return": {} }
#
##
Quoted 6 lines
That's roughly following the following EBNF grammar:
api_comment= "##\n" comment "##\n"
comment =freeform_comment|symbol_commentfreeform_comment= { "# " text "\n" | "#\n" }symbol_comment= "# @" name ":\n" { member | meta |freeform_comment}
Rejects non-empty comments where "#" is not followed by space. Such usage is accepted outside doc comments. Hmm.
Quoted 1 line
member = "# @" name ':' [ text ]
freeform_comment
Are you missing a "\n" before freeform_comment?
Quoted 1 line
meta = "# " ( "Returns:", "Since:", "Note:", "Notes:", "Example:", "Examples:" ) [ text ]
freeform_comment
Likewise.
Quoted 1 line
text = free-text markdown-like, "#optional" for members
The grammar is ambiguous: a line "# @foo:\n" can be parsed both as freeform_comment and as symbol_comment. Since your intent is obvious enough, it can still serve as documentation. It's not a suitable foundation for parsing, though. Okay for a commit message.
Quoted 3 lines
Thanks to the following json expressions, the documentation is enhanced with extra information about the type of arguments and return value expected.
I guess you want to say that we enrich the documentation we extract from comments with information from the actual schema. Correct?
Missing: a brief discussion of deficiencies. These include:
* The generated QMP documentation includes internal types
We use qapi-schema.json both for defining the external QMP interface and for defining internal types. qmp-introspect.py carefully separates the two, to not expose internal types. qapi2texi.py happily exposes everything.
Currently, about a fifth of the types in the generated docs are internal:
AcpiTableOptions
BiosAtaTranslation
BlockDeviceMapEntry
COLOMessage
COLOMode
DummyForceArrays
FailoverStatus
FloppyDriveType
ImageCheck
LostTickPolicy
MapEntry
MigrationParameter
NetClientDriver
NetFilterDirection
NetLegacy
NetLegacyNicOptions
NetLegacyOptions
NetLegacyOptionsKind
Netdev
NetdevBridgeOptions
NetdevDumpOptions
NetdevHubPortOptions
NetdevL2TPv3Options
NetdevNetmapOptions
NetdevNoneOptions
NetdevSocketOptions
NetdevTapOptions
NetdevUserOptions
NetdevVdeOptions
NetdevVhostUserOptions
NumaNodeOptions
NumaOptions
NumaOptionsKind
OnOffAuto
OnOffSplit
PreallocMode
QCryptoBlockCreateOptions
QCryptoBlockCreateOptionsLUKS
QCryptoBlockFormat
QCryptoBlockInfo
QCryptoBlockInfoBase
QCryptoBlockInfoQCow
QCryptoBlockOpenOptions
QCryptoBlockOptionsBase
QCryptoBlockOptionsLUKS
QCryptoBlockOptionsQCow
QCryptoSecretFormat
QCryptoTLSCredsEndpoint
QapiErrorClass
ReplayMode
X86CPUFeatureWordInfo
X86CPURegister32
Generating documentation for internal types might be useful, but letting them pollute QMP interface documentation isn't. Needs fixing before we release. Until then, needs a FIXME comment in qapi2texi.py.
* Union support is lacking
The doc string language is adequate for documenting commands, events, and non-union types. It doesn't really handle union variants. Hardly surprising, as you fitted the language do existing practice, and existing (mal-)practice is neglecting to document union variant members.
* Documentation is lacking
See review of qapi-code-gen.txt below.
* Doc comment error message positions are imprecise
They always point to the beginning of the comment.
* Probably more
We should update this with noteworthy findings during review. I tried, but I suspect I missed some.
Quoted 1 line
Signed-off-by Marc-André Lureau <[email protected]>
[Lengthy diffstat snipped...]
Quoted 41 lines
tests/Makefile.include +17
-0@@ -350,6 +350,21 @@ qapi-schema += base-cycle-direct.json qapi-schema += base-cycle-indirect.json qapi-schema += command-int.json qapi-schema += comments.json +qapi-schema += doc-bad-args.json +qapi-schema += doc-bad-symbol.json +qapi-schema += doc-duplicated-arg.json +qapi-schema += doc-duplicated-return.json +qapi-schema += doc-duplicated-since.json +qapi-schema += doc-empty-arg.json +qapi-schema += doc-empty-section.json +qapi-schema += doc-empty-symbol.json +qapi-schema += doc-invalid-end.json +qapi-schema += doc-invalid-end2.json +qapi-schema += doc-invalid-return.json +qapi-schema += doc-invalid-section.json +qapi-schema += doc-invalid-start.json +qapi-schema += doc-missing-expr.json +qapi-schema += doc-missing-space.json qapi-schema += double-data.json qapi-schema += double-type.json qapi-schema += duplicate-key.json@@ -443,6 +458,8 @@ qapi-schema += union-optional-branch.json qapi-schema += union-unknown.json qapi-schema += unknown-escape.json qapi-schema += unknown-expr-key.json + + check-qapi-schema-y := $(addprefix tests/qapi-schema/, $(qapi-schema)) GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h \scripts/qapi.py +0
-0
scripts/qapi.py class QAPILineError(Exception): · line 127
Quoted 6 lines
scripts/qapi.py +3
-0@@ -122,6 +122,109 @@ class QAPILineError(Exception): "%s:%d: %s" % (self.info['file'], self.info['line'], self.msg) +class QAPIDoc(object): + class Section(object): + def __init__(self, name=""):
name=None feels more natural than "" for an absent optional name.
scripts/qapi.py class QAPILineError(Exception): · line 130
Quoted 3 lines
scripts/qapi.py +3
-0+ # optional section name (argument/member or section name) + self.name = name + # the list of strings for this section
Would "list of lines" be more accurate, or less?
scripts/qapi.py class QAPILineError(Exception): · line 140
Quoted 10 lines
scripts/qapi.py +10
-0+ self.content = [] + + def append(self, line): + self.content.append(line) + + def __repr__(self): + return "\n".join(self.content).strip() + + class ArgSection(Section): + pass
Begs the question what makes ArgSection differ from Section. I think it's the semantics of self.name: an ArgSection's name is the parameter name, a non-ArgSection can either be a "meta" section (name is one of "Returns"", "Since", "Note", "Notes", "Example", "Examples") or an anonymous section (name is "").
scripts/qapi.py class QAPILineError(Exception): · line 146
Quoted 6 lines
scripts/qapi.py +6
-0+ + def __init__(self, parser): + self.parser = parser + self.symbol = None + self.body = QAPIDoc.Section() + # a dict {'arg': ArgSection, ...}
Works. Alternatevely:
# dict mapping parameter name to ArgSection
scripts/qapi.py class QAPILineError(Exception): · line 152
Quoted 6 lines
scripts/qapi.py +6
-0+ self.args = OrderedDict() + # a list of Section + self.meta = [] + # the current section + self.section = self.body + # associated expression and info (set by expression parser)
"will be set by expression parser", or "to be set by expression parser"?
scripts/qapi.py class QAPILineError(Exception): · line 154
Quoted 2 lines
scripts/qapi.py +2
-0+ self.expr = None + self.info = None
Clearer now. The one remark I still have is on the use of "meta" isn't obvious here. I think a comment further up explaining the different kinds of sections would help.
To be honest, I don't get what's "meta" about the "meta" sections :)
scripts/qapi.py class QAPILineError(Exception): · line 157
Quoted 3 lines
scripts/qapi.py +3
-0+ + def has_meta(self, name): + """Returns True if the doc has a meta section 'name'"""
PEP257[1] demands imperative mood, and punctuation:
"""Return True if the doc has a meta section 'name'."""
Unfortunately, there seems to be no established convention for marking parameter names. You put this one in single quotes, which works here, but could be confusing in other cases. I'd sidestep it:
"""Return True if we have a meta section with this name."""
or
"""Does a meta section with this name exist?"""
scripts/qapi.py class QAPILineError(Exception): · line 164
Quoted 7 lines
scripts/qapi.py +7
-0+ for i in self.meta: + if i.name == name: + return True + return False + + def append(self, line): + """Adds a # comment line, to be parsed and added to current section"""
Imperative mood:
"""Add a comment line, to be parsed and added to the current section."""
However, we're not always adding to the current section, we can also start a new one. The following avoids suggesting anything about the current section:
"""Parse a comment line and add it to the documentation."""
When the function name is a verb, and its doc string starts with a different verb, the name might be suboptimal. Use your judgement.
If this one-liner is too terse, we can try a multi-line doc string:
"""Parse a comment line and add it to the documentation.
TODO should we tell more about how we parse?
Args:
line: the comment starting with '#', with the newline stripped.
Raises:
QAPISchemaError: TODO explain error conditions
"""
Format stolen from the Google Python Style Guide[2], because PEP257 is of not much help there.
Once you start with such elaborate doc strings, pressure will likely mount to do the same elsewhere. Could be a distraction right now. Use your judgement.
scripts/qapi.py class QAPILineError(Exception): · line 172
Quoted 8 lines
scripts/qapi.py +8
-0+ line = line[1:] + if not line: + self._append_freeform(line) + return + + if line[0] != ' ': + raise QAPISchemaError(self.parser, "missing space after #") + line = line[1:]
QAPISchemaError takes the error position from its QAPISchemaParser argument. In other words, the error position depends on the state of the parser when it calls this function. Turns out the position is the beginning of the comment. Servicable here. Action at a distance, though.
Less strict:
# strip leading # and space
line = line[1:]
if line[0] == ' ':
line = line[1:]Also avoids special-casing empty comments.
Perhaps we should treat all leading whitespace the same (I'm not sure):
# strip leading # and whitespace
line = line[1:]
line = line.lstrip()scripts/qapi.py class QAPILineError(Exception): · line 180
Quoted 8 lines
scripts/qapi.py +8
-0+ + if self.symbol: + self._append_symbol_line(line) + elif (not self.body.content and + line.startswith("@") and line.endswith(":")): + self.symbol = line[1:-1] + if not self.symbol: + raise QAPISchemaError(self.parser, "Invalid symbol")
Doesn't recognize the symbol when there's anything other than a single space between # and @. Pathological case: '#\t@foo:' starting in column 6 looks exactly like '# @foo:', but doesn't work. Fortunately, your code rejects the tab there. Assigning meaning to (leading) whitespace may make sense, but it must be documented clearly.
Doesn't recognize the symbol when there's crap after ":". Confusing when it's invisible crap, i.e. trailing whitespace. In general, it's best to parse left to right, like this:
elif not self.body.content and line.startswith('@'):
match = valid_name.match(line[1:]);
if not match:
raise QAPISchemaError(self.parser, 'Invalid name')
if line.startswith(':', match.end(0)):
raise QAPISchemaError(self.parser, 'Expected ":")
Here, the error position is clearly suboptimal: it's the beginning of the comment instead of where the actual error is, namely the beginning / the end of the name. More of the same below. The root cause is stacking parsers. I'm not asking you to do anything about it at this time.
Note my use of "name" rather than "symbol" in the error message. qapi-code-gen.txt talks about names, not symbols. Consistent use of terminology matters.
scripts/qapi.py class QAPILineError(Exception): · line 189
Quoted 9 lines
scripts/qapi.py +9
-0+ else: + self._append_freeform(line) + + def _append_symbol_line(self, line): + name = line.split(' ', 1)[0] + + if name.startswith("@") and name.endswith(":"): + line = line[len(name)+1:] + self._start_args_section(name[1:-1])
Similar issue. Left to right:
if re.match(r'\s*@', line):
match = valid_name.match(line[1:]);
if not match:
raise QAPISchemaError(self.parser, 'Invalid parameter name')
line = line[match.end(0):]
if line.startswith(':'):
raise QAPISchemaError(self.parser, 'Expected ":")
line = line[1:]
self._start_args_section(match.group(0))Even better would be factoring out the common code to parse '@foo:'.
scripts/qapi.py class QAPILineError(Exception): · line 195
Quoted 6 lines
scripts/qapi.py +6
-0+ elif name in ("Returns:", "Since:", + # those are often singular or plural + "Note:", "Notes:", + "Example:", "Examples:"): + line = line[len(name)+1:] + self._start_meta_section(name[:-1])
Since we're re.match()ing already, here's how do to it that way:
else
match = re.match(r'\s*(Returns|Since|Notes?|Examples?):', line)
if match:
line = line[match.end(0):]
self._start_meta_section(match.group(1))scripts/qapi.py class QAPILineError(Exception): · line 201
Quoted 6 lines
scripts/qapi.py +6
-0+ + self._append_freeform(line) + + def _start_args_section(self, name): + if not name: + raise QAPISchemaError(self.parser, "Invalid argument name")
parameter name
scripts/qapi.py class QAPILineError(Exception): · line 203
Quoted 2 lines
scripts/qapi.py +2
-0+ if name in self.args: + raise QAPISchemaError(self.parser, "'%s' arg duplicated" % name)
Duplicate parameter name
Quoted 4 lines
scripts/qapi.py +4
-0+ self.section = QAPIDoc.ArgSection(name) + self.args[name] = self.section + + def _start_meta_section(self, name):
scripts/qapi.py class QAPILineError(Exception): · line 217
Quoted 10 lines
scripts/qapi.py +10
-0+ if name in ("Returns", "Since") and self.has_meta(name): + raise QAPISchemaError(self.parser, + "Duplicated '%s' section" % name) + self.section = QAPIDoc.Section(name) + self.meta.append(self.section) + + def _append_freeform(self, line): + in_arg = isinstance(self.section, QAPIDoc.ArgSection) + if in_arg and self.section.content and not self.section.content[-1] \ + and line and not line[0].isspace():
PEP8[3] prefers parenthesises over backslash:
if (in_arg and self.section.content and not self.section.content[-1]
and line and not line[0].isspace()):
scripts/qapi.py class QAPILineError(Exception): · line 222
Quoted 5 lines
scripts/qapi.py +5
-0+ # an empty line followed by a non-indented + # comment ends the argument section + self.section = self.body + self._append_freeform(line) + return
Switching back to the self.body section like this reorders the documentation text. I still think this is a terrible idea. A dumb script is exceedingly unlikely to improve human-written doc comment text by reordering. In the rare case it does, the doc comment source should be reordered.
Here's an example where the doc generator happily creates unintelligible garbage if I format CpuDefinitionInfo's doc comment in a slightly off way:
##
# @CpuDefinitionInfo:
#
# Virtual CPU definition.
#
# @name: the name of the CPU definition
#
# @migration-safe: #optional whether a CPU definition can be safely # used for migration in combination with a QEMU compatibility # machine when migrating between different QMU versions and between # hosts with different sets of (hardware or software)
# capabilities.
#
# If not provided, information is not available and callers should # not assume the CPU definition to be migration-safe. (since 2.8) #
# @static: whether a CPU definition is static and will not change # depending on QEMU version, machine type, machine options and # accelerator options. A static model is always
# migration-safe. (since 2.8)
#
# @unavailable-features: #optional List of properties that prevent # the CPU model from running in the current host. (since 2.8) #
# @unavailable-features is a list of QOM property names that # represent CPU model attributes that prevent the CPU from running. # If the QOM property is read-only, that means there's no known # way to make the CPU model run in the current host. Implementations # that choose not to provide specific information return the # property name "type".
#
# If the property is read-write, it means that it MAY be possible # to run the CPU model in the current host if that property is # changed. Management software can use it as hints to suggest or # choose an alternative for the user, or just to generate meaningful # error messages explaining why the CPU model can't be used. # If @unavailable-features is an empty list, the CPU model is # runnable using the current host and machine-type.
# If @unavailable-features is not present, runnability
# information for the CPU is not available.
#
# Since: 1.2.0
##
{ 'struct': 'CpuDefinitionInfo',
'data': { 'name': 'str', '*migration-safe': 'bool', 'static': 'bool',
'*unavailable-features': [ 'str' ] } }
To detect the problem, you have to read the generated docs attentively. You know my opinion on our chances for that to happen during development.
My point is not that we should support this doc comment format. My point is that people could conceivably write something like it, and not get caught in patch review.
I can see three ways out of this swamp:
1. Let sections continue until another one begins.
2. Make text between sections an error.
3. When a section ends, start a new anonymous section.
Can't say offhand which one will work best.
scripts/qapi.py class QAPILineError(Exception): · line 224
Quoted 2 lines
scripts/qapi.py +2
-0+ if in_arg or not self.section.name.startswith("Example"): + line = line.strip()
Stripping whitespace is not "Markdown-like", because intendation carries meaning in Markdown. Example:
* First item in itemized list
* Second item
* Sub-item of second item
* Another sub-item
* Third item
Stripping whitespace destroys the list structure. If that's what you want, you get to document where your "Markdown-like" markup is unlike Markdown :)
Is there a technical reason for stripping whitespace?
See also discussion of space after # above.
Quoted 7 lines
scripts/qapi.py +3
-0+ self.section.append(line) + + class QAPISchemaParser(object): def __init__(self, fp, previously_included=[], incl_info=None):
scripts/qapi.py class QAPISchemaParser(object): · line 249
Quoted 10 lines
scripts/qapi.py +2
-0@@ -137,11 +240,18 @@ class QAPISchemaParser(object): self.line = 1 self.line_pos = 0 self.exprs = [] + self.docs = [] self.accept() while self.tok is not None: info = {'file': fname, 'line': self.line, 'parent': self.incl_info} + if self.tok == '#' and self.val.startswith('##'):
How can self.val *not* start with '##' here?
scripts/qapi.py class QAPISchemaParser(object): · line 251
Quoted 2 lines
scripts/qapi.py +2
-0+ doc = self.get_doc() + doc.info = info
Let's pass info as argument to get_doc(), so we don't have to dot into doc here. get_doc() can avoid dotting into doc by passing info to the constructor.
Quoted 16 lines
scripts/qapi.py +4
-0+ self.docs.append(doc) + continue + expr = self.get_expr(False) if isinstance(expr, dict) and "include" in expr: if len(expr) != 1:@@ -160,6 +270,7 @@ class QAPISchemaParser(object): raise QAPILineError(info, "Inclusion loop for %s" % include) inf = inf['parent'] + # skip multiple include of the same file if incl_abs_fname in previously_included: continue@@ -171,12 +282,38 @@ class QAPISchemaParser(object): exprs_include = QAPISchemaParser(fobj, previously_included,
scripts/qapi.py class QAPISchemaParser(object): · line 292
Quoted 10 lines
scripts/qapi.py +5
-0info) self.exprs.extend(exprs_include.exprs) + self.docs.extend(exprs_include.docs) else: expr_elem = {'expr': expr, 'info': info} + if self.docs and not self.docs[-1].expr: + self.docs[-1].expr = expr + expr_elem['doc'] = self.docs[-1] +
Attaches the expression to the last doc comment that doesn't already have one. A bit sloppy, because there could be non-doc comments in between, or the doc comment could be in another file. It'll do, at least for now.
Quoted 13 lines
scripts/qapi.py +10
-1self.exprs.append(expr_elem) - def accept(self): + def get_doc(self): + if self.val != '##': + raise QAPISchemaError(self, "Junk after '##' at start of " + "documentation comment") + + doc = QAPIDoc(self) + self.accept(False) + while self.tok == '#': + if self.val.startswith('##'): + # End of doc comment
scripts/qapi.py class QAPISchemaParser(object): · line 314
Quoted 10 lines
scripts/qapi.py +10
-0+ if self.val != '##': + raise QAPISchemaError(self, "Junk after '##' at end of " + "documentation comment") + self.accept() + return doc + else: + doc.append(self.val) + self.accept(False) + + raise QAPISchemaError(self, "Documentation comment must end with '##'")
Let's put this after accept, next to the other get_FOO().
Quoted 9 lines
scripts/qapi.py +2
-0+ + def accept(self, skip_comment=True): while True: self.tok = self.src[self.cursor] self.pos = self.cursor@@ -184,7 +321,13 @@ class QAPISchemaParser(object): self.val = None if self.tok == '#':
scripts/qapi.py class QAPISchemaParser(object): · line 333
Quoted 10 lines
scripts/qapi.py +6
-0+ if self.src[self.cursor] == '#': + # Start of doc comment + skip_comment = False self.cursor = self.src.find('\n', self.cursor) + if not skip_comment: + self.val = self.src[self.pos:self.cursor] + return elif self.tok in "{}:,[]": return elif self.tok == "'":
Copied from review of v3, so I don't forget:
Comment tokens are thrown away as before, except when the parser asks for them by passing skip_comment=False, or when the comment token starts with ##. The parser asks while parsing a doc comment, in get_doc().
This is a backchannel from the parser to the lexer. I'd rather avoid such lexer hacks, but I guess we can address that on top.
A comment starting with ## inside an expression is now a syntax error. For instance, input
{
##yields
/dev/stdin:2:1: Expected string or "}"
Rather unfriendly error message, but we can fix that on top.
scripts/qapi.py def check_keys(expr_elem, meta, required, optional=[]): · line 859
Quoted 6 lines
scripts/qapi.py +1
-1@@ -713,7 +856,7 @@ def check_keys(expr_elem, meta, required, optional=[]): % (key, meta, name)) -def check_exprs(exprs): +def check_exprs(exprs, strict_doc):
Note: strict_doc=False unless this is qapi2texi.py.
scripts/qapi.py def check_exprs(exprs): · line 872
Quoted 12 lines
scripts/qapi.py +5
-0global all_names # Learn the types and check for valid expression keys@@ -722,6 +865,11 @@ def check_exprs(exprs): for expr_elem in exprs: expr = expr_elem['expr'] info = expr_elem['info'] + + if strict_doc and 'doc' not in expr_elem: + raise QAPILineError(info, + "Expression missing documentation comment") +
Why should we supress this error in programs other than qapi2texi.py?
Can't see a test for this one.
scripts/qapi.py def check_exprs(exprs): · line 931
Quoted 8 lines
scripts/qapi.py +1
-0if 'enum' in expr: check_keys(expr_elem, 'enum', ['data'], ['prefix']) add_enum(expr['enum'], info, expr['data'])@@ -780,6 +928,63 @@ def check_exprs(exprs): return exprs +def check_simple_doc(doc):
You call this "free-form" elsewhere. Pick one name and stick to it. I think free-form is more descriptive than simple.
scripts/qapi.py def check_exprs(exprs): · line 935
Quoted 4 lines
scripts/qapi.py +4
-0+ if doc.symbol: + raise QAPILineError(doc.info, + "'%s' documention is not followed by the definition" + % doc.symbol)
"Documentation for %s is not ..."
scripts/qapi.py def check_exprs(exprs): · line 943
Quoted 8 lines
scripts/qapi.py +8
-0+ + body = str(doc.body) + if re.search(r'@\S+:', body, re.MULTILINE): + raise QAPILineError(doc.info, + "Document body cannot contain @NAME: sections") + + +def check_expr_doc(doc, expr, info):
You call this "symbol" elsewhere. I think "definition" would be better than either.
scripts/qapi.py def check_exprs(exprs): · line 954
Quoted 11 lines
scripts/qapi.py +11
-0+ for i in ('enum', 'union', 'alternate', 'struct', 'command', 'event'): + if i in expr: + meta = i + break + + name = expr[meta] + if doc.symbol != name: + raise QAPILineError(info, "Definition of '%s' follows documentation" + " for '%s'" % (name, doc.symbol)) + if doc.has_meta('Returns') and 'command' not in expr: + raise QAPILineError(info, "Invalid return documentation")
Suggest something like "'Returns:' is only valid for commands".
We accept 'Returns:' even when the command doesn't return anything, because we currently use it to document errors, too. Can't say I like that, but it's out of scope here.
scripts/qapi.py def check_exprs(exprs): · line 963
Quoted 9 lines
scripts/qapi.py +9
-0+ + doc_args = set(doc.args.keys()) + if meta == 'union': + data = expr.get('base', []) + else: + data = expr.get('data', []) + if isinstance(data, dict): + data = data.keys() + args = set([name.strip('*') for name in data])
Not fixed since v3:
* Flat union where 'base' is a string, e.g. union UserDefFlatUnion in qapi-schema-test.json has base 'UserDefUnionBase', args is set(['a', 'B', 'e', 'D', 'f', 'i', 'o', 'n', 's', 'r', 'U'])
* Command where 'data' is a string, e.g. user_def_cmd0 in qapi-schema-test.json has data 'Empty2', args is set(['E', 'm', 'p', '2', 't', 'y'])
* Event where 'data' is a string, no test case handy (hole in test coverage)
scripts/qapi.py def check_exprs(exprs): · line 966
Quoted 3 lines
scripts/qapi.py +3
-0+ if meta == 'alternate' or \ + (meta == 'union' and not expr.get('discriminator')): + args.add('type')
As explained in review of v3, this is only a subset of the real set of members. Computing the exact set is impractical when working with the abstract syntax tree. I believe we'll eventually have to rewrite this code to work with the QAPISchemaEntity instead.
scripts/qapi2texi.py
Quoted 43 lines
scripts/qapi.py +25
-2+ if not doc_args.issubset(args): + raise QAPILineError(info, "Members documentation is not a subset of" + " API %r > %r" % (list(doc_args), list(args))) + + +def check_docs(docs): + for doc in docs: + for section in doc.args.values() + doc.meta: + content = str(section) + if not content or content.isspace(): + raise QAPILineError(doc.info, + "Empty doc section '%s'" % section.name) + + if not doc.expr: + check_simple_doc(doc) + else: + check_expr_doc(doc, doc.expr, doc.info) + + return docs + + # # Schema compiler frontend #@@ -1249,9 +1454,11 @@ class QAPISchemaEvent(QAPISchemaEntity): class QAPISchema(object): - def __init__(self, fname): + def __init__(self, fname, strict_doc=False): try: - self.exprs = check_exprs(QAPISchemaParser(open(fname, "r")).exprs) + parser = QAPISchemaParser(open(fname, "r")) + self.exprs = check_exprs(parser.exprs, strict_doc) + self.docs = check_docs(parser.docs) self._entity_dict = {} self._predefining = True self._def_predefineds()scripts/qapi2texi.py new file +0
-0
Still only skimming this one.
Quoted 136 lines
scripts/qapi2texi.py new file +135
-0@@ -0,0 +1,331 @@ +#!/usr/bin/env python +# QAPI texi generator +# +# This work is licensed under the terms of the GNU LGPL, version 2+. +# See the COPYING file in the top-level directory. +"""This script produces the documentation of a qapi schema in texinfo format""" +import re +import sys + +import qapi + +COMMAND_FMT = """ +@deftypefn {type} {{{ret}}} {name} @ +{{{args}}} + +{body} + +@end deftypefn + +""".format + +ENUM_FMT = """ +@deftp Enum {name} + +{body} + +@end deftp + +""".format + +STRUCT_FMT = """ +@deftp {{{type}}} {name} @ +{{{attrs}}} + +{body} + +@end deftp + +""".format + +EXAMPLE_FMT = """@example +{code} +@end example +""".format + + +def subst_strong(doc): + """Replaces *foo* by @strong{foo}""" + return re.sub(r'\*([^_\n]+)\*', r'@emph{\1}', doc) + + +def subst_emph(doc): + """Replaces _foo_ by @emph{foo}""" + return re.sub(r'\s_([^_\n]+)_\s', r' @emph{\1} ', doc) + + +def subst_vars(doc): + """Replaces @var by @code{var}""" + return re.sub(r'@([\w-]+)', r'@code{\1}', doc) + + +def subst_braces(doc): + """Replaces {} with @{ @}""" + return doc.replace("{", "@{").replace("}", "@}") + + +def texi_example(doc): + """Format @example""" + doc = subst_braces(doc).strip('\n') + return EXAMPLE_FMT(code=doc) + + +def texi_comment(doc): + """ + Format a comment + + Lines starting with: + - |: generates an @example + - =: generates @section + - ==: generates @subsection + - 1. or 1): generates an @enumerate @item + - o/*/-: generates an @itemize list + """ + lines = [] + doc = subst_braces(doc) + doc = subst_vars(doc) + doc = subst_emph(doc) + doc = subst_strong(doc) + inlist = "" + lastempty = False + for line in doc.split('\n'): + empty = line == "" + + if line.startswith("| "): + line = EXAMPLE_FMT(code=line[2:]) + elif line.startswith("= "): + line = "@section " + line[2:] + elif line.startswith("== "): + line = "@subsection " + line[3:] + elif re.match("^([0-9]*[.)]) ", line): + if not inlist: + lines.append("@enumerate") + inlist = "enumerate" + line = line[line.find(" ")+1:] + lines.append("@item") + elif re.match("^[o*-] ", line): + if not inlist: + lines.append("@itemize %s" % {'o': "@bullet", + '*': "@minus", + '-': ""}[line[0]]) + inlist = "itemize" + lines.append("@item") + line = line[2:] + elif lastempty and inlist: + lines.append("@end %s\n" % inlist) + inlist = "" + + lastempty = empty + lines.append(line) + + if inlist: + lines.append("@end %s\n" % inlist) + return "\n".join(lines) + + +def texi_args(expr, key="data"): + """ + Format the functions/structure/events.. arguments/members + """ + if key not in expr: + return "" + + args = expr[key] + arg_list = [] + if isinstance(args, str):
scripts/qapi2texi.py line 145
Quoted 10 lines
scripts/qapi2texi.py new file +10
-0+ arg_list.append(args) + else: + for name, typ in args.iteritems(): + # optional arg + if name.startswith("*"): + name = name[1:] + arg_list.append("['%s': @var{%s}]" % (name, typ)) + # regular arg + else: + arg_list.append("'%s': @var{%s}" % (name, typ))
Inappropriate use of @var. @var is for metasyntactic variables, i.e. something that stands for another piece of text. typ isn't, it's the name of a specific QAPI type. I think you should use @code.
This is the reason why the type names in qemu-qmp-ref.txt are often mangled, e.g.
-- Struct: VersionInfo { 'qemu': VERSIONTRIPLE, 'package': STR }
Quoted 49 lines
scripts/qapi2texi.py new file +49
-0+ + return ", ".join(arg_list) + + +def texi_body(doc): + """ + Format the body of a symbol documentation: + - a table of arguments + - followed by "Returns/Notes/Since/Example" sections + """ + def _section_order(section): + return {"Returns": 0, + "Note": 1, + "Notes": 1, + "Since": 2, + "Example": 3, + "Examples": 3}[section] + + body = "@table @asis\n" + for arg, section in doc.args.iteritems(): + desc = str(section) + opt = '' + if desc.startswith("#optional"): + desc = desc[10:] + opt = ' *' + elif desc.endswith("#optional"): + desc = desc[:-10] + opt = ' *' + body += "@item @code{'%s'}%s\n%s\n" % (arg, opt, texi_comment(desc)) + body += "@end table\n" + body += texi_comment(str(doc.body)) + + meta = sorted(doc.meta, key=lambda i: _section_order(i.name)) + for section in meta: + name, doc = (section.name, str(section)) + func = texi_comment + if name.startswith("Example"): + func = texi_example + + body += "\n@quotation %s\n%s\n@end quotation" % \ + (name, func(doc)) + return body + + +def texi_alternate(expr, doc): + """ + Format an alternate to texi + """ + args = texi_args(expr)
scripts/qapi2texi.py line 204
Quoted 10 lines
scripts/qapi2texi.py new file +10
-0+ body = texi_body(doc) + return STRUCT_FMT(type="Alternate", + name=doc.symbol, + attrs="[ " + args + " ]", + body=body) + + +def texi_union(expr, doc): + """ + Format an union to texi
I think it's "a union".
scripts/qapi2texi.py line 212
Quoted 8 lines
scripts/qapi2texi.py new file +8
-0+ """ + attrs = "@{ " + texi_args(expr, "base") + " @}" + discriminator = expr.get("discriminator") + if not discriminator: + union = "Flat Union" + discriminator = "type" + else: + union = "Union"
Condition is backwards.
scripts/qapi2texi.py line 220
Quoted 8 lines
scripts/qapi2texi.py new file +8
-0+ attrs += " + '%s' = [ " % discriminator + attrs += texi_args(expr, "data") + " ]" + body = texi_body(doc) + + return STRUCT_FMT(type=union, + name=doc.symbol, + attrs=attrs, + body=body)
You're inventing syntax here. Example output:
-- Union: QCryptoBlockOpenOptions { QCryptoBlockOptionsBase } +
'format' = [ 'qcow': QCRYPTOBLOCKOPTIONSQCOW, 'luks':
QCRYPTOBLOCKOPTIONSLUKS ]
The options that are available for all encryption formats when opening an existing volume
Since: 2.6
-- Flat Union: ImageInfoSpecific { } + 'type' = [ 'qcow2':
IMAGEINFOSPECIFICQCOW2, 'vmdk': IMAGEINFOSPECIFICVMDK, 'luks':
QCRYPTOBLOCKINFOLUKS ]
A discriminated record of image format specific information structures.
Since: 1.7
Note that QCryptoBlockOpenOptions is actually a flat union, and ImageInfoSpecific a simple union. As I said, the condition is backwards.
The meaning of the attrs part is unobvious. Familiarity with schema syntax doesn't really help.
Could we simply use schema syntax here?
If not: whatever format you use, you first need to explain it.
Quoted 18 lines
scripts/qapi2texi.py new file +18
-0+ + +def texi_enum(expr, doc): + """ + Format an enum to texi + """ + for i in expr['data']: + if i not in doc.args: + doc.args[i] = '' + body = texi_body(doc) + return ENUM_FMT(name=doc.symbol, + body=body) + + +def texi_struct(expr, doc): + """ + Format a struct to texi + """
scripts/qapi2texi.py line 248
Quoted 10 lines
scripts/qapi2texi.py new file +10
-0+ args = texi_args(expr) + body = texi_body(doc) + attrs = "@{ " + args + " @}" + base = expr.get("base") + if base: + attrs += " + %s" % base + return STRUCT_FMT(type="Struct", + name=doc.symbol, + attrs=attrs, + body=body)
More syntax invention. Example output:
-- Struct: BlockdevOptionsReplication { 'mode': REPLICATIONMODE,
['top-id': STR] } + BlockdevOptionsGenericFormat
''mode''
the replication mode
''top-id'' *
In secondary mode, node name or device ID of the root node who owns the replication node chain. Must not be given in primary mode.
Driver specific block device options for replication
Since: 2.8
Meaning of the attrs part is perhaps more guessable here, but it's still guesswork.
The meaning of * after ''top-id'' is also unobvious.
Note the redundancy between the attrs part and the body: both state member names and optionalness. The body doesn't state member types and base type. If we fixed that, we could drop the attrs part and save us the trouble of defining and explaining a syntax for it.
Let me take a step back. This document is about the QMP wire format. There are no such things as simple and flat unions on the wire, only JSON objects. QMP introspection duly describes a type's JSON objects, not how it's defined in QAPI. I think QMP documentation should ideally do the same.
QMP introspection uses a common structure for struct, simple and flat
union: common members, variants, and if variants, then the common member that serves as tag. See introspect.json for details.
Base types are flattened away. Appropriate for introspection, but documentation shouldn't do that.
I wrote "ideally" because it's probably too big a step. I'm willing to settle for something less than ideal.
Quoted 35 lines
scripts/qapi2texi.py new file +35
-0+ + +def texi_command(expr, doc): + """ + Format a command to texi + """ + args = texi_args(expr) + ret = expr["returns"] if "returns" in expr else "" + body = texi_body(doc) + return COMMAND_FMT(type="Command", + name=doc.symbol, + ret=ret, + args="(" + args + ")", + body=body) + + +def texi_event(expr, doc): + """ + Format an event to texi + """ + args = texi_args(expr) + body = texi_body(doc) + return COMMAND_FMT(type="Event", + name=doc.symbol, + ret="", + args="(" + args + ")", + body=body) + + +def texi_expr(expr, doc): + """ + Format an expr to texi + """ + (kind, _) = expr.items()[0] +
scripts/qapi2texi.py line 293
Quoted 10 lines
scripts/qapi2texi.py new file +10
-0+ fmt = {"command": texi_command, + "struct": texi_struct, + "enum": texi_enum, + "union": texi_union, + "alternate": texi_alternate, + "event": texi_event} + try: + fmt = fmt[kind] + except KeyError: + raise ValueError("Unknown expression kind '%s'" % kind)
The try / except converts one kind of error into another. What does that buy us? As far as I can tell, this shouldn't ever happen.
Quoted 75 lines
scripts/qapi2texi.py new file +38
-0+ + return fmt(expr, doc) + + +def texi(docs): + """ + Convert QAPI schema expressions to texi documentation + """ + res = [] + for doc in docs: + expr = doc.expr + if not expr: + res.append(texi_body(doc)) + continue + try: + doc = texi_expr(expr, doc) + res.append(doc) + except: + print >>sys.stderr, "error at @%s" % doc.info + raise + + return '\n'.join(res) + + +def main(argv): + """ + Takes schema argument, prints result to stdout + """ + if len(argv) != 2: + print >>sys.stderr, "%s: need exactly 1 argument: SCHEMA" % argv[0] + sys.exit(1) + + schema = qapi.QAPISchema(argv[1], strict_doc=True) + print texi(schema.docs) + + +if __name__ == "__main__": + main(sys.argv)docs/qapi-code-gen.txt +12
-10@@ -45,16 +45,13 @@ QAPI parser does not). At present, there is no place where a QAPI schema requires the use of JSON numbers or null. Comments are allowed; anything between an unquoted # and the following -newline is ignored. Although there is not yet a documentation -generator, a form of stylized comments has developed for consistently -documenting details about an expression and when it was added to the -schema. The documentation is delimited between two lines of ##, then -the first line names the expression, an optional overview is provided, -then individual documentation about each member of 'data' is provided, -and finally, a 'Since: x.y.z' tag lists the release that introduced -the expression. Optional members are tagged with the phrase -'#optional', often with their default value; and extensions added -after the expression was first released are also given a '(since +newline is ignored. The documentation is delimited between two lines +of ##, then the first line names the expression, an optional overview +is provided, then individual documentation about each member of 'data' +is provided, and finally, a 'Since: x.y.z' tag lists the release that +introduced the expression. Optional members are tagged with the +phrase '#optional', often with their default value; and extensions +added after the expression was first released are also given a '(since x.y.z)' comment. For example: ##@@ -73,12 +70,49 @@ x.y.z)' comment. For example: # (Since 2.0) # # Since: 0.14.0 + # + # Notes: You can also make a list: + # - with items + # - like this + #
docs/qapi-code-gen.txt x.y.z)' comment. For example: · line 87
Quoted 10 lines
docs/qapi-code-gen.txt +5
-0+ # Example: + # + # -> { "execute": ... } + # <- { "return": ... } + # ## { 'struct': 'BlockStats', 'data': {'*device': 'str', 'stats': 'BlockDeviceStats', '*parent': 'BlockStats', '*backing': 'BlockStats'} }
This example gives an idea of how to document struct types. But the reader is left guessing how to document other kinds of definitions. In particular, there's no mention of "Returns", "Note" and "Examples" sections anywhere in this file. As is, this could do for a tutorial, but this file is a *reference*, not a tutorial.
For a reference, we need to be more thorough. A doc comments section on its own seems advisable.
I guess doc comment examples are best added to the schema code examples in sections === Struct types ===, ..., === Events ===.
Careful review for completeness is advised.
Quoted 17 lines
docs/qapi-code-gen.txt +17
-0+It's also possible to create documentation sections, such as: + + ## + # = Section + # == Subsection + # + # Some text foo with *strong* and _emphasis_ + # 1. with a list + # 2. like that + # + # And some code: + # | $ echo foo + # | -> do this + # | <- get that + # + ## +
docs/qapi-code-gen.txt x.y.z)' comment. For example: · line 115
Quoted 10 lines
docs/qapi-code-gen.txt +10
-0+Text *foo* and _foo_ are for "strong" and "emphasis" styles (they do +not work over multiple lines). @foo is used to reference a symbol. + +Lines starting with the following characters and a space: +- | are examples +- = are top section +- == are subsection +- X. or X) are enumerations (X is any number) +- o/*/- are itemized list +
Is this doc markup documentation complete?
Is it related to any existing text markup language? Hmm, the commit message calls it "Markdown-like". Should we mention that here?
Is all markup valid in all contexts? For instance, is = Section valid in symbol blocks? What does | (or any markup for that matter) do within an Example section?
Quoted 23 lines
docs/qapi-code-gen.txt +0
-0The schema sets up a series of types, as well as commands and events that will use those types. Forward references are allowed: the parser scans in two passes, where the first pass learns all type names, andtests/qapi-schema/doc-bad-args.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-bad-args.json:1: Members documentation is not a subset of API ['a', 'b'] > ['a']tests/qapi-schema/doc-bad-args.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-bad-args.json new file +0
-0
tests/qapi-schema/doc-bad-args.json line 6
Quoted 6 lines
tests/qapi-schema/doc-bad-args.json new file +6
-0@@ -0,0 +1,6 @@ +## +# @foo: +# @a: a +# @b: b +## +{ 'command': 'foo', 'data': {'a': 'int'} }
The existing tests/qapi-schema/*.json explain what is being tested in a comment. Perhaps like this:
# Arguments listed in the doc comment must exist in the actual schema
##
# @foo:
...Likewise for other tests.
Quoted 527 lines
tests/qapi-schema/doc-bad-args.out new file +0
-0tests/qapi-schema/doc-bad-symbol.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-bad-symbol.json:1: Definition of 'foo' follows documentation for 'food'tests/qapi-schema/doc-bad-symbol.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-bad-symbol.json new file +4
-0@@ -0,0 +1,4 @@ +## +# @food: +## +{ 'command': 'foo', 'data': {'a': 'int'} }tests/qapi-schema/doc-bad-symbol.out new file +0
-0tests/qapi-schema/doc-duplicated-arg.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-duplicated-arg.json:4:1: 'a' arg duplicatedtests/qapi-schema/doc-duplicated-arg.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-duplicated-arg.json new file +5
-0@@ -0,0 +1,5 @@ +## +# @foo: +# @a: +# @a: +##tests/qapi-schema/doc-duplicated-arg.out new file +0
-0tests/qapi-schema/doc-duplicated-return.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-duplicated-return.json:5:1: Duplicated 'Returns' sectiontests/qapi-schema/doc-duplicated-return.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-duplicated-return.json new file +6
-0@@ -0,0 +1,6 @@ +## +# @foo: +# +# Returns: 0 +# Returns: 1 +##tests/qapi-schema/doc-duplicated-return.out new file +0
-0tests/qapi-schema/doc-duplicated-since.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-duplicated-since.json:5:1: Duplicated 'Since' sectiontests/qapi-schema/doc-duplicated-since.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-duplicated-since.json new file +6
-0@@ -0,0 +1,6 @@ +## +# @foo: +# +# Since: 0 +# Since: 1 +##tests/qapi-schema/doc-duplicated-since.out new file +0
-0tests/qapi-schema/doc-empty-arg.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-empty-arg.json:3:1: Invalid argument nametests/qapi-schema/doc-empty-arg.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-empty-arg.json new file +4
-0@@ -0,0 +1,4 @@ +## +# @foo: +# @: +##tests/qapi-schema/doc-empty-arg.out new file +0
-0tests/qapi-schema/doc-empty-section.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-empty-section.json:1: Empty doc section 'Note'tests/qapi-schema/doc-empty-section.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-empty-section.json new file +6
-0@@ -0,0 +1,6 @@ +## +# @foo: +# +# Note: +## +{ 'command': 'foo', 'data': {'a': 'int'} }tests/qapi-schema/doc-empty-section.out new file +0
-0tests/qapi-schema/doc-empty-symbol.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-empty-symbol.json:2:1: Invalid symboltests/qapi-schema/doc-empty-symbol.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-empty-symbol.json new file +3
-0@@ -0,0 +1,3 @@ +## +# @: +##tests/qapi-schema/doc-empty-symbol.out new file +0
-0tests/qapi-schema/doc-invalid-end.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-end.json:3:2: Documentation comment must end with '##'tests/qapi-schema/doc-invalid-end.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-invalid-end.json new file +3
-0@@ -0,0 +1,3 @@ +## +# An invalid comment +#tests/qapi-schema/doc-invalid-end.out new file +0
-0tests/qapi-schema/doc-invalid-end2.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-end2.json:3:1: Junk after '##' at end of documentation commenttests/qapi-schema/doc-invalid-end2.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-invalid-end2.json new file +3
-0@@ -0,0 +1,3 @@ +## +# +## invalidtests/qapi-schema/doc-invalid-end2.out new file +0
-0tests/qapi-schema/doc-invalid-return.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-return.json:1: Invalid return documentationtests/qapi-schema/doc-invalid-return.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-invalid-return.json new file +5
-0@@ -0,0 +1,5 @@ +## +# @foo: +# Returns: blah +## +{ 'event': 'foo' }tests/qapi-schema/doc-invalid-return.out new file +0
-0tests/qapi-schema/doc-invalid-section.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-section.json:1: Document body cannot contain @NAME: sectionstests/qapi-schema/doc-invalid-section.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-invalid-section.json new file +4
-0@@ -0,0 +1,4 @@ +## +# freeform +# @note: foo +##tests/qapi-schema/doc-invalid-section.out new file +0
-0tests/qapi-schema/doc-invalid-start.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-invalid-start.json:1:1: Junk after '##' at start of documentation commenttests/qapi-schema/doc-invalid-start.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-invalid-start.json new file +3
-0@@ -0,0 +1,3 @@ +## invalid +# +##tests/qapi-schema/doc-invalid-start.out new file +0
-0tests/qapi-schema/doc-missing-expr.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-missing-expr.json:1: 'bar' documention is not followed by the definitiontests/qapi-schema/doc-missing-expr.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-missing-expr.json new file +3
-0@@ -0,0 +1,3 @@ +## +# @bar: +##tests/qapi-schema/doc-missing-expr.out new file +0
-0tests/qapi-schema/doc-missing-space.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-missing-space.json:3:1: missing space after #tests/qapi-schema/doc-missing-space.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-missing-space.json new file +4
-0@@ -0,0 +1,4 @@ +## +# missing space: +#wef +##tests/qapi-schema/doc-missing-space.out new file +0
-0tests/qapi-schema/qapi-schema-test.json +58
-0@@ -3,6 +3,43 @@ # This file is a stress test of supported qapi constructs that must # parse and compile correctly. +## +# = Section +# == subsection +# +# Some text foo with *strong* and _emphasis_ +# 1. with a list +# 2. like that @foo +# +# And some code: +# | $ echo foo +# | -> do this +# | <- get that +# +# Note: is not a meta +## + +## +# @TestStruct: +# @integer: foo +# blah +# +# bao +# +# @boolean: bar +# @string: baz +# +# body with @var +# +# Example: +# +# -> { "execute": ... } +# <- { "return": ... } +# +# Since: 2.3 +# Note: a note +# +## { 'struct': 'TestStruct', 'data': { 'integer': 'int', 'boolean': 'bool', 'string': 'str' } }@@ -123,6 +160,27 @@ 'data': {'ud1a': 'UserDefOne', '*ud1b': 'UserDefOne'}, 'returns': 'UserDefTwo' } +## +# Another comment +## + +## +# @guest-get-time: +# +# @a: an integer +# @b: #optional integer +# +# @guest-get-time body +# +# Returns: returns something +# +# Example: +# +# -> { "execute": "guest-get-time", ... } +# <- { "return": "42" } +# +## + # Returning a non-dictionary requires a name from the whitelist { 'command': 'guest-get-time', 'data': {'a': 'int', '*b': 'int' }, 'returns': 'int' }tests/qapi-schema/qapi-schema-test.out +49
-0@@ -232,3 +232,52 @@ command user_def_cmd1 q_obj_user_def_cmd1-arg -> None gen=True success_response=True boxed=False command user_def_cmd2 q_obj_user_def_cmd2-arg -> UserDefTwo gen=True success_response=True boxed=False +doc freeform + body= += Section +== subsection + +Some text foo with *strong* and _emphasis_ +1. with a list +2. like that @foo + +And some code: +| $ echo foo +| -> do this +| <- get that + +Note: is not a meta +doc symbol=TestStruct expr=('struct', 'TestStruct') + arg=integer +foo +blah + +bao + arg=boolean +bar + arg=string +baz + meta=Example +-> { "execute": ... } +<- { "return": ... } + meta=Since +2.3 + meta=Note +a note + body= +body with @var +doc freeform + body= +Another comment +doc symbol=guest-get-time expr=('command', 'guest-get-time') + arg=a +an integer + arg=b +#optional integer + meta=Returns +returns something + meta=Example +-> { "execute": "guest-get-time", ... } +<- { "return": "42" } + body= +@guest-get-time bodytests/qapi-schema/test-qapi.py +2
-0@@ -55,3 +55,15 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): schema = QAPISchema(sys.argv[1]) schema.visit(QAPISchemaTestVisitor()) + +for doc in schema.docs:
tests/qapi-schema/test-qapi.py class QAPISchemaTestVisitor(QAPISchemaVisitor): · line 69
Quoted 10 lines
tests/qapi-schema/test-qapi.py +10
-0+ if doc.symbol: + print 'doc symbol=%s expr=%s' % \ + (doc.symbol, doc.expr.items()[0]) + else: + print 'doc freeform' + for arg, section in doc.args.iteritems(): + print ' arg=%s\n%s' % (arg, section) + for section in doc.meta: + print ' meta=%s\n%s' % (section.name, section) + print ' body=\n%s' % doc.body
[1] https://www.python.org/dev/peps/pep-0257/
[2] https://google.github.io/styleguide/pyguide.html
[3] https://www.python.org/dev/peps/pep-0008/
Re: [Qemu-devel] [PATCH v5 13/17] qapi: add qapi2texi script
Hi
On Wed, Nov 30, 2016 at 8:07 PM Markus Armbruster <[email protected]> wrote:
Quoted 25 lines · Marc-André Lureau
As the name suggests, the qapi2texi script converts JSON QAPI description into a texi file suitable for different target formats (info/man/txt/pdf/html...).
It parses the following kind of blocks:
Free-form:
##
# = Section
# == Subsection
#
# Some text foo with *emphasis*
# 1. with a list
# 2. like that
#
# And some code:# | $ echo foo # | -> do this # | <- get that#
##Symbol:
Quoted 8 lines
##
# @symbol:
#
# Symbol body ditto ergo sum. Foo bar# baz ding. # # @arg: foo # @arg: #optional foo
Let's not use @arg twice.
Terminology: I prefer to use "parameter" for formal parameters, and "argument" for actual arguments. This matches how The Python Language Reference uses the terms.
What about
# @param1: the frob to frobnicate
# @param2: #optional how hard to frobnicate
ok
Quoted 3 lines
#
# Returns: returns bla bla
# Or bla blah
Repeating "returns" is awkward, and we don't do that in our schemas.
We need a period before "Or", or spell it "or".
What about
# Returns: the frobnicated frob.
# If frob isn't frobnicatable, GenericError.
ok
Quoted 13 lines
#
# Since: version
# Notes: notes, comments can have
# - itemized list
# - like this
#
# Example:
#
# -> { "execute": "quit" }
# <- { "return": {} }
#
##
Quoted 6 lines
That's roughly following the following EBNF grammar:
api_comment= "##\n" comment "##\n"
comment =freeform_comment|symbol_commentfreeform_comment= { "# " text "\n" | "#\n" }symbol_comment= "# @" name ":\n" { member | meta |freeform_comment}
Rejects non-empty comments where "#" is not followed by space. Such usage is accepted outside doc comments. Hmm.
Quoted 1 line
member = "# @" name ':' [ text ]
freeform_comment
Are you missing a "\n" before freeform_comment?
yes
Quoted 1 line
meta = "# " ( "Returns:", "Since:", "Note:", "Notes:", "Example:",
"Examples:" ) [ text ] freeform_comment
Likewise.
ok
Quoted 1 line
text = free-text markdown-like, "#optional" for members
The grammar is ambiguous: a line "# @foo:\n" can be parsed both as freeform_comment and as symbol_comment. Since your intent is obvious enough, it can still serve as documentation. It's not a suitable foundation for parsing, though. Okay for a commit message.
Quoted 3 lines
Thanks to the following json expressions, the documentation is enhanced with extra information about the type of arguments and return value expected.
I guess you want to say that we enrich the documentation we extract from comments with information from the actual schema. Correct?
yes
Missing: a brief discussion of deficiencies. These include:
* The generated QMP documentation includes internal types
We use qapi-schema.json both for defining the external QMP interface and for defining internal types. qmp-introspect.py carefully separates the two, to not expose internal types. qapi2texi.py happily exposes everything.
Currently, about a fifth of the types in the generated docs are internal:
AcpiTableOptions
BiosAtaTranslation
BlockDeviceMapEntry
COLOMessage
COLOMode
DummyForceArrays
FailoverStatus
FloppyDriveType
ImageCheck
LostTickPolicy
MapEntry
MigrationParameter
NetClientDriver
NetFilterDirection
NetLegacy
NetLegacyNicOptions
NetLegacyOptions
NetLegacyOptionsKind
Netdev
NetdevBridgeOptions
NetdevDumpOptions
NetdevHubPortOptions
NetdevL2TPv3Options
NetdevNetmapOptions
NetdevNoneOptions
NetdevSocketOptions
NetdevTapOptions
NetdevUserOptions
NetdevVdeOptions
NetdevVhostUserOptions
NumaNodeOptions
NumaOptions
NumaOptionsKind
OnOffAuto
OnOffSplit
PreallocMode
QCryptoBlockCreateOptions
QCryptoBlockCreateOptionsLUKS
QCryptoBlockFormat
QCryptoBlockInfo
QCryptoBlockInfoBase
QCryptoBlockInfoQCow
QCryptoBlockOpenOptions
QCryptoBlockOptionsBase
QCryptoBlockOptionsLUKS
QCryptoBlockOptionsQCow
QCryptoSecretFormat
QCryptoTLSCredsEndpoint
QapiErrorClass
ReplayMode
X86CPUFeatureWordInfo
X86CPURegister32
Generating documentation for internal types might be useful, but letting them pollute QMP interface documentation isn't. Needs fixing before we release. Until then, needs a FIXME comment in qapi2texi.py.
* Union support is lacking
The doc string language is adequate for documenting commands, events, and non-union types. It doesn't really handle union variants. Hardly surprising, as you fitted the language do existing practice, and existing (mal-)practice is neglecting to document union variant members.
* Documentation is lacking
See review of qapi-code-gen.txt below.
* Doc comment error message positions are imprecise
They always point to the beginning of the comment.
* Probably more
We should update this with noteworthy findings during review. I tried, but I suspect I missed some.
ok
Quoted 1 line
Signed-off-by Marc-André Lureau <[email protected]>
[Lengthy diffstat snipped...]
Quoted 41 lines
tests/Makefile.include +17
-0@@ -350,6 +350,21 @@ qapi-schema += base-cycle-direct.json qapi-schema += base-cycle-indirect.json qapi-schema += command-int.json qapi-schema += comments.json +qapi-schema += doc-bad-args.json +qapi-schema += doc-bad-symbol.json +qapi-schema += doc-duplicated-arg.json +qapi-schema += doc-duplicated-return.json +qapi-schema += doc-duplicated-since.json +qapi-schema += doc-empty-arg.json +qapi-schema += doc-empty-section.json +qapi-schema += doc-empty-symbol.json +qapi-schema += doc-invalid-end.json +qapi-schema += doc-invalid-end2.json +qapi-schema += doc-invalid-return.json +qapi-schema += doc-invalid-section.json +qapi-schema += doc-invalid-start.json +qapi-schema += doc-missing-expr.json +qapi-schema += doc-missing-space.json qapi-schema += double-data.json qapi-schema += double-type.json qapi-schema += duplicate-key.json@@ -443,6 +458,8 @@ qapi-schema += union-optional-branch.json qapi-schema += union-unknown.json qapi-schema += unknown-escape.json qapi-schema += unknown-expr-key.json + + check-qapi-schema-y := $(addprefix tests/qapi-schema/, $(qapi-schema)) GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h \scripts/qapi.py +0
-0
scripts/qapi.py class QAPILineError(Exception): · line 122
Quoted 1 line
scripts/qapi.py +0
-0@@ -122,6 +122,109 @@ class QAPILineError(Exception): "%s:%d: %s" % (self.info['file'], self.info['line'],
self.msg)
scripts/qapi.py class QAPILineError(Exception): · line 127
Quoted 5 lines
scripts/qapi.py +3
-0+class QAPIDoc(object): + class Section(object): + def __init__(self, name=""):
name=None feels more natural than "" for an absent optional name.
ok
scripts/qapi.py class QAPILineError(Exception): · line 130
Quoted 3 lines
scripts/qapi.py +3
-0+ # optional section name (argument/member or section name) + self.name = name + # the list of strings for this section
Would "list of lines" be more accurate, or less?
more accurate, ok
scripts/qapi.py class QAPILineError(Exception): · line 140
Quoted 10 lines
scripts/qapi.py +10
-0+ self.content = [] + + def append(self, line): + self.content.append(line) + + def __repr__(self): + return "\n".join(self.content).strip() + + class ArgSection(Section): + pass
Begs the question what makes ArgSection differ from Section. I think it's the semantics of self.name: an ArgSection's name is the parameter name, a non-ArgSection can either be a "meta" section (name is one of "Returns"", "Since", "Note", "Notes", "Example", "Examples") or an anonymous section (name is "").
yes, and the section type is checked in _append_freeform()
scripts/qapi.py class QAPILineError(Exception): · line 146
Quoted 6 lines
scripts/qapi.py +6
-0+ + def __init__(self, parser): + self.parser = parser + self.symbol = None + self.body = QAPIDoc.Section() + # a dict {'arg': ArgSection, ...}
Works. Alternatevely:
# dict mapping parameter name to ArgSection
ok
scripts/qapi.py class QAPILineError(Exception): · line 152
Quoted 6 lines
scripts/qapi.py +6
-0+ self.args = OrderedDict() + # a list of Section + self.meta = [] + # the current section + self.section = self.body + # associated expression and info (set by expression parser)
"will be set by expression parser", or "to be set by expression parser"?
ok
scripts/qapi.py class QAPILineError(Exception): · line 154
Quoted 2 lines
scripts/qapi.py +2
-0+ self.expr = None + self.info = None
Clearer now. The one remark I still have is on the use of "meta" isn't obvious here. I think a comment further up explaining the different kinds of sections would help.
To be honest, I don't get what's "meta" about the "meta" sections :)
Let's drop that distinction, it isn't necessary anymore
scripts/qapi.py class QAPILineError(Exception): · line 157
Quoted 3 lines
scripts/qapi.py +3
-0+ + def has_meta(self, name): + """Returns True if the doc has a meta section 'name'"""
PEP257[1] demands imperative mood, and punctuation:
"""Return True if the doc has a meta section 'name'."""
Unfortunately, there seems to be no established convention for marking parameter names. You put this one in single quotes, which works here, but could be confusing in other cases. I'd sidestep it:
"""Return True if we have a meta section with this name."""
or
"""Does a meta section with this name exist?"""
ok
scripts/qapi.py class QAPILineError(Exception):
Quoted 7 lines
scripts/qapi.py +7
-0+ for i in self.meta: + if i.name == name: + return True + return False + + def append(self, line): + """Adds a # comment line, to be parsed and added to current
section"""
Imperative mood:
"""Add a comment line, to be parsed and added to the current section."""
However, we're not always adding to the current section, we can also start a new one. The following avoids suggesting anything about the current section:
"""Parse a comment line and add it to the documentation."""
When the function name is a verb, and its doc string starts with a different verb, the name might be suboptimal. Use your judgement.
If this one-liner is too terse, we can try a multi-line doc string:
"""Parse a comment line and add it to the documentation.
TODO should we tell more about how we parse?
Args:
line: the comment starting with '#', with the newline stripped.
Raises:
QAPISchemaError: TODO explain error conditions
"""
Format stolen from the Google Python Style Guide[2], because PEP257 is of not much help there.
Once you start with such elaborate doc strings, pressure will likely mount to do the same elsewhere. Could be a distraction right now. Use your judgement.
ok, thanks
scripts/qapi.py class QAPILineError(Exception): · line 172
Quoted 8 lines
scripts/qapi.py +8
-0+ line = line[1:] + if not line: + self._append_freeform(line) + return + + if line[0] != ' ': + raise QAPISchemaError(self.parser, "missing space after #") + line = line[1:]
QAPISchemaError takes the error position from its QAPISchemaParser argument. In other words, the error position depends on the state of the parser when it calls this function. Turns out the position is the beginning of the comment. Servicable here. Action at a distance, though.
Less strict:
# strip leading # and space
line = line[1:]
if line[0] == ' ':
line = line[1:]Also avoids special-casing empty comments.
That would raise "IndexError: string index out of range" on empty comment lines ("#")
Also I'd like to keep the error in case a space is missing (it caught some already).
Perhaps we should treat all leading whitespace the same (I'm not sure):
# strip leading # and whitespace
line = line[1:]
line = line.lstrip()That would break indentation in Example sections
scripts/qapi.py class QAPILineError(Exception): · line 180
Quoted 8 lines
scripts/qapi.py +8
-0+ + if self.symbol: + self._append_symbol_line(line) + elif (not self.body.content and + line.startswith("@") and line.endswith(":")): + self.symbol = line[1:-1] + if not self.symbol: + raise QAPISchemaError(self.parser, "Invalid symbol")
Doesn't recognize the symbol when there's anything other than a single space between # and @. Pathological case: '#\t@foo:' starting in column 6 looks exactly like '# @foo:', but doesn't work. Fortunately, your code rejects the tab there. Assigning meaning to (leading) whitespace may make sense, but it must be documented clearly.
I think it's simpler to only accept a simple space (# + space + @ + symbol
+ :), it will also lead to more uniform doc.
Doesn't recognize the symbol when there's crap after ":". Confusing when it's invisible crap, i.e. trailing whitespace. In general, it's best to parse left to right, like this:
elif not self.body.content and line.startswith('@'):
match = valid_name.match(line[1:]);
if not match:
raise QAPISchemaError(self.parser, 'Invalid name')
if line.startswith(':', match.end(0)):
raise QAPISchemaError(self.parser, 'Expected ":")
Easier is simply to check :
if not line.endswith(":"):
raise QAPIParseError(self.parser, "Line should end with :")
test added
Here, the error position is clearly suboptimal: it's the beginning of the comment instead of where the actual error is, namely the beginning / the end of the name. More of the same below. The root cause is stacking parsers. I'm not asking you to do anything about it at this time.
Note my use of "name" rather than "symbol" in the error message. qapi-code-gen.txt talks about names, not symbols. Consistent use of terminology matters.
Agree, isn't "symbol" more appropriate for documentation though?
scripts/qapi.py class QAPILineError(Exception): · line 189
Quoted 9 lines
scripts/qapi.py +9
-0+ else: + self._append_freeform(line) + + def _append_symbol_line(self, line): + name = line.split(' ', 1)[0] + + if name.startswith("@") and name.endswith(":"): + line = line[len(name)+1:] + self._start_args_section(name[1:-1])
Similar issue. Left to right:
if re.match(r'\s*@', line):
match = valid_name.match(line[1:]);
if not match:
raise QAPISchemaError(self.parser, 'Invalid parameter
name')
line = line[match.end(0):]
if line.startswith(':'):
raise QAPISchemaError(self.parser, 'Expected ":")
line = line[1:]
self._start_args_section(match.group(0))Even better would be factoring out the common code to parse '@foo:'.
It's a valid case to have a section freeform comment starting with @foo, ex:
@param: do this and than if
@param2 is True
I don't think it's worth to factor out the code to parse @foo vs @foo:, yet
scripts/qapi.py class QAPILineError(Exception): · line 195
Quoted 6 lines
scripts/qapi.py +6
-0+ elif name in ("Returns:", "Since:", + # those are often singular or plural + "Note:", "Notes:", + "Example:", "Examples:"): + line = line[len(name)+1:] + self._start_meta_section(name[:-1])
Since we're re.match()ing already, here's how do to it that way:
I don't follow your suggestion for the reason above,so I still have the first word 'name'
else
match = re.match(r'\s*(Returns|Since|Notes?|Examples?):',
line)
if match:
line = line[match.end(0):]
self._start_meta_section(match.group(1))not really much nicer to me (especially because no match yet), I'll keep the current code for now
scripts/qapi.py class QAPILineError(Exception): · line 201
Quoted 6 lines
scripts/qapi.py +6
-0+ + self._append_freeform(line) + + def _start_args_section(self, name): + if not name: + raise QAPISchemaError(self.parser, "Invalid argument name")
parameter name
ok
scripts/qapi.py class QAPILineError(Exception): · line 201
Quoted 2 lines
scripts/qapi.py +2
-0+ if name in self.args: + raise QAPISchemaError(self.parser, "'%s' arg duplicated" %
name)
Duplicate parameter name
ok
scripts/qapi.py class QAPILineError(Exception):
Quoted 13 lines
scripts/qapi.py +13
-0+ self.section = QAPIDoc.ArgSection(name) + self.args[name] = self.section + + def _start_meta_section(self, name): + if name in ("Returns", "Since") and self.has_meta(name): + raise QAPISchemaError(self.parser, + "Duplicated '%s' section" % name) + self.section = QAPIDoc.Section(name) + self.meta.append(self.section) + + def _append_freeform(self, line): + in_arg = isinstance(self.section, QAPIDoc.ArgSection) + if in_arg and self.section.content and not
self.section.content[-1] \
scripts/qapi.py class QAPILineError(Exception): · line 217
Quoted 1 line
scripts/qapi.py +1
-0+ and line and not line[0].isspace():
PEP8[3] prefers parenthesises over backslash:
if (in_arg and self.section.content and not
self.section.content[-1]
and line and not line[0].isspace()):
yes, thanks
scripts/qapi.py class QAPILineError(Exception): · line 222
Quoted 5 lines
scripts/qapi.py +5
-0+ # an empty line followed by a non-indented + # comment ends the argument section + self.section = self.body + self._append_freeform(line) + return
Switching back to the self.body section like this reorders the documentation text. I still think this is a terrible idea. A dumb script is exceedingly unlikely to improve human-written doc comment text by reordering. In the rare case it does, the doc comment source should be reordered.
Here's an example where the doc generator happily creates unintelligible garbage if I format CpuDefinitionInfo's doc comment in a slightly off way:
##
# @CpuDefinitionInfo:
#
# Virtual CPU definition.
#
# @name: the name of the CPU definition
#
# @migration-safe: #optional whether a CPU definition can be safely # used for migration in combination with a QEMU compatibility # machine when migrating between different QMU versions and between # hosts with different sets of (hardware or software)
# capabilities.
#
# If not provided, information is not available and callers should # not assume the CPU definition to be migration-safe. (since 2.8) #
# @static: whether a CPU definition is static and will not change # depending on QEMU version, machine type, machine options and # accelerator options. A static model is always
# migration-safe. (since 2.8)
#
# @unavailable-features: #optional List of properties that prevent # the CPU model from running in the current host. (since 2.8) #
# @unavailable-features is a list of QOM property names that # represent CPU model attributes that prevent the CPU from running. # If the QOM property is read-only, that means there's no known # way to make the CPU model run in the current host. Implementations # that choose not to provide specific information return the # property name "type".
#
# If the property is read-write, it means that it MAY be possible # to run the CPU model in the current host if that property is # changed. Management software can use it as hints to suggest or # choose an alternative for the user, or just to generate meaningful # error messages explaining why the CPU model can't be used. # If @unavailable-features is an empty list, the CPU model is # runnable using the current host and machine-type.
# If @unavailable-features is not present, runnability
# information for the CPU is not available.
#
# Since: 1.2.0
##
{ 'struct': 'CpuDefinitionInfo',
'data': { 'name': 'str', '*migration-safe': 'bool', 'static': 'bool',
'*unavailable-features': [ 'str' ] } }
To detect the problem, you have to read the generated docs attentively. You know my opinion on our chances for that to happen during development.
My point is not that we should support this doc comment format. My point is that people could conceivably write something like it, and not get caught in patch review.
I can see three ways out of this swamp:
1. Let sections continue until another one begins.
but we have interleaved sections, and no explicit "body" section tag, ex:
##
# @input-send-event:
#
# Send input event(s) to guest.
#
# @device: #optional display device to send event(s) to.
# @head: #optional head to send event(s) to, in case the
# display device supports multiple scanouts.
# @events: List of InputEvent union.
#
# Returns: Nothing on success.
#
# The @device and @head parameters can be used to send the input event
# to specific input devices in case (a) multiple input devices of the # same kind are added to the virtual machine and (b) you have # configured input routing (see docs/multiseat.txt) for those input # ....
3. When a section ends, start a new anonymous section.
It's not clear how to recognize when a section ends and append to comment body.
2. Make text between sections an error.
Sound like the best option to me. I'll fix the doc and add a check & test for this common pattern though:
##
# @TestStruct:
#
# body with @var # # @integer: foo # blah # # bao # # Let's catch this bad comment. ##
Can't say offhand which one will work best.
scripts/qapi.py class QAPILineError(Exception): · line 224
Quoted 2 lines
scripts/qapi.py +2
-0+ if in_arg or not self.section.name.startswith("Example"): + line = line.strip()
Stripping whitespace is not "Markdown-like", because intendation carries meaning in Markdown. Example:
* First item in itemized list
* Second item
* Sub-item of second item
* Another sub-item
* Third item
Stripping whitespace destroys the list structure. If that's what you want, you get to document where your "Markdown-like" markup is unlike Markdown :)
let's use "comment annotations" instead
Is there a technical reason for stripping whitespace?
See also discussion of space after # above.
Quoted 7 lines
scripts/qapi.py +3
-0+ self.section.append(line) + + class QAPISchemaParser(object): def __init__(self, fp, previously_included=[], incl_info=None):
scripts/qapi.py class QAPISchemaParser(object): · line 249
Quoted 10 lines
scripts/qapi.py +2
-0@@ -137,11 +240,18 @@ class QAPISchemaParser(object): self.line = 1 self.line_pos = 0 self.exprs = [] + self.docs = [] self.accept() while self.tok is not None: info = {'file': fname, 'line': self.line, 'parent': self.incl_info} + if self.tok == '#' and self.val.startswith('##'):
How can self.val *not* start with '##' here?
you are right, unnecessary condition since we break get_expr() only in
this case now
scripts/qapi.py class QAPISchemaParser(object): · line 251
Quoted 2 lines
scripts/qapi.py +2
-0+ doc = self.get_doc() + doc.info = info
Let's pass info as argument to get_doc(), so we don't have to dot into doc here. get_doc() can avoid dotting into doc by passing info to the constructor.
ok
Quoted 15 lines
scripts/qapi.py +4
-0+ self.docs.append(doc) + continue + expr = self.get_expr(False) if isinstance(expr, dict) and "include" in expr: if len(expr) != 1:@@ -160,6 +270,7 @@ class QAPISchemaParser(object): raise QAPILineError(info, "Inclusion loop for %s" % include) inf = inf['parent'] + # skip multiple include of the same file if incl_abs_fname in previously_included: continue
scripts/qapi.py class QAPISchemaParser(object): · line 282
Quoted 1 line
scripts/qapi.py +0
-0@@ -171,12 +282,38 @@ class QAPISchemaParser(object): exprs_include = QAPISchemaParser(fobj,
previously_included,
scripts/qapi.py class QAPISchemaParser(object): · line 292
Quoted 10 lines
scripts/qapi.py +5
-0info) self.exprs.extend(exprs_include.exprs) + self.docs.extend(exprs_include.docs) else: expr_elem = {'expr': expr, 'info': info} + if self.docs and not self.docs[-1].expr: + self.docs[-1].expr = expr + expr_elem['doc'] = self.docs[-1] +
Attaches the expression to the last doc comment that doesn't already have one. A bit sloppy, because there could be non-doc comments in between, or the doc comment could be in another file. It'll do, at least for now.
I extended the condition to check it attaches the doc from the same file
Quoted 5 lines
scripts/qapi.py +2
-1self.exprs.append(expr_elem) - def accept(self): + def get_doc(self): + if self.val != '##':
scripts/qapi.py class QAPISchemaParser(object):
Quoted 10 lines
scripts/qapi.py +10
-0+ raise QAPISchemaError(self, "Junk after '##' at start of " + "documentation comment") + + doc = QAPIDoc(self) + self.accept(False) + while self.tok == '#': + if self.val.startswith('##'): + # End of doc comment + if self.val != '##': + raise QAPISchemaError(self, "Junk after '##' at end
of "
scripts/qapi.py class QAPISchemaParser(object):
Quoted 8 lines
scripts/qapi.py +8
-0+ "documentation comment") + self.accept() + return doc + else: + doc.append(self.val) + self.accept(False) + + raise QAPISchemaError(self, "Documentation comment must end with
'##'")
Let's put this after accept, next to the other get_FOO().
ok
Quoted 9 lines
scripts/qapi.py +2
-0+ + def accept(self, skip_comment=True): while True: self.tok = self.src[self.cursor] self.pos = self.cursor@@ -184,7 +321,13 @@ class QAPISchemaParser(object): self.val = None if self.tok == '#':
scripts/qapi.py class QAPISchemaParser(object): · line 333
Quoted 10 lines
scripts/qapi.py +6
-0+ if self.src[self.cursor] == '#': + # Start of doc comment + skip_comment = False self.cursor = self.src.find('\n', self.cursor) + if not skip_comment: + self.val = self.src[self.pos:self.cursor] + return elif self.tok in "{}:,[]": return elif self.tok == "'":
Copied from review of v3, so I don't forget:
Comment tokens are thrown away as before, except when the parser asks for them by passing skip_comment=False, or when the comment token starts with ##. The parser asks while parsing a doc comment, in get_doc().
This is a backchannel from the parser to the lexer. I'd rather avoid such lexer hacks, but I guess we can address that on top.
A comment starting with ## inside an expression is now a syntax error. For instance, input
{
##yields
/dev/stdin:2:1: Expected string or "}"
Rather unfriendly error message, but we can fix that on top.
I don't have a good solution to that
scripts/qapi.py def check_keys(expr_elem, meta, required,
Quoted 1 line
scripts/qapi.py +0
-0@@ -713,7 +856,7 @@ def check_keys(expr_elem, meta, required,
optional=[]):
scripts/qapi.py def check_keys(expr_elem, meta, required, optional=[]): · line 859
Quoted 5 lines
scripts/qapi.py +1
-1% (key, meta, name)) -def check_exprs(exprs): +def check_exprs(exprs, strict_doc):
Note: strict_doc=False unless this is qapi2texi.py.
For tests reasons: we may want to fix the test instead, or have a flag QAPI_CHECK/NOSTRICT_DOC=1 or an option.
scripts/qapi.py def check_exprs(exprs): · line 871
Quoted 11 lines
scripts/qapi.py +4
-0global all_names # Learn the types and check for valid expression keys@@ -722,6 +865,11 @@ def check_exprs(exprs): for expr_elem in exprs: expr = expr_elem['expr'] info = expr_elem['info'] + + if strict_doc and 'doc' not in expr_elem: + raise QAPILineError(info, + "Expression missing documentation
comment")
scripts/qapi.py def check_exprs(exprs): · line 872
Quoted 1 line
scripts/qapi.py +1
-0+
Why should we supress this error in programs other than qapi2texi.py?
because the tests don't have comments
Can't see a test for this one.
because tests aren't strict :)
I guess you'll tell me to fix the tests instead, so I did that in the next series.
scripts/qapi.py def check_exprs(exprs): · line 931
Quoted 8 lines
scripts/qapi.py +1
-0if 'enum' in expr: check_keys(expr_elem, 'enum', ['data'], ['prefix']) add_enum(expr['enum'], info, expr['data'])@@ -780,6 +928,63 @@ def check_exprs(exprs): return exprs +def check_simple_doc(doc):
You call this "free-form" elsewhere. Pick one name and stick to it. I think free-form is more descriptive than simple.
ok
scripts/qapi.py def check_exprs(exprs):
Quoted 3 lines
scripts/qapi.py +3
-0+ if doc.symbol: + raise QAPILineError(doc.info, + "'%s' documention is not followed by the
definition"
scripts/qapi.py def check_exprs(exprs): · line 935
Quoted 1 line
scripts/qapi.py +1
-0+ % doc.symbol)
"Documentation for %s is not ..."
ok
scripts/qapi.py def check_exprs(exprs):
Quoted 5 lines
scripts/qapi.py +5
-0+ + body = str(doc.body) + if re.search(r'@\S+:', body, re.MULTILINE): + raise QAPILineError(doc.info, + "Document body cannot contain @NAME:
sections")
scripts/qapi.py def check_exprs(exprs): · line 943
Quoted 3 lines
scripts/qapi.py +3
-0+ + +def check_expr_doc(doc, expr, info):
You call this "symbol" elsewhere. I think "definition" would be better than either.
ok
scripts/qapi.py def check_exprs(exprs): · line 944
Quoted 1 line
scripts/qapi.py +1
-0+ for i in ('enum', 'union', 'alternate', 'struct', 'command',
'event'):
scripts/qapi.py def check_exprs(exprs):
Quoted 7 lines
scripts/qapi.py +7
-0+ if i in expr: + meta = i + break + + name = expr[meta] + if doc.symbol != name: + raise QAPILineError(info, "Definition of '%s' follows
documentation"
scripts/qapi.py def check_exprs(exprs): · line 954
Quoted 3 lines
scripts/qapi.py +3
-0+ " for '%s'" % (name, doc.symbol)) + if doc.has_meta('Returns') and 'command' not in expr: + raise QAPILineError(info, "Invalid return documentation")
Suggest something like "'Returns:' is only valid for commands".
We accept 'Returns:' even when the command doesn't return anything, because we currently use it to document errors, too. Can't say I like that, but it's out of scope here.
ok
scripts/qapi.py def check_exprs(exprs): · line 963
Quoted 9 lines
scripts/qapi.py +9
-0+ + doc_args = set(doc.args.keys()) + if meta == 'union': + data = expr.get('base', []) + else: + data = expr.get('data', []) + if isinstance(data, dict): + data = data.keys() + args = set([name.strip('*') for name in data])
Not fixed since v3:
* Flat union where 'base' is a string, e.g. union UserDefFlatUnion in qapi-schema-test.json has base 'UserDefUnionBase', args is set(['a', 'B', 'e', 'D', 'f', 'i', 'o', 'n', 's', 'r', 'U'])
* Command where 'data' is a string, e.g. user_def_cmd0 in qapi-schema-test.json has data 'Empty2', args is set(['E', 'm', 'p', '2', 't', 'y'])
* Event where 'data' is a string, no test case handy (hole in test coverage)
ok, I changed it that way, that fixes it:
+ if isinstance(data, list):
+ args = set([name.strip('*') for name in data])
+ else:
+ args = set()
scripts/qapi.py def check_exprs(exprs): · line 966
Quoted 3 lines
scripts/qapi.py +3
-0+ if meta == 'alternate' or \ + (meta == 'union' and not expr.get('discriminator')): + args.add('type')
As explained in review of v3, this is only a subset of the real set of members. Computing the exact set is impractical when working with the abstract syntax tree. I believe we'll eventually have to rewrite this code to work with the QAPISchemaEntity instead.
I don't think we want to list all the members as this would lead to duplicated documentation. Instead it should document only the members of the expr being defined. In which case, it looks like this check is good enough, no?
scripts/qapi.py def check_exprs(exprs): · line 968
Quoted 2 lines
scripts/qapi.py +2
-0+ if not doc_args.issubset(args): + raise QAPILineError(info, "Members documentation is not a subset
of"
scripts/qapi.py def check_exprs(exprs): · line 969
Quoted 1 line
scripts/qapi.py +1
-0+ " API %r > %r" % (list(doc_args),
list(args)))
scripts/qapi.py def check_exprs(exprs):
Quoted 9 lines
scripts/qapi.py +9
-0+ + +def check_docs(docs): + for doc in docs: + for section in doc.args.values() + doc.meta: + content = str(section) + if not content or content.isspace(): + raise QAPILineError(doc.info, + "Empty doc section '%s'" %
section.name)
Quoted 13 lines
scripts/qapi.py +9
-0+ + if not doc.expr: + check_simple_doc(doc) + else: + check_expr_doc(doc, doc.expr, doc.info) + + return docs + + # # Schema compiler frontend #
scripts/qapi.py class QAPISchemaEvent(QAPISchemaEntity): · line 1254
Quoted 7 lines
scripts/qapi.py +1
-2@@ -1249,9 +1454,11 @@ class QAPISchemaEvent(QAPISchemaEntity): class QAPISchema(object): - def __init__(self, fname): + def __init__(self, fname, strict_doc=False): try: - self.exprs = check_exprs(QAPISchemaParser(open(fname,
"r")).exprs)
scripts/qapi2texi.py
Quoted 11 lines
scripts/qapi.py +3
-0+ parser = QAPISchemaParser(open(fname, "r")) + self.exprs = check_exprs(parser.exprs, strict_doc) + self.docs = check_docs(parser.docs) self._entity_dict = {} self._predefining = True self._def_predefineds()scripts/qapi2texi.py new file +0
-0
Still only skimming this one.
scripts/qapi2texi.py line 6
Quoted 7 lines
scripts/qapi2texi.py new file +6
-0@@ -0,0 +1,331 @@ +#!/usr/bin/env python +# QAPI texi generator +# +# This work is licensed under the terms of the GNU LGPL, version 2+. +# See the COPYING file in the top-level directory. +"""This script produces the documentation of a qapi schema in texinfo
format"""
Quoted 129 lines
scripts/qapi2texi.py new file +129
-0+import re +import sys + +import qapi + +COMMAND_FMT = """ +@deftypefn {type} {{{ret}}} {name} @ +{{{args}}} + +{body} + +@end deftypefn + +""".format + +ENUM_FMT = """ +@deftp Enum {name} + +{body} + +@end deftp + +""".format + +STRUCT_FMT = """ +@deftp {{{type}}} {name} @ +{{{attrs}}} + +{body} + +@end deftp + +""".format + +EXAMPLE_FMT = """@example +{code} +@end example +""".format + + +def subst_strong(doc): + """Replaces *foo* by @strong{foo}""" + return re.sub(r'\*([^_\n]+)\*', r'@emph{\1}', doc) + + +def subst_emph(doc): + """Replaces _foo_ by @emph{foo}""" + return re.sub(r'\s_([^_\n]+)_\s', r' @emph{\1} ', doc) + + +def subst_vars(doc): + """Replaces @var by @code{var}""" + return re.sub(r'@([\w-]+)', r'@code{\1}', doc) + + +def subst_braces(doc): + """Replaces {} with @{ @}""" + return doc.replace("{", "@{").replace("}", "@}") + + +def texi_example(doc): + """Format @example""" + doc = subst_braces(doc).strip('\n') + return EXAMPLE_FMT(code=doc) + + +def texi_comment(doc): + """ + Format a comment + + Lines starting with: + - |: generates an @example + - =: generates @section + - ==: generates @subsection + - 1. or 1): generates an @enumerate @item + - o/*/-: generates an @itemize list + """ + lines = [] + doc = subst_braces(doc) + doc = subst_vars(doc) + doc = subst_emph(doc) + doc = subst_strong(doc) + inlist = "" + lastempty = False + for line in doc.split('\n'): + empty = line == "" + + if line.startswith("| "): + line = EXAMPLE_FMT(code=line[2:]) + elif line.startswith("= "): + line = "@section " + line[2:] + elif line.startswith("== "): + line = "@subsection " + line[3:] + elif re.match("^([0-9]*[.)]) ", line): + if not inlist: + lines.append("@enumerate") + inlist = "enumerate" + line = line[line.find(" ")+1:] + lines.append("@item") + elif re.match("^[o*-] ", line): + if not inlist: + lines.append("@itemize %s" % {'o': "@bullet", + '*': "@minus", + '-': ""}[line[0]]) + inlist = "itemize" + lines.append("@item") + line = line[2:] + elif lastempty and inlist: + lines.append("@end %s\n" % inlist) + inlist = "" + + lastempty = empty + lines.append(line) + + if inlist: + lines.append("@end %s\n" % inlist) + return "\n".join(lines) + + +def texi_args(expr, key="data"): + """ + Format the functions/structure/events.. arguments/members + """ + if key not in expr: + return "" + + args = expr[key] + arg_list = [] + if isinstance(args, str):
scripts/qapi2texi.py line 145
Quoted 10 lines
scripts/qapi2texi.py new file +10
-0+ arg_list.append(args) + else: + for name, typ in args.iteritems(): + # optional arg + if name.startswith("*"): + name = name[1:] + arg_list.append("['%s': @var{%s}]" % (name, typ)) + # regular arg + else: + arg_list.append("'%s': @var{%s}" % (name, typ))
Inappropriate use of @var. @var is for metasyntactic variables, i.e. something that stands for another piece of text. typ isn't, it's the name of a specific QAPI type. I think you should use @code.
yes
This is the reason why the type names in qemu-qmp-ref.txt are often mangled, e.g.
-- Struct: VersionInfo { 'qemu': VERSIONTRIPLE, 'package': STR }
Right, we have format issue here. If we change it for @code, we get additional quotes in the text format. The simpler is to use no format or @t{}
Quoted 19 lines
scripts/qapi2texi.py new file +19
-0+ + return ", ".join(arg_list) + + +def texi_body(doc): + """ + Format the body of a symbol documentation: + - a table of arguments + - followed by "Returns/Notes/Since/Example" sections + """ + def _section_order(section): + return {"Returns": 0, + "Note": 1, + "Notes": 1, + "Since": 2, + "Example": 3, + "Examples": 3}[section] + + body = "@table @asis\n"
scripts/qapi2texi.py
Quoted 10 lines
scripts/qapi2texi.py new file +10
-0+ for arg, section in doc.args.iteritems(): + desc = str(section) + opt = '' + if desc.startswith("#optional"): + desc = desc[10:] + opt = ' *' + elif desc.endswith("#optional"): + desc = desc[:-10] + opt = ' *' + body += "@item @code{'%s'}%s\n%s\n" % (arg, opt,
texi_comment(desc))
Quoted 20 lines
scripts/qapi2texi.py new file +20
-0+ body += "@end table\n" + body += texi_comment(str(doc.body)) + + meta = sorted(doc.meta, key=lambda i: _section_order(i.name)) + for section in meta: + name, doc = (section.name, str(section)) + func = texi_comment + if name.startswith("Example"): + func = texi_example + + body += "\n@quotation %s\n%s\n@end quotation" % \ + (name, func(doc)) + return body + + +def texi_alternate(expr, doc): + """ + Format an alternate to texi + """ + args = texi_args(expr)
scripts/qapi2texi.py line 204
Quoted 10 lines
scripts/qapi2texi.py new file +10
-0+ body = texi_body(doc) + return STRUCT_FMT(type="Alternate", + name=doc.symbol, + attrs="[ " + args + " ]", + body=body) + + +def texi_union(expr, doc): + """ + Format an union to texi
I think it's "a union".
ok
scripts/qapi2texi.py line 212
Quoted 8 lines
scripts/qapi2texi.py new file +8
-0+ """ + attrs = "@{ " + texi_args(expr, "base") + " @}" + discriminator = expr.get("discriminator") + if not discriminator: + union = "Flat Union" + discriminator = "type" + else: + union = "Union"
Condition is backwards.
fixed
scripts/qapi2texi.py line 220
Quoted 8 lines
scripts/qapi2texi.py new file +8
-0+ attrs += " + '%s' = [ " % discriminator + attrs += texi_args(expr, "data") + " ]" + body = texi_body(doc) + + return STRUCT_FMT(type=union, + name=doc.symbol, + attrs=attrs, + body=body)
You're inventing syntax here. Example output:
-- Union: QCryptoBlockOpenOptions { QCryptoBlockOptionsBase } +
'format' = [ 'qcow': QCRYPTOBLOCKOPTIONSQCOW, 'luks':
QCRYPTOBLOCKOPTIONSLUKS ]
The options that are available for all encryption formats when opening an existing volume
Since: 2.6
-- Flat Union: ImageInfoSpecific { } + 'type' = [ 'qcow2':
IMAGEINFOSPECIFICQCOW2, 'vmdk': IMAGEINFOSPECIFICVMDK, 'luks':
QCRYPTOBLOCKINFOLUKS ]
A discriminated record of image format specific information structures.
Since: 1.7
Note that QCryptoBlockOpenOptions is actually a flat union, and ImageInfoSpecific a simple union. As I said, the condition is backwards.
The meaning of the attrs part is unobvious. Familiarity with schema syntax doesn't really help.
Could we simply use schema syntax here?
Union: QCryptoBlockOpenOptions {
'base': QCryptoBlockOptionsBase, 'discriminator': 'format',
'data': { 'qcow': QCryptoBlockOptionsQCow, 'luks':
QCryptoBlockCreateOptionsLUKS }
}
Doesn't look obvious either and pollute the documentation with schema-specific parameters.
If not: whatever format you use, you first need to explain it.
I am not sure my solution is the best and will remain, but ok let's try to document it for now.
Quoted 18 lines
scripts/qapi2texi.py new file +18
-0+ + +def texi_enum(expr, doc): + """ + Format an enum to texi + """ + for i in expr['data']: + if i not in doc.args: + doc.args[i] = '' + body = texi_body(doc) + return ENUM_FMT(name=doc.symbol, + body=body) + + +def texi_struct(expr, doc): + """ + Format a struct to texi + """
scripts/qapi2texi.py line 248
Quoted 10 lines
scripts/qapi2texi.py new file +10
-0+ args = texi_args(expr) + body = texi_body(doc) + attrs = "@{ " + args + " @}" + base = expr.get("base") + if base: + attrs += " + %s" % base + return STRUCT_FMT(type="Struct", + name=doc.symbol, + attrs=attrs, + body=body)
More syntax invention. Example output:
-- Struct: BlockdevOptionsReplication { 'mode': REPLICATIONMODE,
['top-id': STR] } + BlockdevOptionsGenericFormat
''mode''
the replication mode
''top-id'' *
In secondary mode, node name or device ID of the root node who owns the replication node chain. Must not be given in primary mode.
Driver specific block device options for replication
Since: 2.8
Meaning of the attrs part is perhaps more guessable here, but it's still guesswork.
The meaning of * after ''top-id'' is also unobvious.
Note the redundancy between the attrs part and the body: both state member names and optionalness. The body doesn't state member types and base type. If we fixed that, we could drop the attrs part and save us the trouble of defining and explaining a syntax for it.
Let me take a step back. This document is about the QMP wire format. There are no such things as simple and flat unions on the wire, only JSON objects. QMP introspection duly describes a type's JSON objects, not how it's defined in QAPI. I think QMP documentation should ideally do the same.
QMP introspection uses a common structure for struct, simple and flat
union: common members, variants, and if variants, then the common member that serves as tag. See introspect.json for details.
Base types are flattened away. Appropriate for introspection, but documentation shouldn't do that.
I wrote "ideally" because it's probably too big a step. I'm willing to settle for something less than ideal.
I don't have clear idea what to do here, so if we can leave that for later, that would be nice for me (I am already spending more time than I imagined I would on doc stuff)
Quoted 35 lines
scripts/qapi2texi.py new file +35
-0+ + +def texi_command(expr, doc): + """ + Format a command to texi + """ + args = texi_args(expr) + ret = expr["returns"] if "returns" in expr else "" + body = texi_body(doc) + return COMMAND_FMT(type="Command", + name=doc.symbol, + ret=ret, + args="(" + args + ")", + body=body) + + +def texi_event(expr, doc): + """ + Format an event to texi + """ + args = texi_args(expr) + body = texi_body(doc) + return COMMAND_FMT(type="Event", + name=doc.symbol, + ret="", + args="(" + args + ")", + body=body) + + +def texi_expr(expr, doc): + """ + Format an expr to texi + """ + (kind, _) = expr.items()[0] +
scripts/qapi2texi.py line 293
Quoted 10 lines
scripts/qapi2texi.py new file +10
-0+ fmt = {"command": texi_command, + "struct": texi_struct, + "enum": texi_enum, + "union": texi_union, + "alternate": texi_alternate, + "event": texi_event} + try: + fmt = fmt[kind] + except KeyError: + raise ValueError("Unknown expression kind '%s'" % kind)
The try / except converts one kind of error into another. What does that buy us? As far as I can tell, this shouldn't ever happen.
dropped
Quoted 20 lines
scripts/qapi2texi.py new file +20
-0+ + return fmt(expr, doc) + + +def texi(docs): + """ + Convert QAPI schema expressions to texi documentation + """ + res = [] + for doc in docs: + expr = doc.expr + if not expr: + res.append(texi_body(doc)) + continue + try: + doc = texi_expr(expr, doc) + res.append(doc) + except: + print >>sys.stderr, "error at @%s" % doc.info + raise
scripts/qapi2texi.py
Quoted 10 lines
scripts/qapi2texi.py new file +10
-0+ + return '\n'.join(res) + + +def main(argv): + """ + Takes schema argument, prints result to stdout + """ + if len(argv) != 2: + print >>sys.stderr, "%s: need exactly 1 argument: SCHEMA" %
argv[0]
docs/qapi-code-gen.txt QAPI parser does not). At present, there is no place
Quoted 13 lines
scripts/qapi2texi.py new file +8
-0+ sys.exit(1) + + schema = qapi.QAPISchema(argv[1], strict_doc=True) + print texi(schema.docs) + + +if __name__ == "__main__": + main(sys.argv)docs/qapi-code-gen.txt +0
-0@@ -45,16 +45,13 @@ QAPI parser does not). At present, there is no place
where a QAPI
Quoted 32 lines
docs/qapi-code-gen.txt +12
-10schema requires the use of JSON numbers or null. Comments are allowed; anything between an unquoted # and the following -newline is ignored. Although there is not yet a documentation -generator, a form of stylized comments has developed for consistently -documenting details about an expression and when it was added to the -schema. The documentation is delimited between two lines of ##, then -the first line names the expression, an optional overview is provided, -then individual documentation about each member of 'data' is provided, -and finally, a 'Since: x.y.z' tag lists the release that introduced -the expression. Optional members are tagged with the phrase -'#optional', often with their default value; and extensions added -after the expression was first released are also given a '(since +newline is ignored. The documentation is delimited between two lines +of ##, then the first line names the expression, an optional overview +is provided, then individual documentation about each member of 'data' +is provided, and finally, a 'Since: x.y.z' tag lists the release that +introduced the expression. Optional members are tagged with the +phrase '#optional', often with their default value; and extensions +added after the expression was first released are also given a '(since x.y.z)' comment. For example: ##@@ -73,12 +70,49 @@ x.y.z)' comment. For example: # (Since 2.0) # # Since: 0.14.0 + # + # Notes: You can also make a list: + # - with items + # - like this + #
docs/qapi-code-gen.txt x.y.z)' comment. For example: · line 87
Quoted 10 lines
docs/qapi-code-gen.txt +5
-0+ # Example: + # + # -> { "execute": ... } + # <- { "return": ... } + # ## { 'struct': 'BlockStats', 'data': {'*device': 'str', 'stats': 'BlockDeviceStats', '*parent': 'BlockStats', '*backing': 'BlockStats'} }
This example gives an idea of how to document struct types. But the reader is left guessing how to document other kinds of definitions. In particular, there's no mention of "Returns", "Note" and "Examples" sections anywhere in this file. As is, this could do for a tutorial, but this file is a *reference*, not a tutorial.
For a reference, we need to be more thorough. A doc comments section on its own seems advisable.
I guess doc comment examples are best added to the schema code examples in sections === Struct types ===, ..., === Events ===.
Careful review for completeness is advised.
So far we did quite fine with the generic example. I am not convinced we need to have doc comments for all kinds of types, it looks redundant to me.
Quoted 17 lines
docs/qapi-code-gen.txt +17
-0+It's also possible to create documentation sections, such as: + + ## + # = Section + # == Subsection + # + # Some text foo with *strong* and _emphasis_ + # 1. with a list + # 2. like that + # + # And some code: + # | $ echo foo + # | -> do this + # | <- get that + # + ## +
docs/qapi-code-gen.txt x.y.z)' comment. For example: · line 115
Quoted 10 lines
docs/qapi-code-gen.txt +10
-0+Text *foo* and _foo_ are for "strong" and "emphasis" styles (they do +not work over multiple lines). @foo is used to reference a symbol. + +Lines starting with the following characters and a space: +- | are examples +- = are top section +- == are subsection +- X. or X) are enumerations (X is any number) +- o/*/- are itemized list +
Is this doc markup documentation complete?
I think so
Is it related to any existing text markup language? Hmm, the commit message calls it "Markdown-like". Should we mention that here?
I'll use "annotations" instead in the doc
Is all markup valid in all contexts? For instance, is = Section valid in symbol blocks? What does | (or any markup for that matter) do within an Example section?
Example is verbatim
I improved a bit the doc based on your feedback. I'd suggest we iterate with additional patches later, I could use help.
Review
Quoted 4 lines
docs/qapi-code-gen.txt +0
-0The schema sets up a series of types, as well as commands and events that will use those types. Forward references are allowed: the parser scans in two passes, where the first pass learns all type names, and(quoted diff) +0
-0
b/tests/qapi-schema/doc-bad-args.err
tests/qapi-schema/doc-bad-args.err line 1
Quoted 6 lines
new file mode 100644
index 0000000..a55e003tests/qapi-schema/doc-bad-args.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-bad-args.json:1: Members documentation is not a
subset of API ['a', 'b'] > ['a']
Review
Quoted 1 line
(quoted diff) +0
-0
b/tests/qapi-schema/doc-bad-args.exit
Review
Quoted 7 lines
new file mode 100644
index 0000000..d00491ftests/qapi-schema/doc-bad-args.exit new file +1
-0@@ -0,0 +1 @@ +1(quoted diff) +0
-0
b/tests/qapi-schema/doc-bad-args.json
tests/qapi-schema/doc-bad-args.json line 6
Quoted 11 lines
new file mode 100644
index 0000000..26992eatests/qapi-schema/doc-bad-args.json new file +6
-0@@ -0,0 +1,6 @@ +## +# @foo: +# @a: a +# @b: b +## +{ 'command': 'foo', 'data': {'a': 'int'} }
The existing tests/qapi-schema/*.json explain what is being tested in a comment. Perhaps like this:
# Arguments listed in the doc comment must exist in the actual schema
##
# @foo:
...Likewise for other tests.
ok
Review
Quoted 1 line
(quoted diff) +0
-0
b/tests/qapi-schema/doc-bad-args.out
Review
Quoted 3 lines
new file mode 100644
index 0000000..e69de29(quoted diff) +0
-0
b/tests/qapi-schema/doc-bad-symbol.err
tests/qapi-schema/doc-bad-symbol.err line 1
Quoted 6 lines
new file mode 100644
index 0000000..9c969d1tests/qapi-schema/doc-bad-symbol.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-bad-symbol.json:1: Definition of 'foo' follows
documentation for 'food'
Review
Quoted 1 line
(quoted diff) +0
-0
b/tests/qapi-schema/doc-bad-symbol.exit
Review
Quoted 7 lines
new file mode 100644
index 0000000..d00491ftests/qapi-schema/doc-bad-symbol.exit new file +1
-0@@ -0,0 +1 @@ +1(quoted diff) +0
-0
b/tests/qapi-schema/doc-bad-symbol.json
Review
Quoted 10 lines
new file mode 100644
index 0000000..7255152tests/qapi-schema/doc-bad-symbol.json new file +4
-0@@ -0,0 +1,4 @@ +## +# @food: +## +{ 'command': 'foo', 'data': {'a': 'int'} }(quoted diff) +0
-0
b/tests/qapi-schema/doc-bad-symbol.out
Review
Quoted 3 lines
new file mode 100644
index 0000000..e69de29(quoted diff) +0
-0
b/tests/qapi-schema/doc-duplicated-arg.err
Review
Quoted 7 lines
new file mode 100644
index 0000000..88a272btests/qapi-schema/doc-duplicated-arg.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-duplicated-arg.json:4:1: 'a' arg duplicated(quoted diff) +0
-0
b/tests/qapi-schema/doc-duplicated-arg.exit
Review
Quoted 7 lines
new file mode 100644
index 0000000..d00491ftests/qapi-schema/doc-duplicated-arg.exit new file +1
-0@@ -0,0 +1 @@ +1(quoted diff) +0
-0
b/tests/qapi-schema/doc-duplicated-arg.json
Review
Quoted 11 lines
new file mode 100644
index 0000000..f7804c2tests/qapi-schema/doc-duplicated-arg.json new file +5
-0@@ -0,0 +1,5 @@ +## +# @foo: +# @a: +# @a: +##(quoted diff) +0
-0
b/tests/qapi-schema/doc-duplicated-arg.out
Review
Quoted 3 lines
new file mode 100644
index 0000000..e69de29(quoted diff) +0
-0
b/tests/qapi-schema/doc-duplicated-return.err
tests/qapi-schema/doc-duplicated-return.err line 1
Quoted 6 lines
new file mode 100644
index 0000000..1b02880tests/qapi-schema/doc-duplicated-return.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-duplicated-return.json:5:1: Duplicated 'Returns'
section
Review
Quoted 1 line
(quoted diff) +0
-0
b/tests/qapi-schema/doc-duplicated-return.exit<br class="gmail_msg
Signature · 1 line
Marc-André Lureau
Re: [Qemu-devel] [PATCH v5 13/17] qapi: add qapi2texi script
I had to resort to diff to find your replies, and massage the text manually to produce a readable reply myself. Please quote the usual way.
Quoted 410 lines
Quoted 38 lines · Markus Armbruster
Quoted 25 lines · Marc-André Lureau
As the name suggests, the qapi2texi script converts JSON QAPI description into a texi file suitable for different target formats (info/man/txt/pdf/html...).
It parses the following kind of blocks:
Free-form:
##
# = Section
# == Subsection
#
# Some text foo with *emphasis*
# 1. with a list
# 2. like that
#
# And some code:# | $ echo foo # | -> do this # | <- get that#
##Symbol:
Quoted 8 lines
##
# @symbol:
#
# Symbol body ditto ergo sum. Foo bar# baz ding. # # @arg: foo # @arg: #optional fooLet's not use @arg twice.
Quoted 8 lines
Terminology: I prefer to use "parameter" for formal parameters, and "argument" for actual arguments. This matches how The Python Language Reference uses the terms.
What about
# @param1: the frob to frobnicate
# @param2: #optional how hard to frobnicateok
Quoted 4 lines
Quoted 3 lines
#
# Returns: returns bla bla
# Or bla blahQuoted 8 lines
Repeating "returns" is awkward, and we don't do that in our schemas.
We need a period before "Or", or spell it "or".
What about
# Returns: the frobnicated frob.
# If frob isn't frobnicatable, GenericError.ok
Quoted 20 lines
Quoted 13 lines
#
# Since: version
# Notes: notes, comments can have
# - itemized list
# - like this
#
# Example:
#
# -> { "execute": "quit" }
# <- { "return": {} }
#
##Quoted 6 lines
That's roughly following the following EBNF grammar:
api_comment= "##\n" comment "##\n"
comment =freeform_comment|symbol_commentfreeform_comment= { "# " text "\n" | "#\n" }symbol_comment= "# @" name ":\n" { member | meta |freeform_comment}Quoted 6 lines
Rejects non-empty comments where "#" is not followed by space. Such usage is accepted outside doc comments. Hmm.
Quoted 1 line
member = "# @" name ':' [ text ]
freeform_commentAre you missing a "\n" before
freeform_comment?yes
Quoted 3 lines
Quoted 1 line
meta = "# " ( "Returns:", "Since:", "Note:", "Notes:", "Example:", "Examples:" ) [ text ]
freeform_commentLikewise.
ok
Quoted 7 lines
Quoted 1 line
text = free-text markdown-like, "#optional" for members
The grammar is ambiguous: a line "# @foo:\n" can be parsed both as
freeform_commentand assymbol_comment. Since your intent is obvious enough, it can still serve as documentation. It's not a suitable foundation for parsing, though. Okay for a commit message.Quoted 6 lines
Quoted 3 lines
Thanks to the following json expressions, the documentation is enhanced with extra information about the type of arguments and return value expected.
I guess you want to say that we enrich the documentation we extract from comments with information from the actual schema. Correct?
yes
Quoted 81 lines
Missing: a brief discussion of deficiencies. These include:
* The generated QMP documentation includes internal types
We use qapi-schema.json both for defining the external QMP interface and for defining internal types.
qmp-introspect.pycarefully separates the two, to not expose internal types.qapi2texi.pyhappily exposes everything.Currently, about a fifth of the types in the generated docs are internal:
AcpiTableOptions
BiosAtaTranslation
BlockDeviceMapEntry
COLOMessage
COLOMode
DummyForceArrays
FailoverStatus
FloppyDriveType
ImageCheck
LostTickPolicy
MapEntry
MigrationParameter
NetClientDriver
NetFilterDirection
NetLegacy
NetLegacyNicOptions
NetLegacyOptions
NetLegacyOptionsKind
Netdev
NetdevBridgeOptions
NetdevDumpOptions
NetdevHubPortOptions
NetdevL2TPv3Options
NetdevNetmapOptions
NetdevNoneOptions
NetdevSocketOptions
NetdevTapOptions
NetdevUserOptions
NetdevVdeOptions
NetdevVhostUserOptions
NumaNodeOptions
NumaOptions
NumaOptionsKind
OnOffAuto
OnOffSplit
PreallocMode
QCryptoBlockCreateOptions
QCryptoBlockCreateOptionsLUKS
QCryptoBlockFormat
QCryptoBlockInfo
QCryptoBlockInfoBase
QCryptoBlockInfoQCow
QCryptoBlockOpenOptions
QCryptoBlockOptionsBase
QCryptoBlockOptionsLUKS
QCryptoBlockOptionsQCow
QCryptoSecretFormat
QCryptoTLSCredsEndpoint
QapiErrorClass
ReplayMode
X86CPUFeatureWordInfo
X86CPURegister32Generating documentation for internal types might be useful, but letting them pollute QMP interface documentation isn't. Needs fixing before we release. Until then, needs a FIXME comment in
qapi2texi.py.* Union support is lacking
The doc string language is adequate for documenting commands, events, and non-union types. It doesn't really handle union variants. Hardly surprising, as you fitted the language do existing practice, and existing (mal-)practice is neglecting to document union variant members.
* Documentation is lacking
See review of qapi-code-gen.txt below.
Quoted 8 lines
* Doc comment error message positions are imprecise
They always point to the beginning of the comment.
* Probably more
We should update this with noteworthy findings during review. I tried, but I suspect I missed some.
ok
Quoted 46 lines
Quoted 1 line
Signed-off-by Marc-André Lureau <[email protected]>[Lengthy diffstat snipped...]
Quoted 44 lines
tests/Makefile.include +17
-0@@ -350,6 +350,21 @@ qapi-schema += base-cycle-direct.json qapi-schema += base-cycle-indirect.json qapi-schema += command-int.json qapi-schema += comments.json +qapi-schema += doc-bad-args.json +qapi-schema += doc-bad-symbol.json +qapi-schema += doc-duplicated-arg.json +qapi-schema += doc-duplicated-return.json +qapi-schema += doc-duplicated-since.json +qapi-schema += doc-empty-arg.json +qapi-schema += doc-empty-section.json +qapi-schema += doc-empty-symbol.json +qapi-schema += doc-invalid-end.json +qapi-schema += doc-invalid-end2.json +qapi-schema += doc-invalid-return.json +qapi-schema += doc-invalid-section.json +qapi-schema += doc-invalid-start.json +qapi-schema += doc-missing-expr.json +qapi-schema += doc-missing-space.json qapi-schema += double-data.json qapi-schema += double-type.json qapi-schema += duplicate-key.json@@ -443,6 +458,8 @@ qapi-schema += union-optional-branch.json qapi-schema += union-unknown.json qapi-schema += unknown-escape.json qapi-schema += unknown-expr-key.json + + check-qapi-schema-y := $(addprefix tests/qapi-schema/, $(qapi-schema)) GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h \scripts/qapi.py +0
-0@@ -122,6 +122,109 @@ class QAPILineError(Exception): "%s:%d: %s" % (self.info['file'], self.info['line'], self.msg)Quoted 5 lines
scripts/qapi.py class QAPILineError(Exception): · line 127
Quoted 3 lines
scripts/qapi.py +3
-0+class QAPIDoc(object): + class Section(object): + def __init__(self, name=""):name=None feels more natural than "" for an absent optional name.
ok
Quoted 5 lines
scripts/qapi.py class QAPILineError(Exception): · line 130
Quoted 3 lines
scripts/qapi.py +3
-0+ # optional section name (argument/member or section name) + self.name = name + # the list of strings for this sectionWould "list of lines" be more accurate, or less?
more accurate, ok
Quoted 8 lines
Quoted 8 lines
scripts/qapi.py +8
-0+ self.content = [] + + def append(self, line): + self.content.append(line) + + def __repr__(self): + return "\n".join(self.content).strip() +Quoted 8 lines
scripts/qapi.py class QAPILineError(Exception): · line 140
Quoted 2 lines
scripts/qapi.py +2
-0+ class ArgSection(Section): + passBegs the question what makes ArgSection differ from Section. I think it's the semantics of self.name: an ArgSection's name is the parameter name, a non-ArgSection can either be a "meta" section (name is one of "Returns"", "Since", "Note", "Notes", "Example", "Examples") or an anonymous section (name is "").
yes, and the section type is checked in
_append_freeform()Quoted 10 lines
scripts/qapi.py class QAPILineError(Exception): · line 146
Quoted 6 lines
scripts/qapi.py +6
-0+ + def __init__(self, parser): + self.parser = parser + self.symbol = None + self.body = QAPIDoc.Section() + # a dict {'arg': ArgSection, ...}Works. Alternatevely:
# dict mapping parameter name to ArgSectionok
Quoted 8 lines
scripts/qapi.py class QAPILineError(Exception): · line 152
Quoted 6 lines
scripts/qapi.py +6
-0+ self.args = OrderedDict() + # a list of Section + self.meta = [] + # the current section + self.section = self.body + # associated expression and info (set by expression parser)"will be set by expression parser", or "to be set by expression parser"?
ok
Quoted 8 lines
scripts/qapi.py class QAPILineError(Exception): · line 154
Quoted 2 lines
scripts/qapi.py +2
-0+ self.expr = None + self.info = NoneClearer now. The one remark I still have is on the use of "meta" isn't obvious here. I think a comment further up explaining the different kinds of sections would help.
To be honest, I don't get what's "meta" about the "meta" sections :)
Let's drop that distinction, it isn't necessary anymore
Quoted 12 lines
scripts/qapi.py class QAPILineError(Exception): · line 157
Quoted 3 lines
scripts/qapi.py +3
-0+ + def has_meta(self, name): + """Returns True if the doc has a meta section 'name'"""PEP257[1] demands imperative mood, and punctuation:
"""Return True if the doc has a meta section 'name'."""
Unfortunately, there seems to be no established convention for marking parameter names. You put this one in single quotes, which works here, but could be confusing in other cases. I'd sidestep it:
Quoted 5 lines
"""Return True if we have a meta section with this name."""
or
"""Does a meta section with this name exist?"""
ok
Quoted 34 lines
scripts/qapi.py class QAPILineError(Exception): · line 164
Quoted 7 lines
scripts/qapi.py +7
-0+ for i in self.meta: + if i.name == name: + return True + return False + + def append(self, line): + """Adds a # comment line, to be parsed and added to current section"""Imperative mood:
"""Add a comment line, to be parsed and added to the current section."""
However, we're not always adding to the current section, we can also start a new one. The following avoids suggesting anything about the current section:
"""Parse a comment line and add it to the documentation."""
When the function name is a verb, and its doc string starts with a different verb, the name might be suboptimal. Use your judgement.
If this one-liner is too terse, we can try a multi-line doc string:
"""Parse a comment line and add it to the documentation.
TODO should we tell more about how we parse?
Args:
line: the comment starting with '#', with the newline stripped.Raises:
QAPISchemaError: TODO explain error conditions
"""Quoted 6 lines
Format stolen from the Google Python Style Guide[2], because PEP257 is of not much help there.
Once you start with such elaborate doc strings, pressure will likely mount to do the same elsewhere. Could be a distraction right now. Use your judgement.
ok, thanks
Quoted 22 lines
scripts/qapi.py class QAPILineError(Exception): · line 172
Quoted 8 lines
scripts/qapi.py +8
-0+ line = line[1:] + if not line: + self._append_freeform(line) + return + + if line[0] != ' ': + raise QAPISchemaError(self.parser, "missing space after #") + line = line[1:]QAPISchemaError takes the error position from its QAPISchemaParser argument. In other words, the error position depends on the state of the parser when it calls this function. Turns out the position is the beginning of the comment. Servicable here. Action at a distance, though.
Less strict:
# strip leading # and space line = line[1:] if line[0] == ' ': line = line[1:]
Quoted 4 lines
Quoted 1 line
Also avoids special-casing empty comments.
That would raise "IndexError: string index out of range" on empty comment lines ("#")
Fixable:
if line.startswith(' '):
Quoted 2 lines
Also I'd like to keep the error in case a space is missing (it caught some already).
On the one hand, I share your distaste for lack of space between # and comment text. On the other hand, I dislike enforcing spacing
inconsistently: enforce in doc comments, but not in other comments.
Quoted 7 lines
Quoted 5 lines
Perhaps we should treat all leading whitespace the same (I'm not sure):
# strip leading # and whitespace line = line[1:] line = line.lstrip()That would break indentation in Example sections
True; scratch the idea.
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
scripts/qapi.py +8
-0+ + if self.symbol: + self._append_symbol_line(line) + elif (not self.body.content and + line.startswith("@") and line.endswith(":")): + self.symbol = line[1:-1] + if not self.symbol: + raise QAPISchemaError(self.parser, "Invalid symbol")
Quoted 8 lines
Quoted 5 lines
Doesn't recognize the symbol when there's anything other than a single space between # and @. Pathological case: '#\t@foo:' starting in column 6 looks exactly like '# @foo:', but doesn't work. Fortunately, your code rejects the tab there. Assigning meaning to (leading) whitespace may make sense, but it must be documented clearly.
I think it's simpler to only accept a simple space (# + space + @ + symbol
+ :), it will also lead to more uniform doc.
Simpler is always an argument worth considering, but simpler isn't always better. Experience with other languages has taught me to be carefule when making the kind or amount of whitespace significant.
Kind of whitespace is not a usability issue with your proposal, because your patch rejects anything but space.
Amount of whitespace is, because getting it wrong turns a symbol comment block into a free-form comment block, or a parameter section into free-form lines belonging to whatever section precedes it.
As long as we reject definitions without a symbol comment, errors of the former kind will still be caught, although the error message could be confusing.
As is, we don't reject definitions whose symbol comment fails to document all parameters. Errors of the latter kind will therefore go undetected. Trap for the unwary. See also "@param2 is True" below.
If we can't find a solution without such usability issues now, then I'm willing to settle for documentation warning unwary users, or even for a FIXME comment.
Quoted 11 lines
Quoted 10 lines
Doesn't recognize the symbol when there's crap after ":". Confusing when it's invisible crap, i.e. trailing whitespace. In general, it's best to parse left to right, like this:
elif not self.body.content and
line.startswith('@'):
match =valid_name.match(line[1:]);
if not match:
raiseQAPISchemaError(self.parser, 'Invalid name')
ifline.startswith(':', match.end(0)):
raiseQAPISchemaError(self.parser, 'Expected ":")
Quoted 5 lines
Easier is simply to check :
if notline.endswith(":"):
raiseQAPIParseError(self.parser, "Line should end with :")test added
There's a reason we have a mountain of theory on parsing, built in decades of practice. What starts "easier" than that generally ends up rewritten from scratch. Anyway, let's continue.
Quoted 11 lines
Quoted 9 lines
Here, the error position is clearly suboptimal: it's the beginning of the comment instead of where the actual error is, namely the beginning / the end of the name. More of the same below. The root cause is stacking parsers. I'm not asking you to do anything about it at this time.
Note my use of "name" rather than "symbol" in the error message. qapi-code-gen.txt talks about names, not symbols. Consistent use of terminology matters.
Agree, isn't "symbol" more appropriate for documentation though?
Possibly. But if it's an improvement for generated documentation, it surely is an improvement for hand-written documentation such as qapi-code-gen.txt and the comments in qapi*.py, too. And the Python identifiers. I have to admit that cools my enthusiasm for making the improvement right now :)
Quoted 22 lines
Quoted 22 lines
scripts/qapi.py class QAPILineError(Exception): · line 189
Quoted 9 lines
scripts/qapi.py +9
-0+ else: + self._append_freeform(line) + + def _append_symbol_line(self, line): + name = line.split(' ', 1)[0] + + if name.startswith("@") and name.endswith(":"): + line = line[len(name)+1:] + self._start_args_section(name[1:-1])Similar issue. Left to right:
if re.match(r'\s*@', line): match = valid_name.match(line[1:]); if not match: raise QAPISchemaError(self.parser, 'Invalid parameter name') line = line[match.end(0):] if line.startswith(':'): raise QAPISchemaError(self.parser, 'Expected ":") line = line[1:] self._start_args_section(match.group(0))
Quoted 6 lines
Quoted 1 line
Even better would be factoring out the common code to parse '@foo:'.
It's a valid case to have a section freeform comment starting with @foo, ex:
@param: do this and than if
@param2 is True
Good point, but it's a language issue, not a parsing issue.
The language issue is that we need to recognize a line "# @param: ..." as the start of a parameter section, while still permitting free-form lines like "# @param2 is True".
This is a pretty convincing argument for requiring the ':'. It can also be used as an argument for requiring exactly one space between # and @.
How the language is parsed is completely orthogonal.
Quoted 173 lines
I don't think it's worth to factor out the code to parse @foo vs @foo:, yet
Quoted 8 lines
scripts/qapi.py class QAPILineError(Exception): · line 195
Quoted 6 lines
scripts/qapi.py +6
-0+ elif name in ("Returns:", "Since:", + # those are often singular or plural + "Note:", "Notes:", + "Example:", "Examples:"): + line = line[len(name)+1:] + self._start_meta_section(name[:-1])Since we're re.match()ing already, here's how do to it that way:
I don't follow your suggestion for the reason above,so I still have the first word 'name'
Quoted 5 lines
else match = re.match(r'\s*(Returns|Since|Notes?|Examples?):', line) if match: line = line[match.end(0):] self._start_meta_section(match.group(1))not really much nicer to me (especially because no match yet), I'll keep the current code for now
Quoted 8 lines
scripts/qapi.py class QAPILineError(Exception): · line 201
Quoted 6 lines
scripts/qapi.py +6
-0+ + self._append_freeform(line) + + def _start_args_section(self, name): + if not name: + raise QAPISchemaError(self.parser, "Invalid argument name")parameter name
ok
Quoted 4 lines
scripts/qapi.py class QAPILineError(Exception): · line 203
Quoted 2 lines
scripts/qapi.py +2
-0+ if name in self.args: + raise QAPISchemaError(self.parser, "'%s' arg duplicated" % name)Duplicate parameter name
ok
Quoted 17 lines
Quoted 4 lines
scripts/qapi.py +4
-0+ self.section = QAPIDoc.ArgSection(name) + self.args[name] = self.section + + def _start_meta_section(self, name):scripts/qapi.py class QAPILineError(Exception): · line 217
Quoted 10 lines
scripts/qapi.py +10
-0+ if name in ("Returns", "Since") and self.has_meta(name): + raise QAPISchemaError(self.parser, + "Duplicated '%s' section" % name) + self.section = QAPIDoc.Section(name) + self.meta.append(self.section) + + def _append_freeform(self, line): + in_arg = isinstance(self.section, QAPIDoc.ArgSection) + if in_arg and self.section.content and not self.section.content[-1] \ + and line and not line[0].isspace():PEP8[3] prefers parenthesises over backslash:
Quoted 2 lines
if (
in_argand self.section.content and not self.section.content[-1]
and line and not line[0].isspace()):yes, thanks
Quoted 67 lines
scripts/qapi.py class QAPILineError(Exception): · line 222
Quoted 5 lines
scripts/qapi.py +5
-0+ # an empty line followed by a non-indented + # comment ends the argument section + self.section = self.body + self._append_freeform(line) + returnSwitching back to the self.body section like this reorders the documentation text. I still think this is a terrible idea. A dumb script is exceedingly unlikely to improve human-written doc comment text by reordering. In the rare case it does, the doc comment source should be reordered.
Here's an example where the doc generator happily creates unintelligible garbage if I format CpuDefinitionInfo's doc comment in a slightly off way:
##
# @CpuDefinitionInfo:
#
# Virtual CPU definition.
#
# @name: the name of the CPU definition
#
# @migration-safe: #optional whether a CPU definition can be safely # used for migration in combination with a QEMU compatibility # machine when migrating between different QMU versions and between # hosts with different sets of (hardware or software)
# capabilities.
#
# If not provided, information is not available and callers should # not assume the CPU definition to be migration-safe. (since 2.8) #
# @static: whether a CPU definition is static and will not change # depending on QEMU version, machine type, machine options and # accelerator options. A static model is always
# migration-safe. (since 2.8)
#
# @unavailable-features: #optional List of properties that prevent # the CPU model from running in the current host. (since 2.8) #
# @unavailable-features is a list of QOM property names that # represent CPU model attributes that prevent the CPU from running. # If the QOM property is read-only, that means there's no known # way to make the CPU model run in the current host. Implementations # that choose not to provide specific information return the # property name "type".
#
# If the property is read-write, it means that it MAY be possible # to run the CPU model in the current host if that property is # changed. Management software can use it as hints to suggest or # choose an alternative for the user, or just to generate meaningful # error messages explaining why the CPU model can't be used. # If @unavailable-features is an empty list, the CPU model is # runnable using the current host and machine-type.
# If @unavailable-features is not present, runnability
# information for the CPU is not available.
#
# Since: 1.2.0
##
{ 'struct': 'CpuDefinitionInfo',
'data': { 'name': 'str', '*migration-safe': 'bool', 'static': 'bool',
'*unavailable-features': [ 'str' ] } }To detect the problem, you have to read the generated docs attentively. You know my opinion on our chances for that to happen during development.
Quoted 7 lines
My point is not that we should support this doc comment format. My point is that people could conceivably write something like it, and not get caught in patch review.
I can see three ways out of this swamp:
1. Let sections continue until another one begins.
but we have interleaved sections, and no explicit "body" section tag, ex:
##
# @input-send-event:
#
# Send input event(s) to guest.
#
# @device: #optional display device to send event(s) to.
# @head: #optional head to send event(s) to, in case the
# display device supports multiple scanouts.
# @events: List of InputEvent union.
#
# Returns: Nothing on success.
#
# The @device and @head parameters can be used to send the input event# to specific input devices in case (a) multiple input devices of the # same kind are added to the virtual machine and (b) you have # configured input routing (see docs/multiseat.txt) for those input # ....Quoted 3 lines
2. Make text between sections an error.
3. When a section ends, start a new anonymous section.
It's not clear how to recognize when a section ends and append to comment body.
2. Make text between sections an error.
Sound like the best option to me. I'll fix the doc and add a check & test for this common pattern though:
##
# @TestStruct:
#
Quoted 9 lines
# body with @var # # @integer: foo # blah # # bao # # Let's catch this bad comment. ##
Go ahead.
Quoted 14 lines
Quoted 14 lines
Can't say offhand which one will work best.
scripts/qapi.py class QAPILineError(Exception): · line 224
Quoted 2 lines
scripts/qapi.py +2
-0+ if in_arg or not self.section.name.startswith("Example"): + line = line.strip()Stripping whitespace is not "Markdown-like", because intendation carries meaning in Markdown. Example:
* First item in itemized list
* Second item
* Sub-item of second item
* Another sub-item
* Third item
Quoted 5 lines
Quoted 3 lines
Stripping whitespace destroys the list structure. If that's what you want, you get to document where your "Markdown-like" markup is unlike Markdown :)
let's use "comment annotations" instead
Okay.
Quoted 120 lines
Quoted 17 lines
Is there a technical reason for stripping whitespace?
See also discussion of space after # above.
Quoted 13 lines
scripts/qapi.py +4
-0+ self.section.append(line) + + class QAPISchemaParser(object): def __init__(self, fp, previously_included=[], incl_info=None):@@ -137,11 +240,18 @@ class QAPISchemaParser(object): self.line = 1 self.line_pos = 0 self.exprs = [] + self.docs = [] self.accept()Quoted 6 lines
scripts/qapi.py class QAPISchemaParser(object): · line 249
Quoted 4 lines
scripts/qapi.py +1
-0while self.tok is not None: info = {'file': fname, 'line': self.line, 'parent': self.incl_info} + if self.tok == '#' and self.val.startswith('##'):How can self.val *not* start with '##' here?
you are right, unnecessary condition since we break
get_expr()only in this case nowQuoted 6 lines
scripts/qapi.py class QAPISchemaParser(object): · line 251
Quoted 2 lines
scripts/qapi.py +2
-0+ doc = self.get_doc() + doc.info = infoLet's pass info as argument to
get_doc(), so we don't have to dot into doc here.get_doc()can avoid dotting into doc by passing info to the constructor.ok
Quoted 23 lines
Quoted 23 lines
scripts/qapi.py +6
-0+ self.docs.append(doc) + continue + expr = self.get_expr(False) if isinstance(expr, dict) and "include" in expr: if len(expr) != 1:@@ -160,6 +270,7 @@ class QAPISchemaParser(object): raise QAPILineError(info, "Inclusion loop for %s" % include) inf = inf['parent'] + # skip multiple include of the same file if incl_abs_fname in previously_included: continue@@ -171,12 +282,38 @@ class QAPISchemaParser(object): exprs_include = QAPISchemaParser(fobj, previously_included, info) self.exprs.extend(exprs_include.exprs) + self.docs.extend(exprs_include.docs) else: expr_elem = {'expr': expr, 'info': info} + if self.docs and not self.docs[-1].expr:Quoted 8 lines
scripts/qapi.py class QAPISchemaParser(object): · line 292
Quoted 3 lines
scripts/qapi.py +3
-0+ self.docs[-1].expr = expr + expr_elem['doc'] = self.docs[-1] +Attaches the expression to the last doc comment that doesn't already have one. A bit sloppy, because there could be non-doc comments in between, or the doc comment could be in another file. It'll do, at least for now.
I extended the condition to check it attaches the doc from the same file
Quoted 17 lines
Quoted 17 lines
scripts/qapi.py +14
-1self.exprs.append(expr_elem) - def accept(self): + def get_doc(self): + if self.val != '##': + raise QAPISchemaError(self, "Junk after '##' at start of " + "documentation comment") + + doc = QAPIDoc(self) + self.accept(False) + while self.tok == '#': + if self.val.startswith('##'): + # End of doc comment + if self.val != '##': + raise QAPISchemaError(self, "Junk after '##' at end of " + "documentation comment") + self.accept()Quoted 8 lines
scripts/qapi.py class QAPISchemaParser(object): · line 314
Quoted 6 lines
scripts/qapi.py +6
-0+ return doc + else: + doc.append(self.val) + self.accept(False) + + raise QAPISchemaError(self, "Documentation comment must end with '##'")Let's put this after accept, next to the other
get_FOO().ok
Quoted 22 lines
Quoted 9 lines
scripts/qapi.py +2
-0+ + def accept(self, skip_comment=True): while True: self.tok = self.src[self.cursor] self.pos = self.cursor@@ -184,7 +321,13 @@ class QAPISchemaParser(object): self.val = None if self.tok == '#':scripts/qapi.py class QAPISchemaParser(object): · line 333
Quoted 10 lines
scripts/qapi.py +6
-0+ if self.src[self.cursor] == '#': + # Start of doc comment + skip_comment = False self.cursor = self.src.find('\n', self.cursor) + if not skip_comment: + self.val = self.src[self.pos:self.cursor] + return elif self.tok in "{}:,[]": return elif self.tok == "'":Copied from review of v3, so I don't forget:
Quoted 8 lines
Quoted 6 lines
Comment tokens are thrown away as before, except when the parser asks for them by passing skip_comment=False, or when the comment token starts with ##. The parser asks while parsing a doc comment, in
get_doc().This is a backchannel from the parser to the lexer. I'd rather avoid such lexer hacks, but I guess we can address that on top.
I don't have a good solution to that
I have an idea which may or may not work. I can explore it on top.
Quoted 39 lines
Quoted 12 lines
A comment starting with ## inside an expression is now a syntax error. For instance, input
{ ##yields
/dev/stdin:2:1: Expected string or "}"Rather unfriendly error message, but we can fix that on top.
Quoted 8 lines
scripts/qapi.py def check_keys(expr_elem, meta, required, optional=[]): · line 859
Quoted 6 lines
scripts/qapi.py +1
-1@@ -713,7 +856,7 @@ def check_keys(expr_elem, meta, required, optional=[]): % (key, meta, name)) -def check_exprs(exprs): +def check_exprs(exprs, strict_doc):Note: strict_doc=False unless this is
qapi2texi.py.For tests reasons: we may want to fix the test instead, or have a flag QAPI_CHECK/NOSTRICT_DOC=1 or an option.
Quoted 14 lines
scripts/qapi.py def check_exprs(exprs): · line 872
Quoted 12 lines
scripts/qapi.py +5
-0global all_names # Learn the types and check for valid expression keys@@ -722,6 +865,11 @@ def check_exprs(exprs): for expr_elem in exprs: expr = expr_elem['expr'] info = expr_elem['info'] + + if strict_doc and 'doc' not in expr_elem: + raise QAPILineError(info, + "Expression missing documentation comment") +Why should we supress this error in programs other than
qapi2texi.py?
Quoted 1 line
because the tests don't have comments
Good point :)
Can we come up with a brief comment explaining this?
Quoted 88 lines
Quoted 1 line
Can't see a test for this one.
because tests aren't strict :)
I guess you'll tell me to fix the tests instead, so I did that in the next series.
Quoted 11 lines
scripts/qapi.py def check_exprs(exprs): · line 931
Quoted 8 lines
scripts/qapi.py +1
-0if 'enum' in expr: check_keys(expr_elem, 'enum', ['data'], ['prefix']) add_enum(expr['enum'], info, expr['data'])@@ -780,6 +928,63 @@ def check_exprs(exprs): return exprs +def check_simple_doc(doc):You call this "free-form" elsewhere. Pick one name and stick to it. I think free-form is more descriptive than simple.
ok
Quoted 6 lines
scripts/qapi.py def check_exprs(exprs): · line 935
Quoted 4 lines
scripts/qapi.py +4
-0+ if doc.symbol: + raise QAPILineError(doc.info, + "'%s' documention is not followed by the definition" + % doc.symbol)"Documentation for %s is not ..."
ok
Quoted 11 lines
scripts/qapi.py def check_exprs(exprs): · line 943
Quoted 8 lines
scripts/qapi.py +8
-0+ + body = str(doc.body) + if re.search(r'@\S+:', body, re.MULTILINE): + raise QAPILineError(doc.info, + "Document body cannot contain @NAME: sections") + + +def check_expr_doc(doc, expr, info):You call this "symbol" elsewhere. I think "definition" would be better than either.
ok
Quoted 12 lines
scripts/qapi.py def check_exprs(exprs): · line 954
Quoted 11 lines
scripts/qapi.py +11
-0+ for i in ('enum', 'union', 'alternate', 'struct', 'command', 'event'): + if i in expr: + meta = i + break + + name = expr[meta] + if doc.symbol != name: + raise QAPILineError(info, "Definition of '%s' follows documentation" + " for '%s'" % (name, doc.symbol)) + if doc.has_meta('Returns') and 'command' not in expr: + raise QAPILineError(info, "Invalid return documentation")Quoted 5 lines
Suggest something like "'Returns:' is only valid for commands".
We accept 'Returns:' even when the command doesn't return anything, because we currently use it to document errors, too. Can't say I like that, but it's out of scope here.
ok
Quoted 16 lines
scripts/qapi.py def check_exprs(exprs): · line 963
Quoted 9 lines
scripts/qapi.py +9
-0+ + doc_args = set(doc.args.keys()) + if meta == 'union': + data = expr.get('base', []) + else: + data = expr.get('data', []) + if isinstance(data, dict): + data = data.keys() + args = set([name.strip('*') for name in data])Not fixed since v3:
* Flat union where 'base' is a string, e.g. union UserDefFlatUnion in qapi-schema-test.json has base 'UserDefUnionBase', args is
set(['a', 'B', 'e', 'D', 'f', 'i', 'o', 'n', 's', 'r', 'U'])Quoted 6 lines
* Command where 'data' is a string, e.g.
user_def_cmd0in qapi-schema-test.json has data 'Empty2', args isset(['E', 'm', 'p', '2', 't', 'y'])* Event where 'data' is a string, no test case handy (hole in test coverage)
ok, I changed it that way, that fixes it:
scripts/qapi.py def check_exprs(exprs):
Quoted 4 lines
scripts/qapi.py +4
-0+ if isinstance(data, list): + args = set([name.strip('*') for name in data]) + else: + args = set()
Uh, sure this does the right thing when data is a dict?
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
scripts/qapi.py +3
-0+ if meta == 'alternate' or \ + (meta == 'union' and not expr.get('discriminator')): + args.add('type')
Quoted 8 lines
Quoted 4 lines
As explained in review of v3, this is only a subset of the real set of members. Computing the exact set is impractical when working with the abstract syntax tree. I believe we'll eventually have to rewrite this code to work with the QAPISchemaEntity instead.
I don't think we want to list all the members as this would lead to duplicated documentation. Instead it should document only the members of the expr being defined.
You're sticking to established practice, which makes lots of sense. However, established practice is a lot more clear for simple cases than for things like members inherited from base types, variant members and such. At some point, we'll have to figure out how we want not so simple cases documented. Until then, we can't really decide how to check documentation completeness.
Quoted 2 lines
In which case, it looks like this check is good
enough, no?
For now, yes. Later on, maybe.
Let's document the limitation in a comment and the commit message, and move on.
Quoted 199 lines
Quoted 188 lines
scripts/qapi2texi.py
Quoted 43 lines
scripts/qapi.py +25
-2+ if not doc_args.issubset(args): + raise QAPILineError(info, "Members documentation is not a subset of" + " API %r > %r" % (list(doc_args), list(args))) + + +def check_docs(docs): + for doc in docs: + for section in doc.args.values() + doc.meta: + content = str(section) + if not content or content.isspace(): + raise QAPILineError(doc.info, + "Empty doc section '%s'" % section.name) + + if not doc.expr: + check_simple_doc(doc) + else: + check_expr_doc(doc, doc.expr, doc.info) + + return docs + + # # Schema compiler frontend #@@ -1249,9 +1454,11 @@ class QAPISchemaEvent(QAPISchemaEntity): class QAPISchema(object): - def __init__(self, fname): + def __init__(self, fname, strict_doc=False): try: - self.exprs = check_exprs(QAPISchemaParser(open(fname, "r")).exprs) + parser = QAPISchemaParser(open(fname, "r")) + self.exprs = check_exprs(parser.exprs, strict_doc) + self.docs = check_docs(parser.docs) self._entity_dict = {} self._predefining = True self._def_predefineds()scripts/qapi2texi.py new file +0
-0Still only skimming this one.
Quoted 142 lines
scripts/qapi2texi.py new file +141
-0@@ -0,0 +1,331 @@ +#!/usr/bin/env python +# QAPI texi generator +# +# This work is licensed under the terms of the GNU LGPL, version 2+. +# See the COPYING file in the top-level directory. +"""This script produces the documentation of a qapi schema in texinfo format""" +import re +import sys + +import qapi + +COMMAND_FMT = """ +@deftypefn {type} {{{ret}}} {name} @ +{{{args}}} + +{body} + +@end deftypefn + +""".format + +ENUM_FMT = """ +@deftp Enum {name} + +{body} + +@end deftp + +""".format + +STRUCT_FMT = """ +@deftp {{{type}}} {name} @ +{{{attrs}}} + +{body} + +@end deftp + +""".format + +EXAMPLE_FMT = """@example +{code} +@end example +""".format + + +def subst_strong(doc): + """Replaces *foo* by @strong{foo}""" + return re.sub(r'\*([^_\n]+)\*', r'@emph{\1}', doc) + + +def subst_emph(doc): + """Replaces _foo_ by @emph{foo}""" + return re.sub(r'\s_([^_\n]+)_\s', r' @emph{\1} ', doc) + + +def subst_vars(doc): + """Replaces @var by @code{var}""" + return re.sub(r'@([\w-]+)', r'@code{\1}', doc) + + +def subst_braces(doc): + """Replaces {} with @{ @}""" + return doc.replace("{", "@{").replace("}", "@}") + + +def texi_example(doc): + """Format @example""" + doc = subst_braces(doc).strip('\n') + return EXAMPLE_FMT(code=doc) + + +def texi_comment(doc): + """ + Format a comment + + Lines starting with: + - |: generates an @example + - =: generates @section + - ==: generates @subsection + - 1. or 1): generates an @enumerate @item + - o/*/-: generates an @itemize list + """ + lines = [] + doc = subst_braces(doc) + doc = subst_vars(doc) + doc = subst_emph(doc) + doc = subst_strong(doc) + inlist = "" + lastempty = False + for line in doc.split('\n'): + empty = line == "" + + if line.startswith("| "): + line = EXAMPLE_FMT(code=line[2:]) + elif line.startswith("= "): + line = "@section " + line[2:] + elif line.startswith("== "): + line = "@subsection " + line[3:] + elif re.match("^([0-9]*[.)]) ", line): + if not inlist: + lines.append("@enumerate") + inlist = "enumerate" + line = line[line.find(" ")+1:] + lines.append("@item") + elif re.match("^[o*-] ", line): + if not inlist: + lines.append("@itemize %s" % {'o': "@bullet", + '*': "@minus", + '-': ""}[line[0]]) + inlist = "itemize" + lines.append("@item") + line = line[2:] + elif lastempty and inlist: + lines.append("@end %s\n" % inlist) + inlist = "" + + lastempty = empty + lines.append(line) + + if inlist: + lines.append("@end %s\n" % inlist) + return "\n".join(lines) + + +def texi_args(expr, key="data"): + """ + Format the functions/structure/events.. arguments/members + """ + if key not in expr: + return "" + + args = expr[key] + arg_list = [] + if isinstance(args, str): + arg_list.append(args) + else: + for name, typ in args.iteritems(): + # optional arg + if name.startswith("*"): + name = name[1:]Quoted 8 lines
scripts/qapi2texi.py line 145
Quoted 4 lines
scripts/qapi2texi.py new file +4
-0+ arg_list.append("['%s': @var{%s}]" % (name, typ)) + # regular arg + else: + arg_list.append("'%s': @var{%s}" % (name, typ))Inappropriate use of @var. @var is for metasyntactic variables, i.e. something that stands for another piece of text. typ isn't, it's the name of a specific QAPI type. I think you should use @code.
yes
Quoted 8 lines
Quoted 4 lines
This is the reason why the type names in qemu-qmp-ref.txt are often mangled, e.g.
-- Struct: VersionInfo { 'qemu': VERSIONTRIPLE, 'package': STR }
Right, we have format issue here. If we change it for @code, we get additional quotes in the text format. The simpler is to use no format or @t{}
Pick something you like.
Quoted 119 lines
Quoted 53 lines
Quoted 53 lines
scripts/qapi2texi.py new file +53
-0+ + return ", ".join(arg_list) + + +def texi_body(doc): + """ + Format the body of a symbol documentation: + - a table of arguments + - followed by "Returns/Notes/Since/Example" sections + """ + def _section_order(section): + return {"Returns": 0, + "Note": 1, + "Notes": 1, + "Since": 2, + "Example": 3, + "Examples": 3}[section] + + body = "@table @asis\n" + for arg, section in doc.args.iteritems(): + desc = str(section) + opt = '' + if desc.startswith("#optional"): + desc = desc[10:] + opt = ' *' + elif desc.endswith("#optional"): + desc = desc[:-10] + opt = ' *' + body += "@item @code{'%s'}%s\n%s\n" % (arg, opt, texi_comment(desc)) + body += "@end table\n" + body += texi_comment(str(doc.body)) + + meta = sorted(doc.meta, key=lambda i: _section_order(i.name)) + for section in meta: + name, doc = (section.name, str(section)) + func = texi_comment + if name.startswith("Example"): + func = texi_example + + body += "\n@quotation %s\n%s\n@end quotation" % \ + (name, func(doc)) + return body + + +def texi_alternate(expr, doc): + """ + Format an alternate to texi + """ + args = texi_args(expr) + body = texi_body(doc) + return STRUCT_FMT(type="Alternate", + name=doc.symbol, + attrs="[ " + args + " ]",Quoted 8 lines
scripts/qapi2texi.py line 204
Quoted 6 lines
scripts/qapi2texi.py new file +6
-0+ body=body) + + +def texi_union(expr, doc): + """ + Format an union to texiI think it's "a union".
ok
Quoted 10 lines
scripts/qapi2texi.py line 212
Quoted 8 lines
scripts/qapi2texi.py new file +8
-0+ """ + attrs = "@{ " + texi_args(expr, "base") + " @}" + discriminator = expr.get("discriminator") + if not discriminator: + union = "Flat Union" + discriminator = "type" + else: + union = "Union"Condition is backwards.
fixed
Quoted 27 lines
scripts/qapi2texi.py line 220
Quoted 8 lines
scripts/qapi2texi.py new file +8
-0+ attrs += " + '%s' = [ " % discriminator + attrs += texi_args(expr, "data") + " ]" + body = texi_body(doc) + + return STRUCT_FMT(type=union, + name=doc.symbol, + attrs=attrs, + body=body)You're inventing syntax here. Example output:
-- Union: QCryptoBlockOpenOptions { QCryptoBlockOptionsBase } +
'format' = [ 'qcow': QCRYPTOBLOCKOPTIONSQCOW, 'luks':
QCRYPTOBLOCKOPTIONSLUKS ]The options that are available for all encryption formats when opening an existing volume
Since: 2.6-- Flat Union: ImageInfoSpecific { } + 'type' = [ 'qcow2':
IMAGEINFOSPECIFICQCOW2, 'vmdk': IMAGEINFOSPECIFICVMDK, 'luks':
QCRYPTOBLOCKINFOLUKS ]A discriminated record of image format specific information structures.
Since: 1.7Quoted 8 lines
Note that QCryptoBlockOpenOptions is actually a flat union, and ImageInfoSpecific a simple union. As I said, the condition is backwards.
The meaning of the attrs part is unobvious. Familiarity with schema syntax doesn't really help.
Could we simply use schema syntax here?
Union: QCryptoBlockOpenOptions {
'base': QCryptoBlockOptionsBase, 'discriminator': 'format',
'data': { 'qcow': QCryptoBlockOptionsQCow, 'luks':
QCryptoBlockCreateOptionsLUKS }
Quoted 4 lines
}
Doesn't look obvious either and pollute the documentation with schema-specific parameters.
The schema syntax for flat unions is pretty horrid :) I hope to improve it, but there's more urgent fish to fry.
Quoted 4 lines
Quoted 1 line
If not: whatever format you use, you first need to explain it.
I am not sure my solution is the best and will remain, but ok let's try to document it for now.
Before you pour time into documenting what you have, we should probably discuss what we need.
Quoted 66 lines
Quoted 66 lines
Quoted 18 lines
scripts/qapi2texi.py new file +18
-0+ + +def texi_enum(expr, doc): + """ + Format an enum to texi + """ + for i in expr['data']: + if i not in doc.args: + doc.args[i] = '' + body = texi_body(doc) + return ENUM_FMT(name=doc.symbol, + body=body) + + +def texi_struct(expr, doc): + """ + Format a struct to texi + """scripts/qapi2texi.py line 248
Quoted 10 lines
scripts/qapi2texi.py new file +10
-0+ args = texi_args(expr) + body = texi_body(doc) + attrs = "@{ " + args + " @}" + base = expr.get("base") + if base: + attrs += " + %s" % base + return STRUCT_FMT(type="Struct", + name=doc.symbol, + attrs=attrs, + body=body)More syntax invention. Example output:
-- Struct: BlockdevOptionsReplication { 'mode': REPLICATIONMODE,
['top-id': STR] } + BlockdevOptionsGenericFormat''mode''
the replication mode
''top-id'' *
In secondary mode, node name or device ID of the root node who owns the replication node chain. Must not be given in primary mode.
Driver specific block device options for replication
Since: 2.8Meaning of the attrs part is perhaps more guessable here, but it's still guesswork.
The meaning of * after ''top-id'' is also unobvious.
Note the redundancy between the attrs part and the body: both state member names and optionalness. The body doesn't state member types and base type. If we fixed that, we could drop the attrs part and save us the trouble of defining and explaining a syntax for it.
Let me take a step back. This document is about the QMP wire format. There are no such things as simple and flat unions on the wire, only JSON objects. QMP introspection duly describes a type's JSON objects, not how it's defined in QAPI. I think QMP documentation should ideally do the same.
QMP introspection uses a common structure for struct, simple and flat
union: common members, variants, and if variants, then the common member that serves as tag. See introspect.json for details.Base types are flattened away. Appropriate for introspection, but documentation shouldn't do that.
Quoted 6 lines
Quoted 2 lines
I wrote "ideally" because it's probably too big a step. I'm willing to settle for something less than ideal.
I don't have clear idea what to do here, so if we can leave that for later, that would be nice for me (I am already spending more time than I imagined I would on doc stuff)
Me too, if that's any consolation...
Perhaps I can find a bit of time to think so I can propose what we could do.
Quoted 146 lines
Quoted 40 lines
Quoted 40 lines
scripts/qapi2texi.py new file +40
-0+ + +def texi_command(expr, doc): + """ + Format a command to texi + """ + args = texi_args(expr) + ret = expr["returns"] if "returns" in expr else "" + body = texi_body(doc) + return COMMAND_FMT(type="Command", + name=doc.symbol, + ret=ret, + args="(" + args + ")", + body=body) + + +def texi_event(expr, doc): + """ + Format an event to texi + """ + args = texi_args(expr) + body = texi_body(doc) + return COMMAND_FMT(type="Event", + name=doc.symbol, + ret="", + args="(" + args + ")", + body=body) + + +def texi_expr(expr, doc): + """ + Format an expr to texi + """ + (kind, _) = expr.items()[0] + + fmt = {"command": texi_command, + "struct": texi_struct, + "enum": texi_enum, + "union": texi_union, + "alternate": texi_alternate,Quoted 8 lines
scripts/qapi2texi.py line 293
Quoted 5 lines
scripts/qapi2texi.py new file +5
-0+ "event": texi_event} + try: + fmt = fmt[kind] + except KeyError: + raise ValueError("Unknown expression kind '%s'" % kind)The try / except converts one kind of error into another. What does that buy us? As far as I can tell, this shouldn't ever happen.
dropped
Quoted 95 lines
Quoted 75 lines
scripts/qapi2texi.py new file +38
-0+ + return fmt(expr, doc) + + +def texi(docs): + """ + Convert QAPI schema expressions to texi documentation + """ + res = [] + for doc in docs: + expr = doc.expr + if not expr: + res.append(texi_body(doc)) + continue + try: + doc = texi_expr(expr, doc) + res.append(doc) + except: + print >>sys.stderr, "error at @%s" % doc.info + raise + + return '\n'.join(res) + + +def main(argv): + """ + Takes schema argument, prints result to stdout + """ + if len(argv) != 2: + print >>sys.stderr, "%s: need exactly 1 argument: SCHEMA" % argv[0] + sys.exit(1) + + schema = qapi.QAPISchema(argv[1], strict_doc=True) + print texi(schema.docs) + + +if __name__ == "__main__": + main(sys.argv)docs/qapi-code-gen.txt +12
-10@@ -45,16 +45,13 @@ QAPI parser does not). At present, there is no place where a QAPI schema requires the use of JSON numbers or null. Comments are allowed; anything between an unquoted # and the following -newline is ignored. Although there is not yet a documentation -generator, a form of stylized comments has developed for consistently -documenting details about an expression and when it was added to the -schema. The documentation is delimited between two lines of ##, then -the first line names the expression, an optional overview is provided, -then individual documentation about each member of 'data' is provided, -and finally, a 'Since: x.y.z' tag lists the release that introduced -the expression. Optional members are tagged with the phrase -'#optional', often with their default value; and extensions added -after the expression was first released are also given a '(since +newline is ignored. The documentation is delimited between two lines +of ##, then the first line names the expression, an optional overview +is provided, then individual documentation about each member of 'data' +is provided, and finally, a 'Since: x.y.z' tag lists the release that +introduced the expression. Optional members are tagged with the +phrase '#optional', often with their default value; and extensions +added after the expression was first released are also given a '(since x.y.z)' comment. For example: ##@@ -73,12 +70,49 @@ x.y.z)' comment. For example: # (Since 2.0) # # Since: 0.14.0 + # + # Notes: You can also make a list: + # - with items + # - like this + #docs/qapi-code-gen.txt x.y.z)' comment. For example: · line 87
Quoted 10 lines
docs/qapi-code-gen.txt +5
-0+ # Example: + # + # -> { "execute": ... } + # <- { "return": ... } + # ## { 'struct': 'BlockStats', 'data': {'*device': 'str', 'stats': 'BlockDeviceStats', '*parent': 'BlockStats', '*backing': 'BlockStats'} }This example gives an idea of how to document struct types. But the reader is left guessing how to document other kinds of definitions. In particular, there's no mention of "Returns", "Note" and "Examples" sections anywhere in this file. As is, this could do for a tutorial, but this file is a *reference*, not a tutorial.
For a reference, we need to be more thorough. A doc comments section on its own seems advisable.
Quoted 7 lines
Quoted 4 lines
I guess doc comment examples are best added to the schema code examples in sections === Struct types ===, ..., === Events ===.
Careful review for completeness is advised.
So far we did quite fine with the generic example. I am not convinced we need to have doc comments for all kinds of types, it looks redundant to me.
Well, so far we didn't require people to write well-formed doc comments.
Without such comments in qapi-code-gen.txt's examples, they become incomplete. Pity, because I like to feed them to the QAPI generators; extracted like this:
$ sed '1,/\$ cat example-schema.json/d;/^[^ ]/,$d;s/^ //' ../docs/qapi-code-gen.txt >example-schema.json
Quoted 37 lines
Quoted 21 lines
Quoted 21 lines
docs/qapi-code-gen.txt +21
-0+It's also possible to create documentation sections, such as: + + ## + # = Section + # == Subsection + # + # Some text foo with *strong* and _emphasis_ + # 1. with a list + # 2. like that + # + # And some code: + # | $ echo foo + # | -> do this + # | <- get that + # + ## + +Text *foo* and _foo_ are for "strong" and "emphasis" styles (they do +not work over multiple lines). @foo is used to reference a symbol. + +Lines starting with the following characters and a space:Quoted 8 lines
docs/qapi-code-gen.txt x.y.z)' comment. For example: · line 115
Quoted 6 lines
docs/qapi-code-gen.txt +6
-0+- | are examples +- = are top section +- == are subsection +- X. or X) are enumerations (X is any number) +- o/*/- are itemized list +Is this doc markup documentation complete?
I think so
Quoted 2 lines
Is it related to any existing text markup language? Hmm, the commit message calls it "Markdown-like". Should we mention that here?
I'll use "annotations" instead in the doc
Quoted 8 lines
Quoted 3 lines
Is all markup valid in all contexts? For instance, is = Section valid in symbol blocks? What does | (or any markup for that matter) do within an Example section?
Example is verbatim
I improved a bit the doc based on your feedback. I'd suggest we iterate with additional patches later, I could use help.
Let's mark places that need improvement with FIXME or TODO comments, noted in commit messages.
Quoted 43 lines
Quoted 33 lines
Quoted 23 lines
docs/qapi-code-gen.txt +0
-0The schema sets up a series of types, as well as commands and events that will use those types. Forward references are allowed: the parser scans in two passes, where the first pass learns all type names, andtests/qapi-schema/doc-bad-args.err new file +1
-0@@ -0,0 +1 @@ +tests/qapi-schema/doc-bad-args.json:1: Members documentation is not a subset of API ['a', 'b'] > ['a']tests/qapi-schema/doc-bad-args.exit new file +1
-0@@ -0,0 +1 @@ +1tests/qapi-schema/doc-bad-args.json new file +0
-0tests/qapi-schema/doc-bad-args.json line 6
Quoted 6 lines
tests/qapi-schema/doc-bad-args.json new file +6
-0@@ -0,0 +1,6 @@ +## +# @foo: +# @a: a +# @b: b +## +{ 'command': 'foo', 'data': {'a': 'int'} }The existing tests/qapi-schema/*.json explain what is being tested in a comment. Perhaps like this:
Quoted 7 lines
# Arguments listed in the doc comment must exist in the actual schema ## # @foo: ...Likewise for other tests.
ok
[...]
Quoted 3 lines
Re: [Qemu-devel] [PATCH v5 13/17] qapi: add qapi2texi script
Hi
Quoted 5 lines · Markus Armbruster
I had to resort to diff to find your replies, and massage the text manually to produce a readable reply myself. Please quote the usual way.
I'd have to switch to something else than gmail (which bothers me for various reasons, let's not discuss the merits of various mail clients please ;) In general, I don't have problems, but this mail is rather big, sorry for the inconvenience..
Quoted 431 lines
Quoted 85 lines · Markus Armbruster
Quoted 39 lines
Quoted 25 lines · Marc-André Lureau
As the name suggests, the qapi2texi script converts JSON QAPI description into a texi file suitable for different target formats (info/man/txt/pdf/html...).
It parses the following kind of blocks:
Free-form:
##
# = Section
# == Subsection
#
# Some text foo with *emphasis*
# 1. with a list
# 2. like that
#
# And some code:# | $ echo foo # | -> do this # | <- get that#
##Symbol:
Quoted 8 lines
##
# @symbol:
#
# Symbol body ditto ergo sum. Foo bar# baz ding. # # @arg: foo # @arg: #optional fooLet's not use @arg twice.
Quoted 8 lines
Terminology: I prefer to use "parameter" for formal parameters, and "argument" for actual arguments. This matches how The Python Language Reference uses the terms.
What about
# @param1: the frob to frobnicate
# @param2: #optional how hard to frobnicateok
Quoted 4 lines
Quoted 3 lines
#
# Returns: returns bla bla
# Or bla blahQuoted 8 lines
Repeating "returns" is awkward, and we don't do that in our schemas.
We need a period before "Or", or spell it "or".
What about
# Returns: the frobnicated frob.
# If frob isn't frobnicatable, GenericError.ok
Quoted 20 lines
Quoted 19 lines
#
# Since: version
# Notes: notes, comments can have
# - itemized list
# - like this
#
# Example:
#
# -> { "execute": "quit" }
# <- { "return": {} }
#
##That's roughly following the following EBNF grammar:
api_comment= "##\n" comment "##\n"
comment =freeform_comment|symbol_commentfreeform_comment= { "# " text "\n" | "#\n" }symbol_comment= "# @" name ":\n" { member | meta |freeform_comment}Quoted 10 lines
Quoted 6 lines
Rejects non-empty comments where "#" is not followed by space. Such usage is accepted outside doc comments. Hmm.
Quoted 1 line
member = "# @" name ':' [ text ]
freeform_commentAre you missing a "\n" before
freeform_comment?yes
Quoted 1 line
Quoted 1 line
meta = "# " ( "Returns:", "Since:", "Note:", "Notes:", "Example:",
"Examples:" ) [ text ]
freeform_commentQuoted 13 lines
Quoted 2 lines
Likewise.
ok
Quoted 8 lines
Quoted 1 line
text = free-text markdown-like, "#optional" for members
The grammar is ambiguous: a line "# @foo:\n" can be parsed both as
freeform_commentand assymbol_comment. Since your intent is obvious enough, it can still serve as documentation. It's not a suitable foundation for parsing, though. Okay for a commit message.Quoted 1 line
Thanks to the following json expressions, the documentation is
enhanced
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
with extra information about the type of arguments and return value expected.
I guess you want to say that we enrich the documentation we extract
from
Quoted 11 lines
Quoted 1 line
comments with information from the actual schema. Correct?
yes
Quoted 7 lines
Missing: a brief discussion of deficiencies. These include:
* The generated QMP documentation includes internal types
We use qapi-schema.json both for defining the external QMP interface and for defining internal types.
qmp-introspect.pycarefully separates the two, to not expose internal types.qapi2texi.pyhappily
Quoted 58 lines
Quoted 58 lines
exposes everything.
Currently, about a fifth of the types in the generated docs are internal:
AcpiTableOptions
BiosAtaTranslation
BlockDeviceMapEntry
COLOMessage
COLOMode
DummyForceArrays
FailoverStatus
FloppyDriveType
ImageCheck
LostTickPolicy
MapEntry
MigrationParameter
NetClientDriver
NetFilterDirection
NetLegacy
NetLegacyNicOptions
NetLegacyOptions
NetLegacyOptionsKind
Netdev
NetdevBridgeOptions
NetdevDumpOptions
NetdevHubPortOptions
NetdevL2TPv3Options
NetdevNetmapOptions
NetdevNoneOptions
NetdevSocketOptions
NetdevTapOptions
NetdevUserOptions
NetdevVdeOptions
NetdevVhostUserOptions
NumaNodeOptions
NumaOptions
NumaOptionsKind
OnOffAuto
OnOffSplit
PreallocMode
QCryptoBlockCreateOptions
QCryptoBlockCreateOptionsLUKS
QCryptoBlockFormat
QCryptoBlockInfo
QCryptoBlockInfoBase
QCryptoBlockInfoQCow
QCryptoBlockOpenOptions
QCryptoBlockOptionsBase
QCryptoBlockOptionsLUKS
QCryptoBlockOptionsQCow
QCryptoSecretFormat
QCryptoTLSCredsEndpoint
QapiErrorClass
ReplayMode
X86CPUFeatureWordInfo
X86CPURegister32Quoted 3 lines
Quoted 3 lines
Generating documentation for internal types might be useful, but letting them pollute QMP interface documentation isn't. Needs fixing before we release. Until then, needs a FIXME comment in
qapi2texi.py.Quoted 5 lines
Quoted 5 lines
* Union support is lacking
The doc string language is adequate for documenting commands, events, and non-union types. It doesn't really handle union variants.
Hardly
Quoted 47 lines
Quoted 8 lines
surprising, as you fitted the language do existing practice, and existing (mal-)practice is neglecting to document union variant members.
* Documentation is lacking
See review of qapi-code-gen.txt below.
Quoted 8 lines
* Doc comment error message positions are imprecise
They always point to the beginning of the comment.
* Probably more
We should update this with noteworthy findings during review. I tried, but I suspect I missed some.
ok
Quoted 28 lines
Quoted 1 line
Signed-off-by Marc-André Lureau <[email protected]>[Lengthy diffstat snipped...]
Quoted 26 lines
tests/Makefile.include +15
-0@@ -350,6 +350,21 @@ qapi-schema += base-cycle-direct.json qapi-schema += base-cycle-indirect.json qapi-schema += command-int.json qapi-schema += comments.json +qapi-schema += doc-bad-args.json +qapi-schema += doc-bad-symbol.json +qapi-schema += doc-duplicated-arg.json +qapi-schema += doc-duplicated-return.json +qapi-schema += doc-duplicated-since.json +qapi-schema += doc-empty-arg.json +qapi-schema += doc-empty-section.json +qapi-schema += doc-empty-symbol.json +qapi-schema += doc-invalid-end.json +qapi-schema += doc-invalid-end2.json +qapi-schema += doc-invalid-return.json +qapi-schema += doc-invalid-section.json +qapi-schema += doc-invalid-start.json +qapi-schema += doc-missing-expr.json +qapi-schema += doc-missing-space.json qapi-schema += double-data.json qapi-schema += double-type.jsonQuoted 8 lines
Quoted 8 lines
tests/Makefile.include qapi-schema += union-optional-branch.json · line 463
Quoted 8 lines
tests/Makefile.include +2
-0qapi-schema += duplicate-key.json@@ -443,6 +458,8 @@ qapi-schema += union-optional-branch.json qapi-schema += union-unknown.json qapi-schema += unknown-escape.json qapi-schema += unknown-expr-key.json + + check-qapi-schema-y := $(addprefix tests/qapi-schema/,$(qapi-schema))
Quoted 2 lines
Quoted 2 lines
tests/Makefile.include qapi-schema += union-optional-branch.json · line 464
Quoted 2 lines
tests/Makefile.include +0
-0GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h\
Quoted 6 lines
Quoted 6 lines
scripts/qapi.py class QAPILineError(Exception): · line 122
Quoted 6 lines
scripts/qapi.py +0
-0@@ -122,6 +122,109 @@ class QAPILineError(Exception): "%s:%d: %s" % (self.info['file'], self.info['line'],self.msg)
Quoted 44 lines
Quoted 7 lines
scripts/qapi.py class QAPILineError(Exception): · line 127
Quoted 5 lines
scripts/qapi.py +3
-0+class QAPIDoc(object): + class Section(object): + def __init__(self, name=""):name=None feels more natural than "" for an absent optional name.
ok
Quoted 5 lines
scripts/qapi.py class QAPILineError(Exception): · line 130
Quoted 3 lines
scripts/qapi.py +3
-0+ # optional section name (argument/member or section name) + self.name = name + # the list of strings for this sectionWould "list of lines" be more accurate, or less?
more accurate, ok
Quoted 8 lines
Quoted 8 lines
scripts/qapi.py +8
-0+ self.content = [] + + def append(self, line): + self.content.append(line) + + def __repr__(self): + return "\n".join(self.content).strip() +Quoted 8 lines
scripts/qapi.py class QAPILineError(Exception): · line 140
Quoted 2 lines
scripts/qapi.py +2
-0+ class ArgSection(Section): + passBegs the question what makes ArgSection differ from Section. I think it's the semantics of self.name: an ArgSection's name is the parameter name, a non-ArgSection can either be a "meta" section (name is one of "Returns"", "Since", "Note", "Notes", "Example", "Examples") or an anonymous section (name is "").
yes, and the section type is checked in
_append_freeform()Quoted 7 lines
Quoted 6 lines
scripts/qapi.py +6
-0+ + def __init__(self, parser): + self.parser = parser + self.symbol = None + self.body = QAPIDoc.Section() + # a dict {'arg': ArgSection, ...}Quoted 14 lines
Quoted 3 lines
Works. Alternatevely:
# dict mapping parameter name to ArgSectionok
Quoted 8 lines
scripts/qapi.py class QAPILineError(Exception): · line 152
Quoted 6 lines
scripts/qapi.py +6
-0+ self.args = OrderedDict() + # a list of Section + self.meta = [] + # the current section + self.section = self.body + # associated expression and info (set by expression parser)"will be set by expression parser", or "to be set by expression
parser"?
Quoted 26 lines
ok
Quoted 8 lines
scripts/qapi.py class QAPILineError(Exception): · line 154
Quoted 2 lines
scripts/qapi.py +2
-0+ self.expr = None + self.info = NoneClearer now. The one remark I still have is on the use of "meta" isn't obvious here. I think a comment further up explaining the different kinds of sections would help.
To be honest, I don't get what's "meta" about the "meta" sections :)
Let's drop that distinction, it isn't necessary anymore
Quoted 12 lines
scripts/qapi.py class QAPILineError(Exception): · line 157
Quoted 3 lines
scripts/qapi.py +3
-0+ + def has_meta(self, name): + """Returns True if the doc has a meta section 'name'"""PEP257[1] demands imperative mood, and punctuation:
"""Return True if the doc has a meta section 'name'."""
Unfortunately, there seems to be no established convention for marking parameter names. You put this one in single quotes, which works here, but could be confusing in other cases. I'd sidestep it:
Quoted 15 lines
Quoted 5 lines
"""Return True if we have a meta section with this name."""
or
"""Does a meta section with this name exist?"""
ok
Quoted 7 lines
Quoted 7 lines
scripts/qapi.py +7
-0+ for i in self.meta: + if i.name == name: + return True + return False + + def append(self, line): + """Adds a # comment line, to be parsed and added to currentsection"""
Quoted 4 lines
Quoted 4 lines
Imperative mood:
"""Add a comment line, to be parsed and added to the current
section."""
Quoted 23 lines
Quoted 23 lines
However, we're not always adding to the current section, we can also start a new one. The following avoids suggesting anything about the current section:
"""Parse a comment line and add it to the documentation."""
When the function name is a verb, and its doc string starts with a different verb, the name might be suboptimal. Use your judgement.
If this one-liner is too terse, we can try a multi-line doc string:
"""Parse a comment line and add it to the documentation.
TODO should we tell more about how we parse?
Args:
line: the comment starting with '#', with the newline stripped.Raises:
QAPISchemaError: TODO explain error conditions
"""Quoted 16 lines
Quoted 6 lines
Format stolen from the Google Python Style Guide[2], because PEP257 is of not much help there.
Once you start with such elaborate doc strings, pressure will likely mount to do the same elsewhere. Could be a distraction right now. Use your judgement.
ok, thanks
Quoted 7 lines
Quoted 7 lines
scripts/qapi.py +7
-0+ line = line[1:] + if not line: + self._append_freeform(line) + return + + if line[0] != ' ': + raise QAPISchemaError(self.parser, "missing space after#")
Quoted 15 lines
Quoted 15 lines
scripts/qapi.py class QAPILineError(Exception): · line 170
Quoted 1 line
scripts/qapi.py +1
-0+ line = line[1:]QAPISchemaError takes the error position from its QAPISchemaParser argument. In other words, the error position depends on the state of the parser when it calls this function. Turns out the position is the beginning of the comment. Servicable here. Action at a distance, though.
Less strict:
# strip leading # and space line = line[1:] if line[0] == ' ': line = line[1:]Quoted 4 lines
Quoted 1 line
Also avoids special-casing empty comments.
That would raise "IndexError: string index out of range" on empty comment lines ("#")
Fixable:
ifline.startswith(' '):
Quoted 9 lines
Quoted 1 line
Also I'd like to keep the error in case a space is missing (it caught
some
Quoted 1 line
already).
On the one hand, I share your distaste for lack of space between # and comment text. On the other hand, I dislike enforcing spacing
inconsistently: enforce in doc comments, but not in other comments.
It's only enforced for doc comments, which I think is fair.
Quoted 45 lines
Quoted 7 lines
Quoted 5 lines
Perhaps we should treat all leading whitespace the same (I'm not sure):
# strip leading # and whitespace line = line[1:] line = line.lstrip()That would break indentation in Example sections
True; scratch the idea.
Quoted 11 lines
Quoted 11 lines
scripts/qapi.py class QAPILineError(Exception): · line 180
Quoted 8 lines
scripts/qapi.py +8
-0+ + if self.symbol: + self._append_symbol_line(line) + elif (not self.body.content and + line.startswith("@") and line.endswith(":")): + self.symbol = line[1:-1] + if not self.symbol: + raise QAPISchemaError(self.parser, "Invalid symbol")Doesn't recognize the symbol when there's anything other than a single space between # and @. Pathological case: '#\t@foo:' starting in
column
Quoted 5 lines
Quoted 3 lines
6 looks exactly like '# @foo:', but doesn't work. Fortunately, your code rejects the tab there. Assigning meaning to (leading) whitespace may make sense, but it must be documented clearly.
I think it's simpler to only accept a simple space (# + space + @ +
symbol
Quoted 1 line
+ :), it will also lead to more uniform doc.
Simpler is always an argument worth considering, but simpler isn't always better. Experience with other languages has taught me to be carefule when making the kind or amount of whitespace significant.
Kind of whitespace is not a usability issue with your proposal, because your patch rejects anything but space.
Amount of whitespace is, because getting it wrong turns a symbol comment block into a free-form comment block, or a parameter section into free-form lines belonging to whatever section precedes it.
As long as we reject definitions without a symbol comment, errors of the former kind will still be caught, although the error message could be confusing.
Quoted 8 lines
As is, we don't reject definitions whose symbol comment fails to document all parameters. Errors of the latter kind will therefore go undetected. Trap for the unwary. See also "@param2 is True" below.
If we can't find a solution without such usability issues now, then I'm willing to settle for documentation warning unwary users, or even for a FIXME comment.
ok
Quoted 432 lines
Quoted 12 lines
Quoted 11 lines
Doesn't recognize the symbol when there's crap after ":". Confusing when it's invisible crap, i.e. trailing whitespace. In general, it's best to parse left to right, like this:
elif not self.body.content and
line.startswith('@'):
match =valid_name.match(line[1:]);
if not match:
raiseQAPISchemaError(self.parser, 'Invalid name')
ifline.startswith(':', match.end(0)):
raiseQAPISchemaError(self.parser, 'Expected ":")Quoted 3 lines
Easier is simply to check :
if notline.endswith(":"):
raise QAPIParseError(self.parser, "Line should end with:")
Quoted 2 lines
test added
There's a reason we have a mountain of theory on parsing, built in decades of practice. What starts "easier" than that generally ends up rewritten from scratch. Anyway, let's continue.
Quoted 2 lines
Quoted 2 lines
Here, the error position is clearly suboptimal: it's the beginning of the comment instead of where the actual error is, namely the beginning
/
Quoted 9 lines
Quoted 7 lines
the end of the name. More of the same below. The root cause is stacking parsers. I'm not asking you to do anything about it at this time.
Note my use of "name" rather than "symbol" in the error message. qapi-code-gen.txt talks about names, not symbols. Consistent use of terminology matters.
Agree, isn't "symbol" more appropriate for documentation though?
Possibly. But if it's an improvement for generated documentation, it surely is an improvement for hand-written documentation such as qapi-code-gen.txt and the comments in qapi*.py, too. And the Python identifiers. I have to admit that cools my enthusiasm for making the improvement right now :)
Quoted 12 lines
Quoted 12 lines
scripts/qapi.py class QAPILineError(Exception): · line 189
Quoted 9 lines
scripts/qapi.py +9
-0+ else: + self._append_freeform(line) + + def _append_symbol_line(self, line): + name = line.split(' ', 1)[0] + + if name.startswith("@") and name.endswith(":"): + line = line[len(name)+1:] + self._start_args_section(name[1:-1])Similar issue. Left to right:
Quoted 4 lines
Quoted 4 lines
if
re.match(r'\s*@', line):
match =valid_name.match(line[1:]); if not match:
raise QAPISchemaError(self.parser, 'Invalidparameter name')
Quoted 9 lines
Quoted 7 lines
line = line[match.end(0):] if line.startswith(':'): raise QAPISchemaError(self.parser, 'Expected ":") line = line[1:] self._start_args_section(match.group(0))Even better would be factoring out the common code to parse '@foo:'.
It's a valid case to have a section freeform comment starting with @foo,
ex:
Quoted 3 lines
@param: do this and than if
@param2 is TrueGood point, but it's a language issue, not a parsing issue.
The language issue is that we need to recognize a line "# @param: ..." as the start of a parameter section, while still permitting free-form lines like "# @param2 is True".
This is a pretty convincing argument for requiring the ':'. It can also be used as an argument for requiring exactly one space between # and @.
How the language is parsed is completely orthogonal.
Quoted 1 line
I don't think it's worth to factor out the code to parse @foo vs @foo:,
yet
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
scripts/qapi.py +6
-0+ elif name in ("Returns:", "Since:", + # those are often singular or plural + "Note:", "Notes:", + "Example:", "Examples:"): + line = line[len(name)+1:] + self._start_meta_section(name[:-1])Quoted 7 lines
Quoted 1 line
Since we're re.match()ing already, here's how do to it that way:
I don't follow your suggestion for the reason above,so I still have the first word 'name'
Quoted 2 lines
else
match =
re.match(r'\s*(Returns|Since|Notes?|Examples?):', line)Quoted 7 lines
Quoted 3 lines
if match: line = line[match.end(0):] self._start_meta_section(match.group(1))not really much nicer to me (especially because no match yet), I'll keep the current code for now
Quoted 6 lines
Quoted 6 lines
scripts/qapi.py class QAPILineError(Exception):
Quoted 6 lines
scripts/qapi.py +6
-0+ + self._append_freeform(line) + + def _start_args_section(self, name): + if not name: + raise QAPISchemaError(self.parser, "Invalid argumentname")
Quoted 7 lines
Quoted 2 lines
parameter name
ok
Quoted 2 lines
Quoted 2 lines
scripts/qapi.py +2
-0+ if name in self.args: + raise QAPISchemaError(self.parser, "'%s' arg duplicated"% name)
Quoted 5 lines
Quoted 2 lines
Duplicate parameter name
ok
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
scripts/qapi.py +5
-0+ self.section = QAPIDoc.ArgSection(name) + self.args[name] = self.section + + def _start_meta_section(self, name): + if name in ("Returns", "Since") and self.has_meta(name):Quoted 8 lines
scripts/qapi.py class QAPILineError(Exception):
Quoted 8 lines
scripts/qapi.py +8
-0+ raise QAPISchemaError(self.parser, + "Duplicated '%s' section" % name) + self.section = QAPIDoc.Section(name) + self.meta.append(self.section) + + def _append_freeform(self, line): + in_arg = isinstance(self.section, QAPIDoc.ArgSection) + if in_arg and self.section.content and notself.section.content[-1] \
Quoted 5 lines
Quoted 5 lines
scripts/qapi.py class QAPILineError(Exception): · line 217
Quoted 1 line
scripts/qapi.py +1
-0+ and line and not line[0].isspace():PEP8[3] prefers parenthesises over backslash:
if (
in_argand self.section.content and notself.section.content[-1]
Quoted 13 lines
Quoted 1 line
and line and not line[0].isspace()):
yes, thanks
Quoted 9 lines
scripts/qapi.py class QAPILineError(Exception): · line 222
Quoted 5 lines
scripts/qapi.py +5
-0+ # an empty line followed by a non-indented + # comment ends the argument section + self.section = self.body + self._append_freeform(line) + returnSwitching back to the self.body section like this reorders the documentation text. I still think this is a terrible idea. A dumb script is exceedingly unlikely to improve human-written doc comment
text
Quoted 4 lines
Quoted 4 lines
by reordering. In the rare case it does, the doc comment source should be reordered.
Here's an example where the doc generator happily creates
unintelligible
Quoted 23 lines
Quoted 23 lines
garbage if I format CpuDefinitionInfo's doc comment in a slightly off way:
##
# @CpuDefinitionInfo:
#
# Virtual CPU definition.
#
# @name: the name of the CPU definition
#
# @migration-safe: #optional whether a CPU definition can be safely # used for migration in combination with a QEMU compatibility # machine when migrating between different QMU versions and between # hosts with different sets of (hardware or software)
# capabilities.
#
# If not provided, information is not available and callers should # not assume the CPU definition to be migration-safe. (since 2.8) #
# @static: whether a CPU definition is static and will not change # depending on QEMU version, machine type, machine options and # accelerator options. A static model is always
# migration-safe. (since 2.8)Quoted 8 lines
Quoted 8 lines
#
# @unavailable-features: #optional List of properties that prevent # the CPU model from running in the current host. (since 2.8) #
# @unavailable-features is a list of QOM property names that # represent CPU model attributes that prevent the CPU from running. # If the QOM property is read-only, that means there's no known # way to make the CPU model run in the current host.Implementations
Quoted 7 lines
Quoted 7 lines
# that choose not to provide specific information return the # property name "type". # # If the property is read-write, it means that it MAY be possible # to run the CPU model in the current host if that property is # changed. Management software can use it as hints to suggest or # choose an alternative for the user, or just to generatemeaningful
Quoted 10 lines
Quoted 10 lines
# error messages explaining why the CPU model can't be used. # If @unavailable-features is an empty list, the CPU model is # runnable using the current host and machine-type. # If @unavailable-features is not present, runnability # information for the CPU is not available. # # Since: 1.2.0 ## { 'struct': 'CpuDefinitionInfo', 'data': { 'name': 'str', '*migration-safe': 'bool', 'static':'bool',
Quoted 10 lines
Quoted 10 lines
'*unavailable-features': [ 'str' ] } }To detect the problem, you have to read the generated docs attentively. You know my opinion on our chances for that to happen during development.
My point is not that we should support this doc comment format. My point is that people could conceivably write something like it, and not get caught in patch review.
Quoted 5 lines
Quoted 3 lines
I can see three ways out of this swamp:
1. Let sections continue until another one begins.
but we have interleaved sections, and no explicit "body" section tag,
ex:
Quoted 34 lines
##
# @input-send-event:
#
# Send input event(s) to guest.
#
# @device: #optional display device to send event(s) to.
# @head: #optional head to send event(s) to, in case the
# display device supports multiple scanouts.
# @events: List of InputEvent union.
#
# Returns: Nothing on success.
#
# The @device and @head parameters can be used to send the input event# to specific input devices in case (a) multiple input devices of the # same kind are added to the virtual machine and (b) you have # configured input routing (see docs/multiseat.txt) for those input # ....Quoted 3 lines
2. Make text between sections an error.
3. When a section ends, start a new anonymous section.
It's not clear how to recognize when a section ends and append to comment body.
2. Make text between sections an error.
Sound like the best option to me. I'll fix the doc and add a check & test for this common pattern though:
##
# @TestStruct:
#Quoted 9 lines
# body with @var # # @integer: foo # blah # # bao # # Let's catch this bad comment. ##Go ahead.
Quoted 6 lines
Quoted 6 lines
Can't say offhand which one will work best.
scripts/qapi.py class QAPILineError(Exception): · line 224
Quoted 2 lines
scripts/qapi.py +2
-0+ if in_arg or not self.section.name.startswith("Example"): + line = line.strip()Stripping whitespace is not "Markdown-like", because intendation
carries
Quoted 8 lines
Quoted 8 lines
meaning in Markdown. Example:
* First item in itemized list
* Second item
* Sub-item of second item
* Another sub-item
* Third itemQuoted 5 lines
Quoted 3 lines
Stripping whitespace destroys the list structure. If that's what you want, you get to document where your "Markdown-like" markup is unlike Markdown :)
let's use "comment annotations" instead
Okay.
Quoted 36 lines
Quoted 17 lines
Is there a technical reason for stripping whitespace?
See also discussion of space after # above.
Quoted 13 lines
scripts/qapi.py +4
-0+ self.section.append(line) + + class QAPISchemaParser(object): def __init__(self, fp, previously_included=[], incl_info=None):@@ -137,11 +240,18 @@ class QAPISchemaParser(object): self.line = 1 self.line_pos = 0 self.exprs = [] + self.docs = [] self.accept()Quoted 6 lines
scripts/qapi.py class QAPISchemaParser(object): · line 249
Quoted 4 lines
scripts/qapi.py +1
-0while self.tok is not None: info = {'file': fname, 'line': self.line, 'parent': self.incl_info} + if self.tok == '#' and self.val.startswith('##'):How can self.val *not* start with '##' here?
you are right, unnecessary condition since we break
get_expr()only in this case nowQuoted 6 lines
scripts/qapi.py class QAPISchemaParser(object): · line 251
Quoted 2 lines
scripts/qapi.py +2
-0+ doc = self.get_doc() + doc.info = infoLet's pass info as argument to
get_doc(), so we don't have to dot into doc here.get_doc()can avoid dotting into doc by passing info to the constructor.ok
Quoted 8 lines
Quoted 8 lines
scripts/qapi.py class QAPISchemaParser(object): · line 270
Quoted 8 lines
scripts/qapi.py +3
-0+ self.docs.append(doc) + continue + expr = self.get_expr(False) if isinstance(expr, dict) and "include" in expr: if len(expr) != 1:@@ -160,6 +270,7 @@ class QAPISchemaParser(object): raise QAPILineError(info, "Inclusion loopfor %s"
Quoted 8 lines
Quoted 8 lines
scripts/qapi.py class QAPISchemaParser(object): · line 282
Quoted 8 lines
scripts/qapi.py +1
-0% include) inf = inf['parent'] + # skip multiple include of the same file if incl_abs_fname in previously_included: continue@@ -171,12 +282,38 @@ class QAPISchemaParser(object): exprs_include = QAPISchemaParser(fobj,
previously_included,Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
scripts/qapi.py +5
-0info) self.exprs.extend(exprs_include.exprs) + self.docs.extend(exprs_include.docs) else: expr_elem = {'expr': expr, 'info': info} + if self.docs and not self.docs[-1].expr: + self.docs[-1].expr = expr + expr_elem['doc'] = self.docs[-1] +Quoted 13 lines
Quoted 4 lines
Attaches the expression to the last doc comment that doesn't already have one. A bit sloppy, because there could be non-doc comments in between, or the doc comment could be in another file. It'll do, at least for now.
I extended the condition to check it attaches the doc from the same file
Quoted 6 lines
Quoted 6 lines
scripts/qapi.py +3
-1self.exprs.append(expr_elem) - def accept(self): + def get_doc(self): + if self.val != '##': + raise QAPISchemaError(self, "Junk after '##' at start of"
Quoted 9 lines
Quoted 9 lines
scripts/qapi.py class QAPISchemaParser(object):
Quoted 9 lines
scripts/qapi.py +9
-0+ "documentation comment") + + doc = QAPIDoc(self) + self.accept(False) + while self.tok == '#': + if self.val.startswith('##'): + # End of doc comment + if self.val != '##': + raise QAPISchemaError(self, "Junk after '##' atend of "
Quoted 8 lines
Quoted 8 lines
scripts/qapi.py class QAPISchemaParser(object):
Quoted 8 lines
scripts/qapi.py +8
-0+ "documentation comment") + self.accept() + return doc + else: + doc.append(self.val) + self.accept(False) + + raise QAPISchemaError(self, "Documentation comment must endwith '##'")
Quoted 29 lines
Quoted 2 lines
Let's put this after accept, next to the other
get_FOO().ok
Quoted 24 lines
Quoted 9 lines
scripts/qapi.py +2
-0+ + def accept(self, skip_comment=True): while True: self.tok = self.src[self.cursor] self.pos = self.cursor@@ -184,7 +321,13 @@ class QAPISchemaParser(object): self.val = None if self.tok == '#':scripts/qapi.py class QAPISchemaParser(object): · line 333
Quoted 10 lines
scripts/qapi.py +6
-0+ if self.src[self.cursor] == '#': + # Start of doc comment + skip_comment = False self.cursor = self.src.find('\n', self.cursor) + if not skip_comment: + self.val = self.src[self.pos:self.cursor] + return elif self.tok in "{}:,[]": return elif self.tok == "'":Copied from review of v3, so I don't forget:
Comment tokens are thrown away as before, except when the parser asks for them by passing skip_comment=False, or when the comment token
starts
Quoted 10 lines
Quoted 6 lines
Quoted 4 lines
with ##. The parser asks while parsing a doc comment, in
get_doc().This is a backchannel from the parser to the lexer. I'd rather avoid such lexer hacks, but I guess we can address that on top.
I don't have a good solution to that
I have an idea which may or may not work. I can explore it on top.
thanks
Quoted 41 lines
Quoted 6 lines
Quoted 6 lines
A comment starting with ## inside an expression is now a syntax error. For instance, input
{ ##Quoted 7 lines
Quoted 7 lines
yields
/dev/stdin:2:1: Expected string or "}"Rather unfriendly error message, but we can fix that on top.
scripts/qapi.py def check_keys(expr_elem, meta, required,
Quoted 1 line
scripts/qapi.py +0
-0@@ -713,7 +856,7 @@ def check_keys(expr_elem, meta, required,optional=[]):
Quoted 13 lines
Quoted 7 lines
scripts/qapi.py def check_keys(expr_elem, meta, required, optional=[]): · line 859
Quoted 5 lines
scripts/qapi.py +1
-1% (key, meta, name)) -def check_exprs(exprs): +def check_exprs(exprs, strict_doc):Note: strict_doc=False unless this is
qapi2texi.py.For tests reasons: we may want to fix the test instead, or have a flag QAPI_CHECK/NOSTRICT_DOC=1 or an option.
Quoted 2 lines
Quoted 2 lines
scripts/qapi.py +0
-0global all_namesQuoted 9 lines
Quoted 9 lines
scripts/qapi.py def check_exprs(exprs): · line 871
Quoted 9 lines
scripts/qapi.py +4
-0# Learn the types and check for valid expression keys@@ -722,6 +865,11 @@ def check_exprs(exprs): for expr_elem in exprs: expr = expr_elem['expr'] info = expr_elem['info'] + + if strict_doc and 'doc' not in expr_elem: + raise QAPILineError(info, + "Expression missing documentationcomment")
Quoted 4 lines
Quoted 3 lines
scripts/qapi.py def check_exprs(exprs): · line 872
Quoted 1 line
scripts/qapi.py +1
-0+Why should we supress this error in programs other than
qapi2texi.py?
Quoted 7 lines
Quoted 1 line
because the tests don't have comments
Good point :)
Can we come up with a brief comment explaining this?
I fixed the tests instead (after all, we have complete control on what to
accept or not. that was boring but now it's done)
Quoted 92 lines
Quoted 5 lines
Quoted 1 line
Can't see a test for this one.
because tests aren't strict :)
I guess you'll tell me to fix the tests instead, so I did that in the
next
Quoted 9 lines
series.
Quoted 7 lines
Quoted 7 lines
scripts/qapi.py +0
-0if 'enum' in expr: check_keys(expr_elem, 'enum', ['data'], ['prefix']) add_enum(expr['enum'], info, expr['data'])@@ -780,6 +928,63 @@ def check_exprs(exprs): return exprsQuoted 10 lines
Quoted 4 lines
scripts/qapi.py def check_exprs(exprs): · line 931
Quoted 1 line
scripts/qapi.py +1
-0+def check_simple_doc(doc):You call this "free-form" elsewhere. Pick one name and stick to it. I think free-form is more descriptive than simple.
ok
Quoted 3 lines
Quoted 3 lines
scripts/qapi.py +3
-0+ if doc.symbol: + raise QAPILineError(doc.info, + "'%s' documention is not followed by thedefinition"
Quoted 11 lines
Quoted 3 lines
scripts/qapi.py def check_exprs(exprs): · line 935
Quoted 1 line
scripts/qapi.py +1
-0+ % doc.symbol)"Documentation for %s is not ..."
ok
Quoted 5 lines
Quoted 5 lines
scripts/qapi.py +5
-0+ + body = str(doc.body) + if re.search(r'@\S+:', body, re.MULTILINE): + raise QAPILineError(doc.info, + "Document body cannot contain @NAME:sections")
Quoted 10 lines
Quoted 6 lines
scripts/qapi.py def check_exprs(exprs): · line 943
Quoted 3 lines
scripts/qapi.py +3
-0+ + +def check_expr_doc(doc, expr, info):You call this "symbol" elsewhere. I think "definition" would be better than either.
ok
Quoted 1 line
Quoted 1 line
scripts/qapi.py +1
-0+ for i in ('enum', 'union', 'alternate', 'struct', 'command','event'):
Quoted 7 lines
Quoted 7 lines
scripts/qapi.py def check_exprs(exprs):
Quoted 7 lines
scripts/qapi.py +7
-0+ if i in expr: + meta = i + break + + name = expr[meta] + if doc.symbol != name: + raise QAPILineError(info, "Definition of '%s' followsdocumentation"
Quoted 35 lines
Quoted 9 lines
scripts/qapi.py def check_exprs(exprs): · line 954
Quoted 3 lines
scripts/qapi.py +3
-0+ " for '%s'" % (name, doc.symbol)) + if doc.has_meta('Returns') and 'command' not in expr: + raise QAPILineError(info, "Invalid return documentation")Suggest something like "'Returns:' is only valid for commands".
We accept 'Returns:' even when the command doesn't return anything, because we currently use it to document errors, too. Can't say I like that, but it's out of scope here.
ok
Quoted 22 lines
scripts/qapi.py def check_exprs(exprs): · line 963
Quoted 9 lines
scripts/qapi.py +9
-0+ + doc_args = set(doc.args.keys()) + if meta == 'union': + data = expr.get('base', []) + else: + data = expr.get('data', []) + if isinstance(data, dict): + data = data.keys() + args = set([name.strip('*') for name in data])Not fixed since v3:
* Flat union where 'base' is a string, e.g. union UserDefFlatUnion in qapi-schema-test.json has base 'UserDefUnionBase', args is
set(['a', 'B', 'e', 'D', 'f', 'i', 'o', 'n', 's', 'r', 'U'])* Command where 'data' is a string, e.g.
user_def_cmd0in qapi-schema-test.json has data 'Empty2', args isset(['E', 'm', 'p', '2', 't', 'y'])* Event where 'data' is a string, no test case handy (hole in test coverage)
Quoted 8 lines
scripts/qapi.py def check_exprs(exprs):
Quoted 5 lines
ok, I changed it that way, that fixes it:
scripts/qapi.py +4
-0+ if isinstance(data, list): + args = set([name.strip('*') for name in data]) + else: + args = set()Uh, sure this does the right thing when data is a dict?
yes, the line above takes care of extracting the keys in data.
Quoted 21 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
scripts/qapi.py +3
-0+ if meta == 'alternate' or \ + (meta == 'union' and not expr.get('discriminator')): + args.add('type')Quoted 8 lines
Quoted 4 lines
As explained in review of v3, this is only a subset of the real set of members. Computing the exact set is impractical when working with the abstract syntax tree. I believe we'll eventually have to rewrite this code to work with the QAPISchemaEntity instead.
I don't think we want to list all the members as this would lead to duplicated documentation. Instead it should document only the members of the expr being defined.
You're sticking to established practice, which makes lots of sense. However, established practice is a lot more clear for simple cases than for things like members inherited from base types, variant members and such. At some point, we'll have to figure out how we want not so simple cases documented. Until then, we can't really decide how to check documentation completeness.
Quoted 8 lines
Quoted 2 lines
In which case, it looks like this check is good
enough, no?For now, yes. Later on, maybe.
Let's document the limitation in a comment and the commit message, and move on.
I'd appreciate your help to list the limitations in the commit message, as I have not as thorough understanding as you, and even worse I often don't use the same name for the various concepts.
Quoted 345 lines
Quoted 3 lines
Quoted 3 lines
scripts/qapi.py def check_exprs(exprs): · line 968
Quoted 3 lines
scripts/qapi.py +2
-0+ if not doc_args.issubset(args): + raise QAPILineError(info, "Members documentation is not asubset of"
Quoted 1 line
Quoted 1 line
scripts/qapi.py def check_exprs(exprs): · line 969
Quoted 1 line
scripts/qapi.py +1
-0+ " API %r > %r" % (list(doc_args),list(args)))
Quoted 9 lines
Quoted 9 lines
scripts/qapi.py def check_exprs(exprs):
Quoted 9 lines
scripts/qapi.py +9
-0+ + +def check_docs(docs): + for doc in docs: + for section in doc.args.values() + doc.meta: + content = str(section) + if not content or content.isspace(): + raise QAPILineError(doc.info, + "Empty doc section '%s'" %section.name)
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
scripts/qapi.py +9
-0+ + if not doc.expr: + check_simple_doc(doc) + else: + check_expr_doc(doc, doc.expr, doc.info) + + return docs + + # # Schema compiler frontend #@@ -1249,9 +1454,11 @@ class QAPISchemaEvent(QAPISchemaEntity):Quoted 5 lines
Quoted 5 lines
scripts/qapi.py class QAPISchemaEvent(QAPISchemaEntity):
Quoted 5 lines
scripts/qapi.py +1
-2class QAPISchema(object): - def __init__(self, fname): + def __init__(self, fname, strict_doc=False): try: - self.exprs = check_exprs(QAPISchemaParser(open(fname,"r")).exprs)
Quoted 14 lines
Quoted 14 lines
scripts/qapi2texi.py
Quoted 11 lines
scripts/qapi.py +3
-0+ parser = QAPISchemaParser(open(fname, "r")) + self.exprs = check_exprs(parser.exprs, strict_doc) + self.docs = check_docs(parser.docs) self._entity_dict = {} self._predefining = True self._def_predefineds()scripts/qapi2texi.py new file +0
-0Still only skimming this one.
Quoted 7 lines
Quoted 7 lines
scripts/qapi2texi.py line 6
Quoted 7 lines
scripts/qapi2texi.py new file +6
-0@@ -0,0 +1,331 @@ +#!/usr/bin/env python +# QAPI texi generator +# +# This work is licensed under the terms of the GNU LGPL, version 2+. +# See the COPYING file in the top-level directory. +"""This script produces the documentation of a qapi schema intexinfo format"""
Quoted 146 lines
Quoted 135 lines
Quoted 135 lines
scripts/qapi2texi.py new file +135
-0+import re +import sys + +import qapi + +COMMAND_FMT = """ +@deftypefn {type} {{{ret}}} {name} @ +{{{args}}} + +{body} + +@end deftypefn + +""".format + +ENUM_FMT = """ +@deftp Enum {name} + +{body} + +@end deftp + +""".format + +STRUCT_FMT = """ +@deftp {{{type}}} {name} @ +{{{attrs}}} + +{body} + +@end deftp + +""".format + +EXAMPLE_FMT = """@example +{code} +@end example +""".format + + +def subst_strong(doc): + """Replaces *foo* by @strong{foo}""" + return re.sub(r'\*([^_\n]+)\*', r'@emph{\1}', doc) + + +def subst_emph(doc): + """Replaces _foo_ by @emph{foo}""" + return re.sub(r'\s_([^_\n]+)_\s', r' @emph{\1} ', doc) + + +def subst_vars(doc): + """Replaces @var by @code{var}""" + return re.sub(r'@([\w-]+)', r'@code{\1}', doc) + + +def subst_braces(doc): + """Replaces {} with @{ @}""" + return doc.replace("{", "@{").replace("}", "@}") + + +def texi_example(doc): + """Format @example""" + doc = subst_braces(doc).strip('\n') + return EXAMPLE_FMT(code=doc) + + +def texi_comment(doc): + """ + Format a comment + + Lines starting with: + - |: generates an @example + - =: generates @section + - ==: generates @subsection + - 1. or 1): generates an @enumerate @item + - o/*/-: generates an @itemize list + """ + lines = [] + doc = subst_braces(doc) + doc = subst_vars(doc) + doc = subst_emph(doc) + doc = subst_strong(doc) + inlist = "" + lastempty = False + for line in doc.split('\n'): + empty = line == "" + + if line.startswith("| "): + line = EXAMPLE_FMT(code=line[2:]) + elif line.startswith("= "): + line = "@section " + line[2:] + elif line.startswith("== "): + line = "@subsection " + line[3:] + elif re.match("^([0-9]*[.)]) ", line): + if not inlist: + lines.append("@enumerate") + inlist = "enumerate" + line = line[line.find(" ")+1:] + lines.append("@item") + elif re.match("^[o*-] ", line): + if not inlist: + lines.append("@itemize %s" % {'o': "@bullet", + '*': "@minus", + '-': ""}[line[0]]) + inlist = "itemize" + lines.append("@item") + line = line[2:] + elif lastempty and inlist: + lines.append("@end %s\n" % inlist) + inlist = "" + + lastempty = empty + lines.append(line) + + if inlist: + lines.append("@end %s\n" % inlist) + return "\n".join(lines) + + +def texi_args(expr, key="data"): + """ + Format the functions/structure/events.. arguments/members + """ + if key not in expr: + return "" + + args = expr[key] + arg_list = [] + if isinstance(args, str): + arg_list.append(args) + else: + for name, typ in args.iteritems(): + # optional arg + if name.startswith("*"): + name = name[1:]Quoted 8 lines
scripts/qapi2texi.py line 145
Quoted 4 lines
scripts/qapi2texi.py new file +4
-0+ arg_list.append("['%s': @var{%s}]" % (name, typ)) + # regular arg + else: + arg_list.append("'%s': @var{%s}" % (name, typ))Inappropriate use of @var. @var is for metasyntactic variables, i.e. something that stands for another piece of text. typ isn't, it's the name of a specific QAPI type. I think you should use @code.
yes
Quoted 8 lines
Quoted 4 lines
This is the reason why the type names in qemu-qmp-ref.txt are often mangled, e.g.
-- Struct: VersionInfo { 'qemu': VERSIONTRIPLE, 'package': STR }
Right, we have format issue here. If we change it for @code, we get additional quotes in the text format. The simpler is to use no format or @t{}
Pick something you like.
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
scripts/qapi2texi.py new file +21
-0+ + return ", ".join(arg_list) + + +def texi_body(doc): + """ + Format the body of a symbol documentation: + - a table of arguments + - followed by "Returns/Notes/Since/Example" sections + """ + def _section_order(section): + return {"Returns": 0, + "Note": 1, + "Notes": 1, + "Since": 2, + "Example": 3, + "Examples": 3}[section] + + body = "@table @asis\n" + for arg, section in doc.args.iteritems(): + desc = str(section)Quoted 8 lines
Quoted 8 lines
scripts/qapi2texi.py
Quoted 8 lines
scripts/qapi2texi.py new file +8
-0+ opt = '' + if desc.startswith("#optional"): + desc = desc[10:] + opt = ' *' + elif desc.endswith("#optional"): + desc = desc[:-10] + opt = ' *' + body += "@item @code{'%s'}%s\n%s\n" % (arg, opt,
texi_comment(desc))Quoted 44 lines
Quoted 24 lines
Quoted 24 lines
scripts/qapi2texi.py new file +24
-0+ body += "@end table\n" + body += texi_comment(str(doc.body)) + + meta = sorted(doc.meta, key=lambda i: _section_order(i.name)) + for section in meta: + name, doc = (section.name, str(section)) + func = texi_comment + if name.startswith("Example"): + func = texi_example + + body += "\n@quotation %s\n%s\n@end quotation" % \ + (name, func(doc)) + return body + + +def texi_alternate(expr, doc): + """ + Format an alternate to texi + """ + args = texi_args(expr) + body = texi_body(doc) + return STRUCT_FMT(type="Alternate", + name=doc.symbol, + attrs="[ " + args + " ]",Quoted 8 lines
scripts/qapi2texi.py line 204
Quoted 6 lines
scripts/qapi2texi.py new file +6
-0+ body=body) + + +def texi_union(expr, doc): + """ + Format an union to texiI think it's "a union".
ok
Quoted 9 lines
Quoted 8 lines
scripts/qapi2texi.py new file +8
-0+ """ + attrs = "@{ " + texi_args(expr, "base") + " @}" + discriminator = expr.get("discriminator") + if not discriminator: + union = "Flat Union" + discriminator = "type" + else: + union = "Union"Quoted 25 lines
Quoted 1 line
Condition is backwards.
fixed
Quoted 21 lines
scripts/qapi2texi.py line 220
Quoted 8 lines
scripts/qapi2texi.py new file +8
-0+ attrs += " + '%s' = [ " % discriminator + attrs += texi_args(expr, "data") + " ]" + body = texi_body(doc) + + return STRUCT_FMT(type=union, + name=doc.symbol, + attrs=attrs, + body=body)You're inventing syntax here. Example output:
-- Union: QCryptoBlockOpenOptions { QCryptoBlockOptionsBase } +
'format' = [ 'qcow': QCRYPTOBLOCKOPTIONSQCOW, 'luks':
QCRYPTOBLOCKOPTIONSLUKS ]The options that are available for all encryption formats when opening an existing volume
Since: 2.6-- Flat Union: ImageInfoSpecific { } + 'type' = [ 'qcow2':
IMAGEINFOSPECIFICQCOW2, 'vmdk': IMAGEINFOSPECIFICVMDK,'luks':
Quoted 21 lines
Quoted 6 lines
QCRYPTOBLOCKINFOLUKS ]
A discriminated record of image format specific information structures.
Since: 1.7Quoted 8 lines
Note that QCryptoBlockOpenOptions is actually a flat union, and ImageInfoSpecific a simple union. As I said, the condition is backwards.
The meaning of the attrs part is unobvious. Familiarity with schema syntax doesn't really help.
Could we simply use schema syntax here?
Union: QCryptoBlockOpenOptions {
'base': QCryptoBlockOptionsBase, 'discriminator': 'format',
'data': { 'qcow': QCryptoBlockOptionsQCow, 'luks':
QCryptoBlockCreateOptionsLUKS }Quoted 4 lines
}
Doesn't look obvious either and pollute the documentation with schema-specific parameters.
The schema syntax for flat unions is pretty horrid :) I hope to improve it, but there's more urgent fish to fry.
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
If not: whatever format you use, you first need to explain it.
I am not sure my solution is the best and will remain, but ok let's try
to
Quoted 1 line
document it for now.
Before you pour time into documenting what you have, we should probably discuss what we need.
Can this be marked as limitation and improved laster? The series is big, patch is getting bigger over time, it's quite hard to handle all your requirements in one go.
Quoted 299 lines
Quoted 31 lines
Quoted 31 lines
+
Quoted 17 lines
scripts/qapi2texi.py new file +17
-0+ +def texi_enum(expr, doc): + """ + Format an enum to texi + """ + for i in expr['data']: + if i not in doc.args: + doc.args[i] = '' + body = texi_body(doc) + return ENUM_FMT(name=doc.symbol, + body=body) + + +def texi_struct(expr, doc): + """ + Format a struct to texi + """scripts/qapi2texi.py line 248
Quoted 10 lines
scripts/qapi2texi.py new file +10
-0+ args = texi_args(expr) + body = texi_body(doc) + attrs = "@{ " + args + " @}" + base = expr.get("base") + if base: + attrs += " + %s" % base + return STRUCT_FMT(type="Struct", + name=doc.symbol, + attrs=attrs, + body=body)More syntax invention. Example output:
Quoted 7 lines
Quoted 7 lines
-- Struct: BlockdevOptionsReplication { 'mode': REPLICATIONMODE,
['top-id': STR] } + BlockdevOptionsGenericFormat''mode''
the replication mode
''top-id'' *
In secondary mode, node name or device ID of the root nodewho
Quoted 1 line
Quoted 1 line
owns the replication node chain. Must not be given in
primary
Quoted 5 lines
Quoted 5 lines
mode.
Driver specific block device options for replication
Since: 2.8Meaning of the attrs part is perhaps more guessable here, but it's
still
Quoted 9 lines
Quoted 9 lines
guesswork.
The meaning of * after ''top-id'' is also unobvious.
Note the redundancy between the attrs part and the body: both state member names and optionalness. The body doesn't state member types and base type. If we fixed that, we could drop the attrs part and save us the trouble of defining and explaining a syntax for it.
Quoted 8 lines
Quoted 8 lines
Let me take a step back. This document is about the QMP wire format. There are no such things as simple and flat unions on the wire, only JSON objects. QMP introspection duly describes a type's JSON objects, not how it's defined in QAPI. I think QMP documentation should ideally do the same.
QMP introspection uses a common structure for struct, simple and flat
union: common members, variants, and if variants, then the commonmember
Quoted 9 lines
Quoted 7 lines
that serves as tag. See introspect.json for details.
Base types are flattened away. Appropriate for introspection, but documentation shouldn't do that.
I wrote "ideally" because it's probably too big a step. I'm willing to settle for something less than ideal.
I don't have clear idea what to do here, so if we can leave that for
later,
Quoted 1 line
that would be nice for me (I am already spending more time than I
imagined
Quoted 1 line
I would on doc stuff)
Me too, if that's any consolation...
Perhaps I can find a bit of time to think so I can propose what we could do.
Quoted 73 lines
Quoted 40 lines
Quoted 40 lines
scripts/qapi2texi.py new file +40
-0+ + +def texi_command(expr, doc): + """ + Format a command to texi + """ + args = texi_args(expr) + ret = expr["returns"] if "returns" in expr else "" + body = texi_body(doc) + return COMMAND_FMT(type="Command", + name=doc.symbol, + ret=ret, + args="(" + args + ")", + body=body) + + +def texi_event(expr, doc): + """ + Format an event to texi + """ + args = texi_args(expr) + body = texi_body(doc) + return COMMAND_FMT(type="Event", + name=doc.symbol, + ret="", + args="(" + args + ")", + body=body) + + +def texi_expr(expr, doc): + """ + Format an expr to texi + """ + (kind, _) = expr.items()[0] + + fmt = {"command": texi_command, + "struct": texi_struct, + "enum": texi_enum, + "union": texi_union, + "alternate": texi_alternate,Quoted 8 lines
scripts/qapi2texi.py line 293
Quoted 5 lines
scripts/qapi2texi.py new file +5
-0+ "event": texi_event} + try: + fmt = fmt[kind] + except KeyError: + raise ValueError("Unknown expression kind '%s'" % kind)The try / except converts one kind of error into another. What does that buy us? As far as I can tell, this shouldn't ever happen.
dropped
Quoted 22 lines
Quoted 22 lines
scripts/qapi2texi.py new file +22
-0+ + return fmt(expr, doc) + + +def texi(docs): + """ + Convert QAPI schema expressions to texi documentation + """ + res = [] + for doc in docs: + expr = doc.expr + if not expr: + res.append(texi_body(doc)) + continue + try: + doc = texi_expr(expr, doc) + res.append(doc) + except: + print >>sys.stderr, "error at @%s" % doc.info + raise + + return '\n'.join(res)Quoted 8 lines
Quoted 8 lines
scripts/qapi2texi.py
Quoted 8 lines
scripts/qapi2texi.py new file +8
-0+ + +def main(argv): + """ + Takes schema argument, prints result to stdout + """ + if len(argv) != 2: + print >>sys.stderr, "%s: need exactly 1 argument: SCHEMA" %argv[0]
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
scripts/qapi2texi.py new file +5
-0+ sys.exit(1) + + schema = qapi.QAPISchema(argv[1], strict_doc=True) + print texi(schema.docs) +Quoted 8 lines
Quoted 8 lines
docs/qapi-code-gen.txt QAPI parser does not). At present, there is no
Quoted 8 lines
scripts/qapi2texi.py new file +3
-0+ +if __name__ == "__main__": + main(sys.argv)docs/qapi-code-gen.txt +0
-0@@ -45,16 +45,13 @@ QAPI parser does not). At present, there is noplace where a QAPI
Quoted 3 lines
Quoted 3 lines
docs/qapi-code-gen.txt QAPI parser does not). At present, there is no place where a QAPI
Quoted 3 lines
docs/qapi-code-gen.txt +0
-0schema requires the use of JSON numbers or null. Comments are allowed; anything between an unquoted # and thefollowing
Quoted 5 lines
Quoted 5 lines
docs/qapi-code-gen.txt QAPI parser does not). At present, there is no place where a QAPI
Quoted 5 lines
docs/qapi-code-gen.txt +0
-5-newline is ignored. Although there is not yet a documentation -generator, a form of stylized comments has developed for consistently -documenting details about an expression and when it was added to the -schema. The documentation is delimited between two lines of ##, then -the first line names the expression, an optional overview isprovided,
Quoted 1 line
Quoted 1 line
docs/qapi-code-gen.txt QAPI parser does not). At present, there is no · line 53
Quoted 1 line
docs/qapi-code-gen.txt +0
-1-then individual documentation about each member of 'data' isprovided,
Quoted 7 lines
Quoted 7 lines
docs/qapi-code-gen.txt QAPI parser does not). At present, there is no place where a QAPI
Quoted 7 lines
docs/qapi-code-gen.txt +3
-4-and finally, a 'Since: x.y.z' tag lists the release that introduced -the expression. Optional members are tagged with the phrase -'#optional', often with their default value; and extensions added -after the expression was first released are also given a '(since +newline is ignored. The documentation is delimited between two lines +of ##, then the first line names the expression, an optional overview +is provided, then individual documentation about each member of'data'
Quoted 4 lines
Quoted 4 lines
docs/qapi-code-gen.txt QAPI parser does not). At present, there is no place where a QAPI
Quoted 4 lines
docs/qapi-code-gen.txt +4
-0+is provided, and finally, a 'Since: x.y.z' tag lists the release that +introduced the expression. Optional members are tagged with the +phrase '#optional', often with their default value; and extensions +added after the expression was first released are also given a'(since
Quoted 29 lines
Quoted 29 lines
Quoted 12 lines
docs/qapi-code-gen.txt +5
-0x.y.z)' comment. For example: ##@@ -73,12 +70,49 @@ x.y.z)' comment. For example: # (Since 2.0) # # Since: 0.14.0 + # + # Notes: You can also make a list: + # - with items + # - like this + #docs/qapi-code-gen.txt x.y.z)' comment. For example: · line 87
Quoted 10 lines
docs/qapi-code-gen.txt +5
-0+ # Example: + # + # -> { "execute": ... } + # <- { "return": ... } + # ## { 'struct': 'BlockStats', 'data': {'*device': 'str', 'stats': 'BlockDeviceStats', '*parent': 'BlockStats', '*backing': 'BlockStats'} }This example gives an idea of how to document struct types. But the reader is left guessing how to document other kinds of definitions. In particular, there's no mention of "Returns", "Note" and "Examples" sections anywhere in this file. As is, this could do for a tutorial, but this file is a *reference*, not a tutorial.
Quoted 1 line
Quoted 1 line
For a reference, we need to be more thorough. A doc comments section
on
Quoted 9 lines
Quoted 6 lines
its own seems advisable.
I guess doc comment examples are best added to the schema code examples in sections === Struct types ===, ..., === Events ===.
Careful review for completeness is advised.
So far we did quite fine with the generic example. I am not convinced we need to have doc comments for all kinds of types, it looks redundant to
me.
Well, so far we didn't require people to write well-formed doc comments.
Without such comments in qapi-code-gen.txt's examples, they become incomplete. Pity, because I like to feed them to the QAPI generators; extracted like this:
$ sed '1,/\$ cat example-schema.json/d;/^[^ ]/,$d;s/^ //' ../docs/qapi-code-gen.txt >example-schema.jsonQuoted 30 lines
Quoted 21 lines
Quoted 21 lines
docs/qapi-code-gen.txt +21
-0+It's also possible to create documentation sections, such as: + + ## + # = Section + # == Subsection + # + # Some text foo with *strong* and _emphasis_ + # 1. with a list + # 2. like that + # + # And some code: + # | $ echo foo + # | -> do this + # | <- get that + # + ## + +Text *foo* and _foo_ are for "strong" and "emphasis" styles (they do +not work over multiple lines). @foo is used to reference a symbol. + +Lines starting with the following characters and a space:Quoted 8 lines
docs/qapi-code-gen.txt x.y.z)' comment. For example: · line 115
Quoted 6 lines
docs/qapi-code-gen.txt +6
-0+- | are examples +- = are top section +- == are subsection +- X. or X) are enumerations (X is any number) +- o/*/- are itemized list +Is this doc markup documentation complete?
Quoted 9 lines
I think so
Quoted 2 lines
Is it related to any existing text markup language? Hmm, the commit message calls it "Markdown-like". Should we mention that here?
I'll use "annotations" instead in the doc
Quoted 2 lines
Is all markup valid in all contexts? For instance, is = Section valid in symbol blocks? What does | (or any markup for that matter) do
within
Quoted 3 lines
Quoted 1 line
an Example section?
Example is verbatim<
Signature · 1 line
Marc-André Lureau
Re: [Qemu-devel] [PATCH v5 13/17] qapi: add qapi2texi script
Quoted 9 lines · Marc-André Lureau
Hi
Quoted 5 lines · Markus Armbruster
I had to resort to diff to find your replies, and massage the text manually to produce a readable reply myself. Please quote the usual way.
Quoted 4 lines
I'd have to switch to something else than gmail (which bothers me for various reasons, let's not discuss the merits of various mail clients please ;) In general, I don't have problems, but this mail is rather big, sorry for the inconvenience..
This time, it was only a bit of mojibake and lots of unwanted line wraps %-)
I'll try to cut unnecessary quoted material this time.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines · Markus Armbruster
Quoted 6 lines
Quoted 3 lines · Marc-André Lureau
As the name suggests, the qapi2texi script converts JSON QAPI description into a texi file suitable for different target formats (info/man/txt/pdf/html...).
[...]
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Missing: a brief discussion of deficiencies. These include:
* The generated QMP documentation includes internal types
We use qapi-schema.json both for defining the external QMP interface and for defining internal types.
qmp-introspect.pycarefully separates the two, to not expose internal types.qapi2texi.pyhappily exposes everything.Currently, about a fifth of the types in the generated docs are internal:
AcpiTableOptions
BiosAtaTranslation
BlockDeviceMapEntry
COLOMessage
COLOMode
DummyForceArrays
FailoverStatus
FloppyDriveType
ImageCheck
LostTickPolicy
MapEntry
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
MigrationParameter
NetClientDriver
NetFilterDirection
NetLegacy
NetLegacyNicOptions
NetLegacyOptions
NetLegacyOptionsKind
Netdev
4>> > > NetdevBridgeOptions
Quoted 61 lines
Quoted 61 lines
Quoted 61 lines
Quoted 49 lines
NetdevDumpOptions
NetdevHubPortOptions
NetdevL2TPv3Options
NetdevNetmapOptions
NetdevNoneOptions
NetdevSocketOptions
NetdevTapOptions
NetdevUserOptions
NetdevVdeOptions
NetdevVhostUserOptions
NumaNodeOptions
NumaOptions
NumaOptionsKind
OnOffAuto
OnOffSplit
PreallocMode
QCryptoBlockCreateOptions
QCryptoBlockCreateOptionsLUKS
QCryptoBlockFormat
QCryptoBlockInfo
QCryptoBlockInfoBase
QCryptoBlockInfoQCow
QCryptoBlockOpenOptions
QCryptoBlockOptionsBase
QCryptoBlockOptionsLUKS
QCryptoBlockOptionsQCow
QCryptoSecretFormat
QCryptoTLSCredsEndpoint
QapiErrorClass
ReplayMode
X86CPUFeatureWordInfo
X86CPURegister32Generating documentation for internal types might be useful, but letting them pollute QMP interface documentation isn't. Needs fixing before we release. Until then, needs a FIXME comment in
qapi2texi.py.* Union support is lacking
The doc string language is adequate for documenting commands, events, and non-union types. It doesn't really handle union variants. Hardly surprising, as you fitted the language do existing practice, and existing (mal-)practice is neglecting to document union variant members.
* Documentation is lacking
See review of qapi-code-gen.txt below.
Quoted 8 lines
* Doc comment error message positions are imprecise
They always point to the beginning of the comment.
* Probably more
We should update this with noteworthy findings during review. I tried, but I suspect I missed some.
ok
Quoted 1 line
Quoted 1 line
Signed-off-by Marc-André Lureau <[email protected]>
[...]
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
scripts/qapi.py +0
-0
[...]
Quoted 68 lines
Quoted 68 lines
Quoted 60 lines
Quoted 29 lines
scripts/qapi.py
Quoted 2 lines
scripts/qapi.py +2
-0+ def append(self, line): + """Adds a # comment line, to be parsed and added to current section"""Imperative mood:
"""Add a comment line, to be parsed and added to the current section."""
However, we're not always adding to the current section, we can also start a new one. The following avoids suggesting anything about the current section:
"""Parse a comment line and add it to the documentation."""
When the function name is a verb, and its doc string starts with a different verb, the name might be suboptimal. Use your judgement.
If this one-liner is too terse, we can try a multi-line doc string:
"""Parse a comment line and add it to the documentation.
TODO should we tell more about how we parse?
Args:
line: the comment starting with '#', with the newline stripped.Raises:
QAPISchemaError: TODO explain error conditions
"""Quoted 6 lines
Format stolen from the Google Python Style Guide[2], because PEP257 is of not much help there.
Once you start with such elaborate doc strings, pressure will likely mount to do the same elsewhere. Could be a distraction right now. Use your judgement.
ok, thanks
Quoted 22 lines
scripts/qapi.py class QAPILineError(Exception): · line 172
Quoted 8 lines
scripts/qapi.py +8
-0+ line = line[1:] + if not line: + self._append_freeform(line) + return + + if line[0] != ' ': + raise QAPISchemaError(self.parser, "missing space after #") + line = line[1:]QAPISchemaError takes the error position from its QAPISchemaParser argument. In other words, the error position depends on the state of the parser when it calls this function. Turns out the position is the beginning of the comment. Servicable here. Action at a distance, though.
Less strict:
# strip leading # and space line = line[1:] if line[0] == ' ': line = line[1:]Quoted 4 lines
Quoted 1 line
Also avoids special-casing empty comments.
That would raise "IndexError: string index out of range" on empty comment lines ("#")
Fixable:
ifline.startswith(' '):
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Also I'd like to keep the error in case a space is missing (it caught some already).
On the one hand, I share your distaste for lack of space between # and comment text. On the other hand, I dislike enforcing spacing
inconsistently: enforce in doc comments, but not in other comments.It's only enforced for doc comments, which I think is fair.
If it's worth enforcing for some comments (which I doubt), then why isn't it worth enforcing for all of them? Anyway, it's something we can fiddle with on top.
[...]
Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
Quoted 6 lines
Not fixed since v3:
* Flat union where 'base' is a string, e.g. union UserDefFlatUnion in qapi-schema-test.json has base 'UserDefUnionBase', args is
set(['a', 'B', 'e', 'D', 'f', 'i', 'o', 'n', 's', 'r', 'U'])Quoted 6 lines
* Command where 'data' is a string, e.g.
user_def_cmd0in qapi-schema-test.json has data 'Empty2', args isset(['E', 'm', 'p', '2', 't', 'y'])* Event where 'data' is a string, no test case handy (hole in test coverage)
ok, I changed it that way, that fixes it:
scripts/qapi.py +4
-0+ if isinstance(data, list): + args = set([name.strip('*') for name in data]) + else: + args = set()
Quoted 4 lines
Quoted 2 lines
Uh, sure this does the right thing when data is a dict?
yes, the line above takes care of extracting the keys in data.
Ah, I misunderstood. First mapping dict to list of keys, then dealing with either list or other should indeed work.
Quoted 23 lines
Quoted 23 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
scripts/qapi.py +3
-0+ if meta == 'alternate' or \ + (meta == 'union' and not expr.get('discriminator')): + args.add('type')Quoted 8 lines
Quoted 4 lines
As explained in review of v3, this is only a subset of the real set of members. Computing the exact set is impractical when working with the abstract syntax tree. I believe we'll eventually have to rewrite this code to work with the QAPISchemaEntity instead.
I don't think we want to list all the members as this would lead to duplicated documentation. Instead it should document only the members of the expr being defined.
You're sticking to established practice, which makes lots of sense. However, established practice is a lot more clear for simple cases than for things like members inherited from base types, variant members and such. At some point, we'll have to figure out how we want not so simple cases documented. Until then, we can't really decide how to check documentation completeness.
Quoted 2 lines
In which case, it looks like this check is good
enough, no?
Quoted 8 lines
Quoted 4 lines
For now, yes. Later on, maybe.
Let's document the limitation in a comment and the commit message, and move on.
I'd appreciate your help to list the limitations in the commit message, as I have not as thorough understanding as you, and even worse I often don't use the same name for the various concepts.
I'll try.
Deducing concept names from code isn't always easy...
[...]
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
scripts/qapi2texi.py new file +0
-0
[...]
Quoted 76 lines
Quoted 76 lines
Quoted 63 lines
Quoted 5 lines
scripts/qapi2texi.py line 204
Quoted 3 lines
scripts/qapi2texi.py new file +3
-0+def texi_union(expr, doc): + """ + Format an union to texiI think it's "a union".
ok
Quoted 10 lines
scripts/qapi2texi.py line 212
Quoted 8 lines
scripts/qapi2texi.py new file +8
-0+ """ + attrs = "@{ " + texi_args(expr, "base") + " @}" + discriminator = expr.get("discriminator") + if not discriminator: + union = "Flat Union" + discriminator = "type" + else: + union = "Union"Condition is backwards.
fixed
Quoted 27 lines
scripts/qapi2texi.py line 220
Quoted 8 lines
scripts/qapi2texi.py new file +8
-0+ attrs += " + '%s' = [ " % discriminator + attrs += texi_args(expr, "data") + " ]" + body = texi_body(doc) + + return STRUCT_FMT(type=union, + name=doc.symbol, + attrs=attrs, + body=body)You're inventing syntax here. Example output:
-- Union: QCryptoBlockOpenOptions { QCryptoBlockOptionsBase } +
'format' = [ 'qcow': QCRYPTOBLOCKOPTIONSQCOW, 'luks':
QCRYPTOBLOCKOPTIONSLUKS ]The options that are available for all encryption formats when opening an existing volume
Since: 2.6-- Flat Union: ImageInfoSpecific { } + 'type' = [ 'qcow2':
IMAGEINFOSPECIFICQCOW2, 'vmdk': IMAGEINFOSPECIFICVMDK, 'luks':
QCRYPTOBLOCKINFOLUKS ]A discriminated record of image format specific information structures.
Since: 1.7Quoted 8 lines
Note that QCryptoBlockOpenOptions is actually a flat union, and ImageInfoSpecific a simple union. As I said, the condition is backwards.
The meaning of the attrs part is unobvious. Familiarity with schema syntax doesn't really help.
Could we simply use schema syntax here?
Union: QCryptoBlockOpenOptions {
'base': QCryptoBlockOptionsBase, 'discriminator': 'format',
'data': { 'qcow': QCryptoBlockOptionsQCow, 'luks':
QCryptoBlockCreateOptionsLUKS }Quoted 4 lines
}
Doesn't look obvious either and pollute the documentation with schema-specific parameters.
The schema syntax for flat unions is pretty horrid :) I hope to improve it, but there's more urgent fish to fry.
Quoted 4 lines
Quoted 1 line
If not: whatever format you use, you first need to explain it.
I am not sure my solution is the best and will remain, but ok let's try to document it for now.
Quoted 7 lines
Quoted 3 lines
Before you pour time into documenting what you have, we should probably discuss what we need.
Can this be marked as limitation and improved laster? The series is big, patch is getting bigger over time, it's quite hard to handle all your requirements in one go.
I'm sure it is!
How about this: you split off the code to derive documentation from the schema expressions into its own patch. The initial qapi2texi patch gets a FIXME comment instead, explaining what kind of information the generated documentation lacks. I think it's basically member types. The split-off patch then resolves that FIXME.
This lets me apply the first patch. We can then discuss how to do the second patch better. If you're out of time or energy on this topic (I'd understand), you could even leave it to me. After all, it's me who's particular about it...
[...]
PATCH v5 14/17 texi2pod: learn quotation, deftp and deftypefn
In reply to Marc-André LureauLearn a few more markups used for API documentation.
--- scripts/texi2pod.pl | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-)
scripts/texi2pod.pl +50 -3
@@ -37,6 +37,7 @@ $inf = ""; $ibase = ""; @ipath = (); $encoding = undef; +@args = (); while ($_ = shift) { if (/^-D(.*)$/) {
@@ -162,7 +163,8 @@ while(<$inf>) { if ($ended =~ /^(?:ifset|ifclear|ignore|menu|iftex)$/) { $skipping = pop @skstack; next; - } elsif ($ended =~ /^(?:example|smallexample|display)$/) { + } elsif ($ended =~ /^(?:example|smallexample|display + |quotation|deftp|deftypefn)$/x) { $shift = ""; $_ = ""; # need a paragraph break } elsif ($ended =~ /^(?:itemize|enumerate|[fv]?table)$/) {
@@ -303,6 +305,7 @@ while(<$inf>) { $ic =~ s/\@(?:code|kbd)/C/; $ic =~ s/\@(?:dfn|var|emph|cite|i)/I/; $ic =~ s/\@(?:file)/F/; + $ic =~ s/\@(?:asis)//; $_ = "\n=over 4\n"; };
@@ -323,10 +326,54 @@ while(<$inf>) { $_ = "\n=item ".join (" : ", @columns)."\n"; }; + /^\@(quotation)\s*(.+)?$/ and do { + push @endwstack, $endw; + $endw = $1; + $_ = "\n$2:" + }; + + /^{(.*)}$|^(.*)$/ and $#args > 0 and do { + $kind = $args[0]; + $arguments = $1 // ""; + if ($endw eq "deftypefn") { + $ret = $args[1]; + $fname = "B<$args[2]>"; + $_ = $ret ? "$ret " : ""; + $_ .= "$fname $arguments ($kind)"; + } else { + $_ = "B<$args[1]> ($kind)\n\n$arguments"; + } + @args = (); + }; + + /^\@(deftp)\s*(.+)?$/ and do { + push @endwstack, $endw; + $endw = $1; + $arg = $2; + $arg =~ s/{([^}]*)}/$1/g; + $arg =~ s/\@$//; + @args = split (/ /, $arg); + $_ = ""; + }; + + /^\@(deftypefn)\s*(.+)?$/ and do { + push @endwstack, $endw; + $endw = $1; + $arg = $2; + $arg =~ s/{([^}]*)}/$1/g; + $arg =~ s/\@$//; + @args = split (/ /, $arg); + $_ = ""; + }; + /^\@itemx?\s*(.+)?$/ and do { if (defined $1) { - # Entity escapes prevent munging by the <> processing below. - $_ = "\n=item $ic\<$1\>\n"; + if ($ic eq "") { + $_ = "\n=item $1\n"; + } else { + # Entity escapes prevent munging by the <> processing below. + $_ = "\n=item $ic\<$1\>\n"; + } } else { $_ = "\n=item $ic\n"; $ic =~ y/A-Ya-y/B-Zb-z/;
Signature · 1 line
2.10.0
PATCH v5 15/17 (SQUASHED) move doc to schema
In reply to Marc-André Lureauqmp-commands: move 'add_client' doc to schema
qmp-commands: move 'query-name' doc to schema
qmp-commands: move 'query-kvm' doc to schema
qmp-commands: move 'query-status' doc to schema
qmp-commands: move 'query-uuid' doc to schema
qmp-commands: move 'query-chardev' doc to schema
qmp-commands: move 'query-chardev-backends' doc to schema
qmp-commands: move 'ringbuf-write' doc to schema
qmp-commands: move 'ringbuf-read' doc to schema
qmp-commands: move 'query-events' doc to schema
qmp-commands: move 'query-migrate' doc to schema
qmp-commands: move 'migrate-set-capabilities' doc to schema
qmp-commands: move 'query-migrate-capabilities' doc to schema
qmp-commands: move 'migrate-set-parameters' doc to schema
qmp-commands: move 'query-migrate-parameters' doc to schema
qmp-commands: move 'client_migrate_info' doc to schema
qmp-commands: move 'migrate-start-postcopy' doc to schema
qmp-commands: move 'query-mice' doc to schema
qmp-commands: move 'query-cpus' doc to schema
qmp-commands: move 'query-iothreads' doc to schema
qmp-commands: move 'query-vnc' doc to schema
qmp-commands: move 'query-spice' doc to schema
qmp-commands: move 'query-balloon' doc to schema
qmp-commands: move 'query-pci' doc to schema
qmp-commands: move 'quit' doc to schema
qmp-commands: move 'stop' doc to schema
qmp-commands: move 'system_reset' doc to schema
qmp-commands: move 'system_powerdown' doc to schema
qmp-commands: move 'cpu-add' doc to schema
qmp-commands: move 'add_client' doc to schema
qmp-commands: move 'query-name' doc to schema
qmp-commands: move 'query-kvm' doc to schema
qmp-commands: move 'query-status' doc to schema
qmp-commands: move 'query-uuid' doc to schema
qmp-commands: move 'query-chardev' doc to schema
qmp-commands: move 'query-chardev-backends' doc to schema
qmp-commands: move 'ringbuf-write' doc to schema
qmp-commands: move 'ringbuf-read' doc to schema
qmp-commands: move 'query-events' doc to schema
qmp-commands: move 'query-migrate' doc to schema
qmp-commands: move 'migrate-set-capabilities' doc to schema
qmp-commands: move 'query-migrate-capabilities' doc to schema
qmp-commands: move 'migrate-set-parameters' doc to schema
qmp-commands: move 'query-migrate-parameters' doc to schema
qmp-commands: move 'client_migrate_info' doc to schema
qmp-commands: move 'migrate-start-postcopy' doc to schema
qmp-commands: move 'query-mice' doc to schema
qmp-commands: move 'query-cpus' doc to schema
qmp-commands: move 'query-iothreads' doc to schema
qmp-commands: move 'query-vnc' doc to schema
qmp-commands: move 'query-spice' doc to schema
qmp-commands: move 'query-balloon' doc to schema
qmp-commands: move 'query-pci' doc to schema
qmp-commands: move 'quit' doc to schema
qmp-commands: move 'stop' doc to schema
qmp-commands: move 'system_reset' doc to schema
qmp-commands: move 'system_powerdown' doc to schema
qmp-commands: move 'cpu-add' doc to schema
qmp-commands: move 'memsave' doc to schema
Notice that "cpu" argument is actually "cpu-index" in the json.
qmp-commands: move 'pmemsave' doc to schema
qmp-commands: move 'cont' doc to schema
qmp-commands: move 'system_wakeup' doc to schema
qmp-commands: move 'inject-nmi' doc to schema
qmp-commands: move 'set_link' doc to schema
qmp-commands: move 'balloon' doc to schema
qmp-commands: move 'transaction' doc to schema
qmp-commands: move 'human-monitor-command' doc to schema
qmp-commands: move 'migrate_cancel' doc to schema
qmp-commands: move 'migrate_set_downtime' doc to schema
qmp-commands: move 'migrate_set_speed' doc to schema
qmp-commands: move 'query-migrate-cache-size' doc to schema
qmp-commands: move 'set_password' doc to schema
qmp-commands: move 'expire_password' doc to schema
qmp-commands: move 'change' doc to schema
qmp-commands: move 'migrate' doc to schema
qmp-commands: move 'migrate-incoming' doc to schema
qmp-commands: move 'xen-save-devices-state' doc to schema
qmp-commands: move 'xen-set-global-dirty-log' doc to schema
qmp-commands: move 'device_del' doc to schema
qmp-commands: move 'dump-guest-memory' doc to schema
qmp-commands: move 'query-dump-guest-memory-capability' doc to schema
qmp-commands: move 'dump-skeys' doc to schema
qmp-commands: move 'netdev_add' doc to schema
qmp-commands: move 'netdev_del' doc to schema
qmp-commands: move 'object-add' doc to schema
qmp-commands: move 'object-del' doc to schema
qmp-commands: move 'getfd' doc to schema
qmp-commands: move 'closefd' doc to schema
qmp-commands: move 'add-fd' doc to schema
qmp-commands: move 'remove-fd' doc to schema
qmp-commands: move 'query-fdsets' doc to schema
qmp-commands: move 'send-key' doc to schema
qmp-commands: move 'screendump' doc to schema
qmp-commands: move 'chardev-add' doc to schema
qmp-commands: move 'chardev-remove' doc to schema
qmp-commands: move 'query-tpm-models' doc to schema
qmp-commands: move 'query-tpm-types' doc to schema
qmp-commands: move 'query-tpm' doc to schema
qmp-commands: move 'query-command-line-options' doc to schema
qmp-commands: move 'query-rx-filter' doc to schema
qmp-commands: move 'input-send-event' doc to schema
qmp-commands: move 'query-memdev' doc to schema
qmp-commands: move 'query-memory-devices' doc to schema
qmp-commands: move 'query-acpi-ospm-status' doc to schema
qmp-commands: move 'rtc-reset-reinjection' doc to schema
qmp-commands: move 'query-block' doc to schema
qmp-commands: move 'query-blockstats' doc to schema
qmp-commands: move 'block_passwd' doc to schema
qmp-commands: move 'block_resize' doc to schema
qmp-commands: move 'blockdev-snapshot-sync' doc to schema
qmp-commands: move 'blockdev-snapshot' doc to schema
qmp-commands: move 'change-backing-file' doc to schema
qmp-commands: move 'block-commit' doc to schema
qmp-commands: move 'drive-backup' doc to schema
qmp-commands: move 'blockdev-backup' doc to schema
qmp-commands: move 'query-named-block-nodes' doc to schema
qmp-commands: move 'drive-mirror' doc to schema
qmp-commands: move 'block-dirty-bitmap-add' doc to schema
qmp-commands: move 'block-dirty-bitmap-remove' doc to schema
qmp-commands: move 'block-dirty-bitmap-clear' doc to schema
qmp-commands: move 'block_set_io_throttle' doc to schema
qmp-commands: move 'block-stream' doc to schema
qmp-commands: move 'blockdev-add' doc to schema
qmp-commands: move 'x-blockdev-del' doc to schema
qmp-commands: move 'blockdev-open-tray' doc to schema
qmp-commands: move 'blockdev-close-tray' doc to schema
qmp-commands: move 'x-blockdev-remove-medium' doc to schema
qmp-commands: move 'x-blockdev-insert-medium' doc to schema
qmp-commands: move 'blockdev-change-medium' doc to schema
qmp-commands: move 'block-set-write-threshold' doc to schema
qmp-commands: move 'blockdev-snapshot-internal-sync' doc to schema
qmp-commands: move 'blockdev-snapshot-delete-internal-sync' doc to schema
qmp-commands: move 'eject' doc to schema
qmp-commands: move 'query-version' doc to schema
qmp-commands: move 'query-commands' doc to schema
qmp-commands: move 'add_client' doc to schema
qmp-commands: move 'query-name' doc to schema
qmp-commands: move 'query-kvm' doc to schema
qmp-commands: move 'query-status' doc to schema
qmp-commands: move 'query-uuid' doc to schema
qmp-commands: move 'query-chardev' doc to schema
qmp-commands: move 'query-chardev-backends' doc to schema
qmp-commands: move 'ringbuf-write' doc to schema
qmp-commands: move 'ringbuf-read' doc to schema
qmp-commands: move 'query-events' doc to schema
qmp-commands: move 'query-migrate' doc to schema
qmp-commands: move 'migrate-set-capabilities' doc to schema
qmp-commands: move 'query-migrate-capabilities' doc to schema
qmp-commands: move 'migrate-set-parameters' doc to schema
qmp-commands: move 'query-migrate-parameters' doc to schema
qmp-commands: move 'client_migrate_info' doc to schema
qmp-commands: move 'migrate-start-postcopy' doc to schema
qmp-commands: move 'query-mice' doc to schema
qmp-commands: move 'query-cpus' doc to schema
qmp-commands: move 'query-iothreads' doc to schema
qmp-commands: move 'query-vnc' doc to schema
qmp-commands: move 'query-spice' doc to schema
qmp-commands: move 'query-balloon' doc to schema
qmp-commands: move 'query-pci' doc to schema
qmp-commands: move 'quit' doc to schema
qmp-commands: move 'stop' doc to schema
qmp-commands: move 'system_reset' doc to schema
qmp-commands: move 'system_powerdown' doc to schema
qmp-commands: move 'cpu-add' doc to schema
qmp-commands: move 'memsave' doc to schema
Notice that "cpu" argument is actually "cpu-index" in the json.
qmp-commands: move 'pmemsave' doc to schema
qmp-commands: move 'cont' doc to schema
qmp-commands: move 'system_wakeup' doc to schema
qmp-commands: move 'inject-nmi' doc to schema
qmp-commands: move 'set_link' doc to schema
qmp-commands: move 'balloon' doc to schema
qmp-commands: move 'transaction' doc to schema
qmp-commands: move 'human-monitor-command' doc to schema
qmp-commands: move 'migrate_cancel' doc to schema
qmp-commands: move 'migrate_set_downtime' doc to schema
qmp-commands: move 'migrate_set_speed' doc to schema
qmp-commands: move 'query-migrate-cache-size' doc to schema
qmp-commands: move 'set_password' doc to schema
qmp-commands: move 'expire_password' doc to schema
qmp-commands: move 'change' doc to schema
qmp-commands: move 'migrate' doc to schema
qmp-commands: move 'migrate-incoming' doc to schema
qmp-commands: move 'xen-save-devices-state' doc to schema
qmp-commands: move 'xen-set-global-dirty-log' doc to schema
qmp-commands: move 'device_del' doc to schema
qmp-commands: move 'dump-guest-memory' doc to schema
qmp-commands: move 'query-dump-guest-memory-capability' doc to schema
qmp-commands: move 'dump-skeys' doc to schema
qmp-commands: move 'netdev_add' doc to schema
qmp-commands: move 'netdev_del' doc to schema
qmp-commands: move 'object-add' doc to schema
qmp-commands: move 'object-del' doc to schema
qmp-commands: move 'getfd' doc to schema
qmp-commands: move 'closefd' doc to schema
qmp-commands: move 'add-fd' doc to schema
qmp-commands: move 'remove-fd' doc to schema
qmp-commands: move 'query-fdsets' doc to schema
qmp-commands: move 'send-key' doc to schema
qmp-commands: move 'screendump' doc to schema
qmp-commands: move 'chardev-add' doc to schema
qmp-commands: move 'chardev-remove' doc to schema
qmp-commands: move 'query-tpm-models' doc to schema
qmp-commands: move 'query-tpm-types' doc to schema
qmp-commands: move 'query-tpm' doc to schema
qmp-commands: move 'query-command-line-options' doc to schema
qmp-commands: move 'query-rx-filter' doc to schema
qmp-commands: move 'input-send-event' doc to schema
qmp-commands: move 'query-memdev' doc to schema
qmp-commands: move 'query-memory-devices' doc to schema
qmp-commands: move 'query-acpi-ospm-status' doc to schema
qmp-commands: move 'rtc-reset-reinjection' doc to schema
qmp-commands: move 'query-block' doc to schema
qmp-commands: move 'query-blockstats' doc to schema
qmp-commands: move 'block_passwd' doc to schema
qmp-commands: move 'block_resize' doc to schema
qmp-commands: move 'blockdev-snapshot-sync' doc to schema
qmp-commands: move 'blockdev-snapshot' doc to schema
qmp-commands: move 'change-backing-file' doc to schema
qmp-commands: move 'block-commit' doc to schema
qmp-commands: move 'drive-backup' doc to schema
qmp-commands: move 'blockdev-backup' doc to schema
qmp-commands: move 'query-named-block-nodes' doc to schema
qmp-commands: move 'drive-mirror' doc to schema
qmp-commands: move 'block-dirty-bitmap-add' doc to schema
qmp-commands: move 'block-dirty-bitmap-remove' doc to schema
qmp-commands: move 'block-dirty-bitmap-clear' doc to schema
qmp-commands: move 'block_set_io_throttle' doc to schema
qmp-commands: move 'block-stream' doc to schema
qmp-commands: move 'blockdev-add' doc to schema
qmp-commands: move 'x-blockdev-del' doc to schema
qmp-commands: move 'blockdev-open-tray' doc to schema
qmp-commands: move 'blockdev-close-tray' doc to schema
qmp-commands: move 'x-blockdev-remove-medium' doc to schema
qmp-commands: move 'x-blockdev-insert-medium' doc to schema
qmp-commands: move 'blockdev-change-medium' doc to schema
qmp-commands: move 'block-set-write-threshold' doc to schema
qmp-commands: move 'blockdev-snapshot-internal-sync' doc to schema
qmp-commands: move 'blockdev-snapshot-delete-internal-sync' doc to schema
qmp-commands: move 'eject' doc to schema
qmp-commands: move 'query-version' doc to schema
qmp-commands: move 'query-commands' doc to schema
qmp-commands: move 'query-rocker' doc to schema
qmp-commands: move 'query-rocker-ports' doc to schema
qmp-commands: move 'query-rocker-of-dpa-flows' doc to schema
qmp-commands: move 'query-rocker-of-dpa-groups' doc to schema
qmp-commands: move 'trace-event-get-state' doc to schema
qmp-commands: move 'trace-event-set-state' doc to schema
qmp-commands: move 'query-hotpluggable-cpus' doc to schema
qmp-commands: move 'query-gic-capabilities' doc to schema
qmp-commands: move 'x-blockdev-change' doc to schema
qmp-commands: move 'blockdev-mirror' doc to schema
qmp-commands: move 'query-dump' doc to schema
qmp-commands: move 'migrate-set-cache-size' doc to schema
qmp-commands: move 'xen-load-devices-state' doc to schema
qmp-commands: move 'x-colo-lost-heartbeat' doc to schema
qmp-commands: remove query-qmp-schema from txt
It's better described in the schema already.
qmp-commands: remove qmp_capabilities from txt
It's better described in the schema already.
qmp-commands: remove cpu from txt
The cpu command is deprecated since commit 755f196898.
qmp-commands: remove device_add from txt
It's already fully described in the schema. Fix the schema to document the command and not the argument (place doc before first arg).
qmp-commands: move documentation bits to schema
Moving the remaining bits of documentation to the json file (text improvements is not the objective of this patch)
qmp-events: move 'BLOCK_IMAGE_CORRUPTED' doc to schema
qmp-events: move 'BLOCK_IO_ERROR' doc to schema
qmp-events: move 'BLOCK_JOB_COMPLETED' doc to schema
qmp-events: move 'BLOCK_JOB_CANCELLED' doc to schema
qmp-events: move 'BLOCK_JOB_ERROR' doc to schema
qmp-events: move 'BLOCK_JOB_READY' doc to schema
qmp-events: move 'DEVICE_TRAY_MOVED' doc to schema
qmp-events: move 'SHUTDOWN' doc to schema
qmp-events: move 'POWERDOWN' doc to schema
qmp-events: move 'RESET' doc to schema
qmp-events: move 'STOP' doc to schema
qmp-events: move 'RESUME' doc to schema
qmp-events: move 'SUSPEND' doc to schema
qmp-events: move 'SUSPEND_DISK' doc to schema
qmp-events: move 'WAKEUP' doc to schema
qmp-events: move 'RTC_CHANGE' doc to schema
qmp-events: move 'WATCHDOG' doc to schema
qmp-events: move 'DEVICE_DELETED' doc to schema
qmp-events: move 'NIC_RX_FILTER_CHANGED' doc to schema
qmp-events: move 'VNC_CONNECTED' doc to schema
qmp-events: move 'VNC_INITIALIZED' doc to schema
qmp-events: move 'VNC_DISCONNECTED' doc to schema
qmp-events: move 'SPICE_CONNECTED' doc to schema
qmp-events: move 'SPICE_INITIALIZED' doc to schema
qmp-events: move 'SPICE_DISCONNECTED' doc to schema
qmp-events: move 'SPICE_MIGRATE_COMPLETED' doc to schema
qmp-events: move 'MIGRATION' doc to schema
qmp-events: move 'ACPI_DEVICE_OST' doc to schema
qmp-events: move 'BALLOON_CHANGE' doc to schema
qmp-events: move 'GUEST_PANICKED' doc to schema
qmp-events: move 'QUORUM_FAILURE' doc to schema
qmp-events: move 'QUORUM_REPORT_BAD' doc to schema
qmp-events: move 'VSERPORT_CHANGE' doc to schema
qmp-events: move 'MEM_UNPLUG_ERROR' doc to schema
qmp-events: move 'DUMP_COMPLETED' doc to schema
qmp-events: move 'MIGRATION_PASS' doc to schema
--- Makefile | 1 - docs/qmp-commands.txt | 3824 ------------------------------------------------- docs/qmp-events.txt | 731 ---------- qapi-schema.json | 1279 ++++++++++++++++- qapi/block-core.json | 679 ++++++++- qapi/block.json | 56 +- qapi/common.json | 32 + qapi/event.json | 240 ++++ qapi/rocker.json | 57 +- qapi/trace.json | 14 + 10 files changed, 2309 insertions(+), 4604 deletions(-) delete mode 100644 docs/qmp-commands.txt delete mode 100644 docs/qmp-events.txt
Makefile +0 -1
@@ -431,7 +431,6 @@ endif install-doc: $(DOCS) $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)" $(INSTALL_DATA) qemu-doc.html "$(DESTDIR)$(qemu_docdir)" - $(INSTALL_DATA) $(SRC_PATH)/docs/qmp-commands.txt "$(DESTDIR)$(qemu_docdir)" ifdef CONFIG_POSIX $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1" $(INSTALL_DATA) qemu.1 "$(DESTDIR)$(mandir)/man1"
docs/qmp-commands.txt deleted +0 -3824
2,993 lines not on this page · raw message
docs/qmp-events.txt deleted +0 -731
731 lines not on this page · raw message
qapi-schema.json +1254 -25
1,279 lines not on this page · raw message
qapi/block-core.json +664 -15
679 lines not on this page · raw message
qapi/block.json +52 -4
56 lines not on this page · raw message
qapi/event.json +240 -0
240 lines not on this page · raw message
qapi/rocker.json +53 -4
57 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.10.0
Part of the diff is not shown here. View the raw message.
PATCH v5 16/17 docs: add qemu logo
In reply to Marc-André LureauThe pdf (needed by texi2pdf for vectorized images) was generated thanks to inkscape, from the pc-bios/qemu_logo.svg file.
--- docs/qemu-ga-ref.texi | 4 ++++ docs/qemu-qmp-ref.texi | 4 ++++ docs/qemu_logo.pdf | Bin 0 -> 9117 bytes 3 files changed, 8 insertions(+) create mode 100644 docs/qemu_logo.pdf
docs/qemu-ga-ref.texi +4 -0
@@ -6,6 +6,10 @@ @settitle QEMU Guest Agent Protocol Reference +@iftex +@center @image{docs/qemu_logo} +@end iftex + @copying This is the QEMU Guest Agent Protocol reference manual.
docs/qemu-qmp-ref.texi +4 -0
@@ -6,6 +6,10 @@ @settitle QEMU QMP Reference Manual +@iftex +@center @image{docs/qemu_logo} +@end iftex + @copying This is the QEMU QMP reference manual.
docs/qemu_logo.pdf new file binary +0 -0
Signature · 1 line
2.10.0
Re: [Qemu-devel] [PATCH v5 16/17] docs: add qemu logo
Quoted 2 lines · Marc-André Lureau
The pdf (needed by texi2pdf for vectorized images) was generated thanks to inkscape, from the pc-bios/qemu_logo.svg file.
Since we don't want to build-depend on inkscape, we need to commit the .pdf. Not that bad, as the .svg is unlikely to change. But let's explain that in the commit message. Recommend to throw in the inkscape command line.
Quoted 2 lines
Signed-off-by Marc-André Lureau <[email protected]>
I'm afraid this fails when build tree != source tree. I get
$ make pdf
GEN docs/qemu-qmp-ref.pdf
/usr/bin/texi2dvi: pdfetex exited with bad status, quitting.
Makefile:558: recipe for target 'docs/qemu-qmp-ref.pdf' failed
make: *** [docs/qemu-qmp-ref.pdf] Error 1
$ tail qemu-qmp-ref.log
@let @centersub @relax
l.12 @center @image{docs/qemu_logo} @Texinfo supports .png, .jpg, .jpeg, and .pdf images with PDF output, and none of those formats could be found. (.eps cannot be supported due to the design of
the PDF format; use regular TeX (DVI output) for that.)
!pdfTeX error: pdfetex (file docs/qemu_logo.): cannot find image file
==> Fatal error occurred, no output PDF file produced!
make dvi fails for me, too.
Quoted 27 lines
--- docs/qemu-ga-ref.texi | 4 ++++ docs/qemu-qmp-ref.texi | 4 ++++ docs/qemu_logo.pdf | Bin 0 -> 9117 bytes 3 files changed, 8 insertions(+) create mode 100644 docs/qemu_logo.pdfdocs/qemu-ga-ref.texi +4
-0@@ -6,6 +6,10 @@ @settitle QEMU Guest Agent Protocol Reference +@iftex +@center @image{docs/qemu_logo} +@end iftex + @copying This is the QEMU Guest Agent Protocol reference manual.docs/qemu-qmp-ref.texi +0
-0
docs/qemu-qmp-ref.texi line 12
Quoted 7 lines
docs/qemu-qmp-ref.texi +4
-0@@ -6,6 +6,10 @@ @settitle QEMU QMP Reference Manual +@iftex +@center @image{docs/qemu_logo} +@end iftex +
Quoting the Texinfo manual:
Here is the synopsis of the '@image' command:
@image{FILENAME[, WIDTH[, HEIGHT[, ALTTEXT[, EXTENSION]]]]} The FILENAME argument is mandatory, and must not have an extension,
because the different processors support different formats:
* TeX (DVI output) reads the file 'FILENAME.eps' (Encapsulated PostScript format).
* pdfTeX reads 'FILENAME.pdf', 'FILENAME.png', 'FILENAME.jpg', or 'FILENAME.jpeg' (in that order). It also tries uppercase versions of the extensions. The PDF format does not support EPS images, so such must be converted first.
* For Info, 'makeinfo' includes 'FILENAME.txt' verbatim (more or less as if it were in '@verbatim'). The Info output may also include a reference to 'FILENAME.png' or 'FILENAME.jpg'. (See below.)
* For HTML, 'makeinfo' outputs a reference to 'FILENAME.png', 'FILENAME.jpg', 'FILENAME.jpeg' or 'FILENAME.gif' (in that order). If none of those exist, it gives an error, and outputs a reference to 'FILENAME.jpg' anyway.
* For Docbook, 'makeinfo' outputs references to 'FILENAME.eps', 'FILENAME.gif' 'FILENAME.jpeg', 'FILENAME.jpg', 'FILENAME.pdf', 'FILENAME.png' and 'FILENAME.svg', for every file found. Also, 'FILENAME.txt' is included verbatim, if present. (The subsequent Docbook processor is supposed to choose the appropriate one.)
* For Info and HTML output, 'makeinfo' uses the optional fifth argument EXTENSION to '@image' for the filename extension, if it is specified and the file is found. Any leading period should be included in EXTENSION. For example:
@image{foo,,,,.xpm}
If you want to install image files for use by Info readers too, we
recommend putting them in a subdirectory like 'FOO-figures' for a package FOO. Copying the files into '$(infodir)/FOO-figures/' should be done in your 'Makefile'.
End quote.
You provide qemu_logo.pdf, which satisfies pdfTeX (our make target pdf) and Docbook (we don't care). Should we provide files to satisfy Info and HTML?
My version of texinfo seems to ignore the @image when it can't file any file in some cases. That's why make info and make html still work.
Quoted 7 lines
docs/qemu-qmp-ref.texi +0
-0@copying This is the QEMU QMP reference manual.docs/qemu_logo.pdf new file binary +0
-0
[...]
Re: [Qemu-devel] [PATCH v5 16/17] docs: add qemu logo
Hi
Quoted 10 lines · Markus Armbruster
Quoted 2 lines · Marc-André Lureau
The pdf (needed by texi2pdf for vectorized images) was generated thanks to inkscape, from the pc-bios/qemu_logo.svg file.
Since we don't want to build-depend on inkscape, we need to commit the .pdf. Not that bad, as the .svg is unlikely to change. But let's explain that in the commit message. Recommend to throw in the inkscape command line.
ok
Quoted 23 lines
Quoted 3 lines
Signed-off-by Marc-André Lureau <[email protected]>I'm afraid this fails when build tree != source tree. I get
$ make pdf GEN docs/qemu-qmp-ref.pdf /usr/bin/texi2dvi: pdfetex exited with bad status, quitting. Makefile:558: recipe for target 'docs/qemu-qmp-ref.pdf' failed make: *** [docs/qemu-qmp-ref.pdf] Error 1 $ tail qemu-qmp-ref.log @let @centersub @relax l.12 @center @image{docs/qemu_logo}@Texinfo supports .png, .jpg, .jpeg, and .pdf images with PDF output,
and none
of those formats could be found. (.eps cannot be supported due to the
design of
the PDF format; use regular TeX (DVI output) for that.)
Quoted 4 lines
!pdfTeX error: pdfetex (file docs/qemu_logo.): cannot find image file
==> Fatal error occurred, no output PDF file produced!
Adding -I $(SRC_PATH) solves it
make dvi fails for me, too.
Quoted 1 line
I propose we drop dvi format rules (pdf is generally better supported)
Quoted 80 lines
Quoted 28 lines
--- docs/qemu-ga-ref.texi | 4 ++++ docs/qemu-qmp-ref.texi | 4 ++++ docs/qemu_logo.pdf | Bin 0 -> 9117 bytes 3 files changed, 8 insertions(+) create mode 100644 docs/qemu_logo.pdfdocs/qemu-ga-ref.texi +4
-0@@ -6,6 +6,10 @@ @settitle QEMU Guest Agent Protocol Reference +@iftex +@center @image{docs/qemu_logo} +@end iftex + @copying This is the QEMU Guest Agent Protocol reference manual.docs/qemu-qmp-ref.texi +0
-0docs/qemu-qmp-ref.texi line 12
Quoted 7 lines
docs/qemu-qmp-ref.texi +4
-0@@ -6,6 +6,10 @@ @settitle QEMU QMP Reference Manual +@iftex +@center @image{docs/qemu_logo} +@end iftex +Quoting the Texinfo manual:
Here is the synopsis of the '@image' command:
@image{FILENAME[, WIDTH[, HEIGHT[, ALTTEXT[, EXTENSION]]]]}The FILENAME argument is mandatory, and must not have an extension,
because the different processors support different formats:* TeX (DVI output) reads the file 'FILENAME.eps' (Encapsulated PostScript format).
* pdfTeX reads 'FILENAME.pdf', 'FILENAME.png', 'FILENAME.jpg', or 'FILENAME.jpeg' (in that order). It also tries uppercase versions of the extensions. The PDF format does not support EPS images, so such must be converted first.
* For Info, 'makeinfo' includes 'FILENAME.txt' verbatim (more or less as if it were in '@verbatim'). The Info output may also include a reference to 'FILENAME.png' or 'FILENAME.jpg'. (See below.)
* For HTML, 'makeinfo' outputs a reference to 'FILENAME.png', 'FILENAME.jpg', 'FILENAME.jpeg' or 'FILENAME.gif' (in that order). If none of those exist, it gives an error, and outputs a reference to 'FILENAME.jpg' anyway.
* For Docbook, 'makeinfo' outputs references to 'FILENAME.eps', 'FILENAME.gif' 'FILENAME.jpeg', 'FILENAME.jpg', 'FILENAME.pdf', 'FILENAME.png' and 'FILENAME.svg', for every file found. Also, 'FILENAME.txt' is included verbatim, if present. (The subsequent Docbook processor is supposed to choose the appropriate one.)
* For Info and HTML output, 'makeinfo' uses the optional fifth argument EXTENSION to '@image' for the filename extension, if it is specified and the file is found. Any leading period should be included in EXTENSION. For example:
@image{foo,,,,.xpm}
If you want to install image files for use by Info readers too, we
recommend putting them in a subdirectory like 'FOO-figures' for a package FOO. Copying the files into '$(infodir)/FOO-figures/' should be done in your 'Makefile'.
Quoted 6 lines
End quote.
You provide qemu_logo.pdf, which satisfies pdfTeX (our make target pdf) and Docbook (we don't care). Should we provide files to satisfy Info and HTML?
The logo is only included @iftex.
I don't see much point in having the logo in info file.
We can add eventually add it to html, I guess it depends how the html will be published, I'd rather fix that when we improve our doc toolchain in the next release (I suppose the pdf will still be generated with texi2pdf, but the html with sphinx with Paolo texi/docbook integration)
Quoted 6 lines
My version of texinfo seems to ignore the @image when it can't file any file in some cases. That's why make info and make html still work.
Quoted 3 lines
docs/qemu-qmp-ref.texi +0
-0@copying This is the QEMU QMP reference manual.
Quoted 8 lines
Quoted 3 lines
docs/qemu_logo.pdf new file +0
-0index
0000000000000000000000000000000000000000..294cb7dec50de73c786925671300fb0abdf9d641
Quoted 1 line
GIT binary patch
[...]
--
Marc-André Lureau
Re: [Qemu-devel] [PATCH v5 16/17] docs: add qemu logo
Quoted 45 lines · Marc-André Lureau
Hi
Quoted 10 lines · Markus Armbruster
Quoted 2 lines · Marc-André Lureau
The pdf (needed by texi2pdf for vectorized images) was generated thanks to inkscape, from the pc-bios/qemu_logo.svg file.
Since we don't want to build-depend on inkscape, we need to commit the .pdf. Not that bad, as the .svg is unlikely to change. But let's explain that in the commit message. Recommend to throw in the inkscape command line.
ok
Quoted 23 lines
Quoted 3 lines
Signed-off-by Marc-André Lureau <[email protected]>I'm afraid this fails when build tree != source tree. I get
$ make pdf GEN docs/qemu-qmp-ref.pdf /usr/bin/texi2dvi: pdfetex exited with bad status, quitting. Makefile:558: recipe for target 'docs/qemu-qmp-ref.pdf' failed make: *** [docs/qemu-qmp-ref.pdf] Error 1 $ tail qemu-qmp-ref.log @let @centersub @relax l.12 @center @image{docs/qemu_logo}@Texinfo supports .png, .jpg, .jpeg, and .pdf images with PDF output,
and none
of those formats could be found. (.eps cannot be supported due to the
design of
the PDF format; use regular TeX (DVI output) for that.)Quoted 4 lines
!pdfTeX error: pdfetex (file docs/qemu_logo.): cannot find image file
==> Fatal error occurred, no output PDF file produced!
Quoted 6 lines
Adding -I $(SRC_PATH) solves it
make dvi fails for me, too.
Quoted 1 line
I propose we drop dvi format rules (pdf is generally better supported)
I figure DVI doesn't provide all that much value anymore, so dropping it could be justified if keeping it is a burden. Separate patch, of course.
Quoted 81 lines
Quoted 81 lines
Quoted 27 lines
--- docs/qemu-ga-ref.texi | 4 ++++ docs/qemu-qmp-ref.texi | 4 ++++ docs/qemu_logo.pdf | Bin 0 -> 9117 bytes 3 files changed, 8 insertions(+) create mode 100644 docs/qemu_logo.pdfdocs/qemu-ga-ref.texi +4
-0@@ -6,6 +6,10 @@ @settitle QEMU Guest Agent Protocol Reference +@iftex +@center @image{docs/qemu_logo} +@end iftex + @copying This is the QEMU Guest Agent Protocol reference manual.docs/qemu-qmp-ref.texi +0
-0docs/qemu-qmp-ref.texi line 12
Quoted 7 lines
docs/qemu-qmp-ref.texi +4
-0@@ -6,6 +6,10 @@ @settitle QEMU QMP Reference Manual +@iftex +@center @image{docs/qemu_logo} +@end iftex +Quoting the Texinfo manual:
Here is the synopsis of the '@image' command:
@image{FILENAME[, WIDTH[, HEIGHT[, ALTTEXT[, EXTENSION]]]]}The FILENAME argument is mandatory, and must not have an extension,
because the different processors support different formats:* TeX (DVI output) reads the file 'FILENAME.eps' (Encapsulated PostScript format).
* pdfTeX reads 'FILENAME.pdf', 'FILENAME.png', 'FILENAME.jpg', or 'FILENAME.jpeg' (in that order). It also tries uppercase versions of the extensions. The PDF format does not support EPS images, so such must be converted first.
* For Info, 'makeinfo' includes 'FILENAME.txt' verbatim (more or less as if it were in '@verbatim'). The Info output may also include a reference to 'FILENAME.png' or 'FILENAME.jpg'. (See below.)
* For HTML, 'makeinfo' outputs a reference to 'FILENAME.png', 'FILENAME.jpg', 'FILENAME.jpeg' or 'FILENAME.gif' (in that order). If none of those exist, it gives an error, and outputs a reference to 'FILENAME.jpg' anyway.
* For Docbook, 'makeinfo' outputs references to 'FILENAME.eps', 'FILENAME.gif' 'FILENAME.jpeg', 'FILENAME.jpg', 'FILENAME.pdf', 'FILENAME.png' and 'FILENAME.svg', for every file found. Also, 'FILENAME.txt' is included verbatim, if present. (The subsequent Docbook processor is supposed to choose the appropriate one.)
* For Info and HTML output, 'makeinfo' uses the optional fifth argument EXTENSION to '@image' for the filename extension, if it is specified and the file is found. Any leading period should be included in EXTENSION. For example:
@image{foo,,,,.xpm}
If you want to install image files for use by Info readers too, we
recommend putting them in a subdirectory like 'FOO-figures' for a package FOO. Copying the files into '$(infodir)/FOO-figures/' should be done in your 'Makefile'.End quote.
Quoted 8 lines
Quoted 4 lines
You provide qemu_logo.pdf, which satisfies pdfTeX (our make target pdf) and Docbook (we don't care). Should we provide files to satisfy Info and HTML?
The logo is only included @iftex.
I don't see much point in having the logo in info file.
Same point as for PDF: it looks pretty. At least in sufficiently capable Info readers:
In Info output, 'makeinfo' writes a reference to the binary image file
(trying FILENAME suffixed with 'EXTENSION', '.EXTENSION', '.png', or '.jpg', in that order) if one exists. It also literally includes the '.txt' file if one exists. This way, Info readers which can display images (such as the Emacs Info browser, running under X) can do so, whereas Info readers which can only use text (such as the standalone Info reader) can display the textual version.
Not implementing the logo for Info isn't a deal-breaker, of course.
Quoted 4 lines
We can add eventually add it to html, I guess it depends how the html will be published, I'd rather fix that when we improve our doc toolchain in the next release (I suppose the pdf will still be generated with texi2pdf, but the html with sphinx with Paolo texi/docbook integration)
Not a deal-breaker, either.
Limitations should be mentioned in the commit message, and perhaps in comments.
Quoted 15 lines
Quoted 6 lines
My version of texinfo seems to ignore the @image when it can't file any file in some cases. That's why make info and make html still work.
Quoted 3 lines
docs/qemu-qmp-ref.texi +0
-0@copying This is the QEMU QMP reference manual.Quoted 8 lines
Quoted 3 lines
docs/qemu_logo.pdf new file +0
-0index
0000000000000000000000000000000000000000..294cb7dec50de73c786925671300fb0abdf9d641
Quoted 1 line
GIT binary patch
[...]
--
Marc-André Lureau
PATCH v5 17/17 build-sys: add qapi doc generation targets
In reply to Marc-André LureauGenerate and install the man and html version of QAPI documentation.
Add it also to optional pdf/dvi/info targets.
Also support plain-text targets docs/qemu-ga-ref.txt & docs/qemu-qmp-ref.txt.
--- Makefile | 56 +++++++++++++++++++++++++++++++++++++++++++++++------- .gitignore | 11 ++++++++++- docs/qmp-intro.txt | 3 +-- 3 files changed, 60 insertions(+), 10 deletions(-)
Makefile +49 -7
@@ -91,6 +91,8 @@ HELPERS-$(CONFIG_LINUX) = qemu-bridge-helper$(EXESUF) ifdef BUILD_DOCS DOCS=qemu-doc.html qemu.1 qemu-img.1 qemu-nbd.8 qemu-ga.8 +DOCS+=docs/qemu-qmp-ref.html docs/qemu-qmp-ref.7 +DOCS+=docs/qemu-ga-ref.html docs/qemu-ga-ref.7 ifdef CONFIG_VIRTFS DOCS+=fsdev/virtfs-proxy-helper.1 endif
@@ -266,6 +268,7 @@ qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated gen-out-type = $(subst .,-,$(suffix $@)) qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py +qapi-py += $(SRC_PATH)/scripts/qapi2texi.py qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\ $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
@@ -395,6 +398,11 @@ distclean: clean rm -f qemu-doc.vr rm -f config.log rm -f linux-headers/asm + rm -f qemu-ga-qapi.texi qemu-qapi.texi + rm -f docs/qemu-qmp-ref.7 docs/qemu-ga-ref.7 + rm -f docs/qemu-qmp-ref.txt docs/qemu-ga-ref.txt + rm -f docs/qemu-qmp-ref.pdf docs/qemu-ga-ref.pdf + rm -f docs/qemu-qmp-ref.html docs/qemu-ga-ref.html for d in $(TARGET_DIRS); do \ rm -rf $$d || exit 1 ; \ done
@@ -431,9 +439,12 @@ endif install-doc: $(DOCS) $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)" $(INSTALL_DATA) qemu-doc.html "$(DESTDIR)$(qemu_docdir)" + $(INSTALL_DATA) docs/qemu-qmp-ref.html "$(DESTDIR)$(qemu_docdir)" ifdef CONFIG_POSIX $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1" $(INSTALL_DATA) qemu.1 "$(DESTDIR)$(mandir)/man1" + $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7" + $(INSTALL_DATA) docs/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7" ifneq ($(TOOLS),) $(INSTALL_DATA) qemu-img.1 "$(DESTDIR)$(mandir)/man1" $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
@@ -441,6 +452,8 @@ ifneq ($(TOOLS),) endif ifneq (,$(findstring qemu-ga,$(TOOLS))) $(INSTALL_DATA) qemu-ga.8 "$(DESTDIR)$(mandir)/man8" + $(INSTALL_DATA) docs/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)" + $(INSTALL_DATA) docs/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7" endif endif ifdef CONFIG_VIRTFS
@@ -528,9 +541,9 @@ ui/console-gl.o: $(SRC_PATH)/ui/console-gl.c \ ui/shader/texture-blit-vert.h ui/shader/texture-blit-frag.h # documentation -MAKEINFO=makeinfo +MAKEINFO=makeinfo -D 'VERSION $(VERSION)' MAKEINFOFLAGS=--no-headers --no-split --number-sections -TEXIFLAG=$(if $(V),,--quiet) +TEXIFLAG=$(if $(V),,--quiet) --command='@set VERSION $(VERSION)' %.dvi: %.texi $(call quiet-command,texi2dvi $(TEXIFLAG) -I . $<,"GEN","$@")
@@ -542,7 +555,11 @@ TEXIFLAG=$(if $(V),,--quiet) $(call quiet-command,$(MAKEINFO) $< -o $@,"GEN","$@") %.pdf: %.texi - $(call quiet-command,texi2pdf $(TEXIFLAG) -I . $<,"GEN","$@") + $(call quiet-command,texi2pdf $(TEXIFLAG) -I . $< -o $@,"GEN","$@") + +%.txt: %.texi + $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --plaintext $< -o $@,\ + " GEN $@") qemu-options.texi: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
@@ -556,6 +573,12 @@ qemu-monitor-info.texi: $(SRC_PATH)/hmp-commands-info.hx $(SRC_PATH)/scripts/hxt qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@") +qemu-qapi.texi: $(qapi-modules) $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py $< > $@,"GEN" "$@") + +qemu-ga-qapi.texi: $(SRC_PATH)/qga/qapi-schema.json $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py $< > $@,"GEN","$@") + qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi qemu-monitor-info.texi $(call quiet-command, \ perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu.pod && \
@@ -587,16 +610,35 @@ qemu-ga.8: qemu-ga.texi $(POD2MAN) --section=8 --center=" " --release=" " qemu-ga.pod > $@, \ "GEN","$@") -dvi: qemu-doc.dvi -html: qemu-doc.html -info: qemu-doc.info -pdf: qemu-doc.pdf +docs/qemu-qmp-ref.7: + $(call quiet-command, \ + perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-qmp-ref.pod && \ + $(POD2MAN) --section=7 --center=" " --release=" " qemu-qmp-ref.pod > $@, \ + "GEN","$@") + +docs/qemu-ga-ref.7: + $(call quiet-command, \ + perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-ga-ref.pod && \ + $(POD2MAN) --section=7 --center=" " --release=" " qemu-ga-ref.pod > $@, \ + "GEN","$@") + +dvi: qemu-doc.dvi docs/qemu-qmp-ref.dvi docs/qemu-ga-ref.dvi +html: qemu-doc.html docs/qemu-qmp-ref.html docs/qemu-ga-ref.html +info: qemu-doc.info docs/qemu-qmp-ref.info docs/qemu-ga-ref.info +pdf: qemu-doc.pdf docs/qemu-qmp-ref.pdf docs/qemu-ga-ref.pdf qemu-doc.dvi qemu-doc.html qemu-doc.info qemu-doc.pdf: \ qemu-img.texi qemu-nbd.texi qemu-options.texi qemu-option-trace.texi \ qemu-monitor.texi qemu-img-cmds.texi qemu-ga.texi \ qemu-monitor-info.texi +docs/qemu-ga-ref.dvi docs/qemu-ga-ref.html docs/qemu-ga-ref.info docs/qemu-ga-ref.pdf docs/qemu-ga-ref.txt docs/qemu-ga-ref.7: \ +docs/qemu-ga-ref.texi qemu-ga-qapi.texi + +docs/qemu-qmp-ref.dvi docs/qemu-qmp-ref.html docs/qemu-qmp-ref.info docs/qemu-qmp-ref.pdf docs/qemu-qmp-ref.txt docs/qemu-qmp-ref.7: \ +docs/qemu-qmp-ref.texi qemu-qapi.texi + + ifdef CONFIG_WIN32 INSTALLER = qemu-setup-$(VERSION)$(EXESUF)
.gitignore +10 -1
@@ -39,7 +39,7 @@ /qmp-introspect.[ch] /qmp-marshal.c /qemu-doc.html -/qemu-doc.info +/qemu-doc.info* /qemu-img /qemu-nbd /qemu-options.def
@@ -109,6 +109,15 @@ /pc-bios/optionrom/kvmvapic.img /pc-bios/s390-ccw/s390-ccw.elf /pc-bios/s390-ccw/s390-ccw.img +/docs/qemu-ga-ref.html +/docs/qemu-ga-ref.txt +/docs/qemu-qmp-ref.html +/docs/qemu-qmp-ref.txt +docs/qemu-ga-ref.info* +docs/qemu-qmp-ref.info* +/qemu-ga-qapi.texi +/qemu-qapi.texi +*.tps .stgit-* cscope.* tags
docs/qmp-intro.txt +1 -2
@@ -16,8 +16,7 @@ QMP is JSON[1] based and features the following: For detailed information on QMP's usage, please, refer to the following files: o qmp-spec.txt QEMU Machine Protocol current specification -o qmp-commands.txt QMP supported commands (auto-generated at build-time) -o qmp-events.txt List of available asynchronous events +o qemu-qmp-ref.html QEMU QMP commands and events (auto-generated at build-time) [1] http://www.json.org
Signature · 1 line
2.10.0
Re: [Qemu-devel] [PATCH v5 17/17] build-sys: add qapi doc generation targets
Quoted 35 lines · Marc-André Lureau
Generate and install the man and html version of QAPI documentation.
Add it also to optional pdf/dvi/info targets.
Also support plain-text targets
docs/qemu-ga-ref.txt&docs/qemu-qmp-ref.txt.Signed-off-by Marc-André Lureau <[email protected]>--- Makefile | 56 +++++++++++++++++++++++++++++++++++++++++++++++------- .gitignore | 11 ++++++++++- docs/qmp-intro.txt | 3 +-- 3 files changed, 60 insertions(+), 10 deletions(-)Makefile +3
-0@@ -91,6 +91,8 @@ HELPERS-$(CONFIG_LINUX) = qemu-bridge-helper$(EXESUF) ifdef BUILD_DOCS DOCS=qemu-doc.html qemu.1 qemu-img.1 qemu-nbd.8 qemu-ga.8 +DOCS+=docs/qemu-qmp-ref.html docs/qemu-qmp-ref.7 +DOCS+=docs/qemu-ga-ref.html docs/qemu-ga-ref.7 ifdef CONFIG_VIRTFS DOCS+=fsdev/virtfs-proxy-helper.1 endif@@ -266,6 +268,7 @@ qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated gen-out-type = $(subst .,-,$(suffix $@)) qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py +qapi-py += $(SRC_PATH)/scripts/qapi2texi.py qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\ $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
Makefile distclean: clean · line 405
Quoted 8 lines
Makefile +5
-0@@ -395,6 +398,11 @@ distclean: clean rm -f qemu-doc.vr rm -f config.log rm -f linux-headers/asm + rm -f qemu-ga-qapi.texi qemu-qapi.texi + rm -f docs/qemu-qmp-ref.7 docs/qemu-ga-ref.7 + rm -f docs/qemu-qmp-ref.txt docs/qemu-ga-ref.txt + rm -f docs/qemu-qmp-ref.pdf docs/qemu-ga-ref.pdf + rm -f docs/qemu-qmp-ref.html docs/qemu-ga-ref.html
Missing: .dvi
Makefile endif · line 442
Quoted 8 lines
Makefile +1
-0for d in $(TARGET_DIRS); do \ rm -rf $$d || exit 1 ; \ done@@ -431,9 +439,12 @@ endif install-doc: $(DOCS) $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)" $(INSTALL_DATA) qemu-doc.html "$(DESTDIR)$(qemu_docdir)" + $(INSTALL_DATA) docs/qemu-qmp-ref.html "$(DESTDIR)$(qemu_docdir)"
Personally, I'd install .txt along with .html, because the .txt is perfectly legible, and plain text is easier to read in some situations. We don't do that for qemu-doc, though.
Quoted 19 lines
Makefile +4
-0ifdef CONFIG_POSIX $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1" $(INSTALL_DATA) qemu.1 "$(DESTDIR)$(mandir)/man1" + $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7" + $(INSTALL_DATA) docs/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7" ifneq ($(TOOLS),) $(INSTALL_DATA) qemu-img.1 "$(DESTDIR)$(mandir)/man1" $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"@@ -441,6 +452,8 @@ ifneq ($(TOOLS),) endif ifneq (,$(findstring qemu-ga,$(TOOLS))) $(INSTALL_DATA) qemu-ga.8 "$(DESTDIR)$(mandir)/man8" + $(INSTALL_DATA) docs/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)" + $(INSTALL_DATA) docs/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7" endif endif ifdef CONFIG_VIRTFS@@ -528,9 +541,9 @@ ui/console-gl.o: $(SRC_PATH)/ui/console-gl.c \ ui/shader/texture-blit-vert.h ui/shader/texture-blit-frag.h
Makefile ui/console-gl.o: $(SRC_PATH)/ui/console-gl.c \ · line 549
Quoted 10 lines
Makefile +2
-2# documentation -MAKEINFO=makeinfo +MAKEINFO=makeinfo -D 'VERSION $(VERSION)' MAKEINFOFLAGS=--no-headers --no-split --number-sections -TEXIFLAG=$(if $(V),,--quiet) +TEXIFLAG=$(if $(V),,--quiet) --command='@set VERSION $(VERSION)' %.dvi: %.texi $(call quiet-command,texi2dvi $(TEXIFLAG) -I . $<,"GEN","$@")
Defines variable VERSION for all .texi, not just qemu-*-ref.texi, for simplicity. Works for me.
Makefile TEXIFLAG=$(if $(V),,--quiet) · line 558
Quoted 6 lines
Makefile +1
-1@@ -542,7 +555,11 @@ TEXIFLAG=$(if $(V),,--quiet) $(call quiet-command,$(MAKEINFO) $< -o $@,"GEN","$@") %.pdf: %.texi - $(call quiet-command,texi2pdf $(TEXIFLAG) -I . $<,"GEN","$@") + $(call quiet-command,texi2pdf $(TEXIFLAG) -I . $< -o $@,"GEN","$@")
I guess this simply makes the default implicit. Okay.
Makefile TEXIFLAG=$(if $(V),,--quiet) · line 562
Quoted 4 lines
Makefile +4
-0+ +%.txt: %.texi + $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --plaintext $< -o $@,\ + " GEN $@")
$ make docs/qemu-qmp-ref.txt
GEN docs/qemu-qmp-ref.txt
Negative repeat count does nothing at /usr/share/texinfo/Texinfo/Convert/Line.pm line 128.
Negative repeat count does nothing at /usr/share/texinfo/Texinfo/Convert/Line.pm line 128.
Negative repeat count does nothing at /usr/share/texinfo/Texinfo/Convert/Line.pm line 128.Could be something wrong with my system. The result looks okay to me all the same.
Quoted 25 lines
Makefile +7
-4qemu-options.texi: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")@@ -556,6 +573,12 @@ qemu-monitor-info.texi: $(SRC_PATH)/hmp-commands-info.hx $(SRC_PATH)/scripts/hxt qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@") +qemu-qapi.texi: $(qapi-modules) $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py $< > $@,"GEN" "$@") + +qemu-ga-qapi.texi: $(SRC_PATH)/qga/qapi-schema.json $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py $< > $@,"GEN","$@") + qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi qemu-monitor-info.texi $(call quiet-command, \ perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu.pod && \@@ -587,16 +610,35 @@ qemu-ga.8: qemu-ga.texi $(POD2MAN) --section=8 --center=" " --release=" " qemu-ga.pod > $@, \ "GEN","$@") -dvi: qemu-doc.dvi -html: qemu-doc.html -info: qemu-doc.info -pdf: qemu-doc.pdf +docs/qemu-qmp-ref.7:
Makefile qemu-ga.8: qemu-ga.texi · line 623
Quoted 10 lines
Makefile +10
-0+ $(call quiet-command, \ + perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-qmp-ref.pod && \ + $(POD2MAN) --section=7 --center=" " --release=" " qemu-qmp-ref.pod > $@, \ + "GEN","$@") + +docs/qemu-ga-ref.7: + $(call quiet-command, \ + perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-ga-ref.pod && \ + $(POD2MAN) --section=7 --center=" " --release=" " qemu-ga-ref.pod > $@, \ + "GEN","$@")
Recipe duplicated. Would the following work?
docs/qemu-qmp-ref.7 docs/qemu-ga-ref.7: $(call quiet-command, \ perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< $(@:.7=.pod) && \ $(POD2MAN) --section=7 --center=" " --release=" " $(@:.7=.pod) > $@, \ "GEN","$@")
Hmm, the recipe is duplicated many times over elsewhere already. Nevermind, unless you genuinely want to clean that up.
Makefile qemu-ga.8: qemu-ga.texi · line 628
Quoted 5 lines
Makefile +5
-0+ +dvi: qemu-doc.dvi docs/qemu-qmp-ref.dvi docs/qemu-ga-ref.dvi +html: qemu-doc.html docs/qemu-qmp-ref.html docs/qemu-ga-ref.html +info: qemu-doc.info docs/qemu-qmp-ref.info docs/qemu-ga-ref.info +pdf: qemu-doc.pdf docs/qemu-qmp-ref.pdf docs/qemu-ga-ref.pdf
Would a txt target make sense?
Quoted 21 lines
Makefile +7
-0qemu-doc.dvi qemu-doc.html qemu-doc.info qemu-doc.pdf: \ qemu-img.texi qemu-nbd.texi qemu-options.texi qemu-option-trace.texi \ qemu-monitor.texi qemu-img-cmds.texi qemu-ga.texi \ qemu-monitor-info.texi +docs/qemu-ga-ref.dvi docs/qemu-ga-ref.html docs/qemu-ga-ref.info docs/qemu-ga-ref.pdf docs/qemu-ga-ref.txt docs/qemu-ga-ref.7: \ +docs/qemu-ga-ref.texi qemu-ga-qapi.texi + +docs/qemu-qmp-ref.dvi docs/qemu-qmp-ref.html docs/qemu-qmp-ref.info docs/qemu-qmp-ref.pdf docs/qemu-qmp-ref.txt docs/qemu-qmp-ref.7: \ +docs/qemu-qmp-ref.texi qemu-qapi.texi + + ifdef CONFIG_WIN32 INSTALLER = qemu-setup-$(VERSION)$(EXESUF).gitignore +0
-0
.gitignore line 42
Quoted 5 lines
.gitignore +1
-1@@ -39,7 +39,7 @@ /qmp-introspect.[ch] /qmp-marshal.c /qemu-doc.html -/qemu-doc.info +/qemu-doc.info*
I guess this is to cover the .info-1, .info-2, ... makeinfo produces when it splits the output. Separate patch, please.
Perhaps we should consider passing --no-split to makeinfo instead. The split I get seems rather pointless: .info-2 has a few indexes, all but one empty, and .info-1 has all the rest, including some indexes.
Quoted 32 lines
.gitignore +9
-0/qemu-img /qemu-nbd /qemu-options.def@@ -109,6 +109,15 @@ /pc-bios/optionrom/kvmvapic.img /pc-bios/s390-ccw/s390-ccw.elf /pc-bios/s390-ccw/s390-ccw.img +/docs/qemu-ga-ref.html +/docs/qemu-ga-ref.txt +/docs/qemu-qmp-ref.html +/docs/qemu-qmp-ref.txt +docs/qemu-ga-ref.info* +docs/qemu-qmp-ref.info* +/qemu-ga-qapi.texi +/qemu-qapi.texi +*.tps .stgit-* cscope.* tagsdocs/qmp-intro.txt +1
-2@@ -16,8 +16,7 @@ QMP is JSON[1] based and features the following: For detailed information on QMP's usage, please, refer to the following files: o qmp-spec.txt QEMU Machine Protocol current specification -o qmp-commands.txt QMP supported commands (auto-generated at build-time) -o qmp-events.txt List of available asynchronous events +o qemu-qmp-ref.html QEMU QMP commands and events (auto-generated at build-time) [1] http://www.json.org
Re: [Qemu-devel] [PATCH v5 17/17] build-sys: add qapi doc generation targets
Hi
Quoted 41 lines · Markus Armbruster
Quoted 5 lines · Marc-André Lureau
Generate and install the man and html version of QAPI documentation.
Add it also to optional pdf/dvi/info targets.
Also support plain-text targets
docs/qemu-ga-ref.txt&
docs/qemu-qmp-ref.txt.Quoted 4 lines
Signed-off-by Marc-André Lureau <[email protected]>--- Makefile | 56+++++++++++++++++++++++++++++++++++++++++++++++-------
Makefile qemu-ga$(EXESUF): QEMU_CFLAGS += -I
Quoted 18 lines
.gitignore | 11 ++++++++++- docs/qmp-intro.txt | 3 +-- 3 files changed, 60 insertions(+), 10 deletions(-)Makefile +2
-0@@ -91,6 +91,8 @@ HELPERS-$(CONFIG_LINUX) = qemu-bridge-helper$(EXESUF) ifdef BUILD_DOCS DOCS=qemu-doc.html qemu.1 qemu-img.1 qemu-nbd.8 qemu-ga.8 +DOCS+=docs/qemu-qmp-ref.html docs/qemu-qmp-ref.7 +DOCS+=docs/qemu-ga-ref.html docs/qemu-ga-ref.7 ifdef CONFIG_VIRTFS DOCS+=fsdev/virtfs-proxy-helper.1 endif@@ -266,6 +268,7 @@ qemu-ga$(EXESUF): QEMU_CFLAGS += -Iqga/qapi-generated
Makefile qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
Quoted 6 lines
Makefile +1
-0gen-out-type = $(subst .,-,$(suffix $@)) qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py +qapi-py += $(SRC_PATH)/scripts/qapi2texi.py qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h:\
Makefile qemu-ga$(EXESUF): QEMU_CFLAGS += -I · line 274
Quoted 1 line
Makefile +0
-0$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py$(qapi-py)
Quoted 12 lines
Makefile distclean: clean · line 405
Quoted 9 lines
Makefile +5
-0@@ -395,6 +398,11 @@ distclean: clean rm -f qemu-doc.vr rm -f config.log rm -f linux-headers/asm + rm -f qemu-ga-qapi.texi qemu-qapi.texi + rm -f docs/qemu-qmp-ref.7 docs/qemu-ga-ref.7 + rm -f docs/qemu-qmp-ref.txt docs/qemu-ga-ref.txt + rm -f docs/qemu-qmp-ref.pdf docs/qemu-ga-ref.pdf + rm -f docs/qemu-qmp-ref.html docs/qemu-ga-ref.htmlMissing: .dvi
I dropped it in a previous patch in the new series
Quoted 14 lines
Makefile endif · line 442
Quoted 9 lines
Makefile +1
-0for d in $(TARGET_DIRS); do \ rm -rf $$d || exit 1 ; \ done@@ -431,9 +439,12 @@ endif install-doc: $(DOCS) $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)" $(INSTALL_DATA) qemu-doc.html "$(DESTDIR)$(qemu_docdir)" + $(INSTALL_DATA) docs/qemu-qmp-ref.html "$(DESTDIR)$(qemu_docdir)"Personally, I'd install .txt along with .html, because the .txt is perfectly legible, and plain text is easier to read in some situations. We don't do that for qemu-doc, though.
Ok, let's install them all
Quoted 58 lines
Quoted 20 lines
Makefile +4
-0ifdef CONFIG_POSIX $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1" $(INSTALL_DATA) qemu.1 "$(DESTDIR)$(mandir)/man1" + $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7" + $(INSTALL_DATA) docs/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7" ifneq ($(TOOLS),) $(INSTALL_DATA) qemu-img.1 "$(DESTDIR)$(mandir)/man1" $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"@@ -441,6 +452,8 @@ ifneq ($(TOOLS),) endif ifneq (,$(findstring qemu-ga,$(TOOLS))) $(INSTALL_DATA) qemu-ga.8 "$(DESTDIR)$(mandir)/man8" + $(INSTALL_DATA) docs/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)" + $(INSTALL_DATA) docs/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7" endif endif ifdef CONFIG_VIRTFS@@ -528,9 +541,9 @@ ui/console-gl.o: $(SRC_PATH)/ui/console-gl.c \ ui/shader/texture-blit-vert.h ui/shader/texture-blit-frag.hMakefile ui/console-gl.o: $(SRC_PATH)/ui/console-gl.c \ · line 549
Quoted 10 lines
Makefile +2
-2# documentation -MAKEINFO=makeinfo +MAKEINFO=makeinfo -D 'VERSION $(VERSION)' MAKEINFOFLAGS=--no-headers --no-split --number-sections -TEXIFLAG=$(if $(V),,--quiet) +TEXIFLAG=$(if $(V),,--quiet) --command='@set VERSION $(VERSION)' %.dvi: %.texi $(call quiet-command,texi2dvi $(TEXIFLAG) -I . $<,"GEN","$@")Defines variable VERSION for all .texi, not just qemu-*-ref.texi, for simplicity. Works for me.
Makefile TEXIFLAG=$(if $(V),,--quiet) · line 558
Quoted 6 lines
Makefile +1
-1@@ -542,7 +555,11 @@ TEXIFLAG=$(if $(V),,--quiet) $(call quiet-command,$(MAKEINFO) $< -o $@,"GEN","$@") %.pdf: %.texi - $(call quiet-command,texi2pdf $(TEXIFLAG) -I . $<,"GEN","$@") + $(call quiet-command,texi2pdf $(TEXIFLAG) -I . $< -o $@,"GEN","$@")I guess this simply makes the default implicit. Okay.
Makefile TEXIFLAG=$(if $(V),,--quiet)
Quoted 3 lines
Makefile +3
-0+ +%.txt: %.texi + $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS)--plaintext $< -o $@,\
Makefile TEXIFLAG=$(if $(V),,--quiet) · line 562
Quoted 1 line
Makefile +1
-0+ " GEN $@")$ make docs/qemu-qmp-ref.txt GEN docs/qemu-qmp-ref.txt Negative repeat count does nothing at /usr/share/texinfo/Texinfo/Convert/Line.pm line 128. Negative repeat count does nothing at /usr/share/texinfo/Texinfo/Convert/Line.pm line 128. Negative repeat count does nothing at /usr/share/texinfo/Texinfo/Convert/Line.pm line 128.
Quoted 3 lines
Could be something wrong with my system. The result looks okay to me all the same.
I have the same warning, seems to be harmless though...
Quoted 59 lines
Makefile TEXIFLAG=$(if $(V),,--quiet) · line 563
Quoted 3 lines
Makefile +0
-0qemu-options.texi: $(SRC_PATH)/qemu-options.hx$(SRC_PATH)/scripts/hxtool
Makefile TEXIFLAG=$(if $(V),,--quiet) · line 564
Quoted 1 line
Makefile +0
-0$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< >$@,"GEN","$@")
Makefile qemu-monitor-info.texi:
Quoted 1 line
Makefile +0
-0@@ -556,6 +573,12 @@ qemu-monitor-info.texi:$(SRC_PATH)/hmp-commands-info.hx $(SRC_PATH)/scripts/hxt
Makefile qemu-monitor-info.texi: · line 573
Quoted 1 line
Makefile +0
-0qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx$(SRC_PATH)/scripts/hxtool
Makefile qemu-monitor-info.texi: · line 574
Quoted 1 line
Makefile +0
-0$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< >$@,"GEN","$@")
Makefile qemu-monitor-info.texi: · line 583
Quoted 10 lines
Makefile +6
-0+qemu-qapi.texi: $(qapi-modules) $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py $< $@,"GEN" "$@") + +qemu-ga-qapi.texi: $(SRC_PATH)/qga/qapi-schema.json $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py $< $@,"GEN","$@") + qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texiqemu-monitor-info.texi
Makefile qemu-ga.8: qemu-ga.texi · line 610
Quoted 4 lines
Makefile +0
-0$(call quiet-command, \perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu.pod && \Makefile +0
-0@@ -587,16 +610,35 @@ qemu-ga.8: qemu-ga.texi $(POD2MAN) --section=8 --center=" " --release=" " qemu-ga.pod >$@, \
Makefile qemu-ga.8: qemu-ga.texi
Quoted 9 lines
Makefile +3
-4"GEN","$@") -dvi: qemu-doc.dvi -html: qemu-doc.html -info: qemu-doc.info -pdf: qemu-doc.pdf +docs/qemu-qmp-ref.7: + $(call quiet-command, \ + perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-qmp-ref.pod&& \
Makefile qemu-ga.8: qemu-ga.texi · line 616
Quoted 1 line
Makefile +1
-0+ $(POD2MAN) --section=7 --center=" " --release=" "qemu-qmp-ref.pod > $@, \
Makefile qemu-ga.8: qemu-ga.texi
Quoted 5 lines
Makefile +5
-0+ "GEN","$@") + +docs/qemu-ga-ref.7: + $(call quiet-command, \ + perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-ga-ref.pod&& \
Makefile qemu-ga.8: qemu-ga.texi · line 624
Quoted 3 lines
Makefile +2
-0+ $(POD2MAN) --section=7 --center=" " --release=" " qemu-ga-ref.pod $@, \ + "GEN","$@")Recipe duplicated. Would the following work?
docs/qemu-qmp-ref.7 docs/qemu-ga-ref.7: $(call quiet-command, \ perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< $(@:.7=.pod) && \ $(POD2MAN) --section=7 --center=" " --release=" " $(@:.7=.pod) > $@, \ "GEN","$@")
Quoted 3 lines
Hmm, the recipe is duplicated many times over elsewhere already. Nevermind, unless you genuinely want to clean that up.
Fixed it in the new series
Quoted 9 lines
Makefile qemu-ga.8: qemu-ga.texi · line 628
Quoted 6 lines
Makefile +5
-0+ +dvi: qemu-doc.dvi docs/qemu-qmp-ref.dvi docs/qemu-ga-ref.dvi +html: qemu-doc.html docs/qemu-qmp-ref.html docs/qemu-ga-ref.html +info: qemu-doc.info docs/qemu-qmp-ref.info docs/qemu-ga-ref.info +pdf: qemu-doc.pdf docs/qemu-qmp-ref.pdf docs/qemu-ga-ref.pdfWould a txt target make sense?
added
Quoted 73 lines
Makefile qemu-ga.8: qemu-ga.texi · line 631
Quoted 4 lines
Makefile +0
-0qemu-doc.dvi qemu-doc.html qemu-doc.info qemu-doc.pdf: \ qemu-img.texi qemu-nbd.texi qemu-options.texiqemu-option-trace.texi \
Makefile qemu-ga.8: qemu-ga.texi
Quoted 4 lines
Makefile +1
-0qemu-monitor.texi qemu-img-cmds.texi qemu-ga.texi \ qemu-monitor-info.texi +docs/qemu-ga-ref.dvi docs/qemu-ga-ref.html docs/qemu-ga-ref.infodocs/qemu-ga-ref.pdf
docs/qemu-ga-ref.txtdocs/qemu-ga-ref.7: \Makefile qemu-ga.8: qemu-ga.texi
Quoted 3 lines
Makefile +3
-0+docs/qemu-ga-ref.texi qemu-ga-qapi.texi + +docs/qemu-qmp-ref.dvi docs/qemu-qmp-ref.html docs/qemu-qmp-ref.infodocs/qemu-qmp-ref.pdf
docs/qemu-qmp-ref.txtdocs/qemu-qmp-ref.7: \Quoted 11 lines
Makefile +3
-0+docs/qemu-qmp-ref.texi qemu-qapi.texi + + ifdef CONFIG_WIN32 INSTALLER = qemu-setup-$(VERSION)$(EXESUF).gitignore +0
-0.gitignore line 42
Quoted 5 lines
.gitignore +1
-1@@ -39,7 +39,7 @@ /qmp-introspect.[ch] /qmp-marshal.c /qemu-doc.html -/qemu-doc.info +/qemu-doc.info*I guess this is to cover the .info-1, .info-2, ... makeinfo produces when it splits the output. Separate patch, please.
ok
Perhaps we should consider passing --no-split to makeinfo instead. The split I get seems rather pointless: .info-2 has a few indexes, all but one empty, and .info-1 has all the rest, including some indexes.
done
Quoted 24 lines
.gitignore +9
-0/qemu-img /qemu-nbd /qemu-options.def@@ -109,6 +109,15 @@ /pc-bios/optionrom/kvmvapic.img /pc-bios/s390-ccw/s390-ccw.elf /pc-bios/s390-ccw/s390-ccw.img +/docs/qemu-ga-ref.html +/docs/qemu-ga-ref.txt +/docs/qemu-qmp-ref.html +/docs/qemu-qmp-ref.txt +docs/qemu-ga-ref.info* +docs/qemu-qmp-ref.info* +/qemu-ga-qapi.texi +/qemu-qapi.texi +*.tps .stgit-* cscope.* tagsdocs/qmp-intro.txt +0
-0docs/qmp-intro.txt QMP is JSON[1] based and features the following: · line 16
Quoted 1 line
docs/qmp-intro.txt +0
-0@@ -16,8 +16,7 @@ QMP is JSON[1] based and features the following: For detailed information on QMP's usage, please, refer to the followingfiles:
docs/qmp-intro.txt QMP is JSON[1] based and features the following: · line 18
Quoted 3 lines
docs/qmp-intro.txt +0
-1o qmp-spec.txt QEMU Machine Protocol current specification -o qmp-commands.txt QMP supported commands (auto-generated at
Quoted 8 lines
build-time)
docs/qmp-intro.txt QMP is JSON[1] based and features the following: · line 18
Quoted 2 lines
docs/qmp-intro.txt +1
-1-o qmp-events.txt List of available asynchronous events +o qemu-qmp-ref.html QEMU QMP commands and events (auto-generated atbuild-time)
docs/qmp-intro.txt QMP is JSON[1] based and features the following: · line 21
Quoted 2 lines
docs/qmp-intro.txt +0
-0[1] http://www.json.org--
Marc-André Lureau
Quoted 10 lines · Marc-André Lureau
Add a qapi2texi script to generate the documentation from the qapi schemas.
The 15th patch in this series is a squashed version of the documentation move from qmp-commands.txt to the schemas. The whole version (not sent on the ML to avoid spamming) is in the following git
branch: https://github.com/elmarco/qemu/commits/qapi-docPDF preview:
https://fedorapeople.org/~elmarco/qemu-qmp-ref.pdf
PATCH 2,4-8 applied to qapi-next for 2.8.
PATCH 1,10 are ready, but I'm punting them to 2.9 because they affect generated code. Probably overcautious.