Skip to contentSkip to conversation

Convert QAPI doc comments to generate rST instead of texinfo

PATCH Superseded Peter Maydell 3 participants 44 messages Mar 9, 2020 – Aug 6, 2020

Subsystems (2)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover Convert QAPI doc comments to generate rST instead of texinfo

This series switches all our QAPI doc comments over from texinfo format to rST. It then removes all the texinfo machinery, because this was the last user of texinfo.

I would ideally like to get this into the release, though the softfreeze date is now approaching rapidly...

Based-on: [email protected] ("post-rst-conversion cleanups") though any conflicts vs master should be trivial.

Changes v3->v4:
* rebased now that the conversion of qemu-doc
to rST has gone in
* new patch 1 which cleans up the indent on a change to migration.json since v3
* added 5 new patches at the end of the series which do the "remove the texinfo machinery" part (makes the diffstat for the series look good ;-))

Below here is the same as the v3 cover letter:

Changes v2->v3:
* all the "preliminary tidy up of existing doc comment" patches are now in master -- thanks!
* rebased on current master (there were some minor conflicts with the just-committed creation of the tools manual)
Changes v1->v2:
* rebased (a few minor conflicts fixed)
* I have fixed the failures to pass "make check"
* minor tweaks to commit messages etc (noted in individual patches)
* the old patch 12 ('qapi: Explicitly put "foo: dropped in n.n" notes into Notes section') has been deleted
* patch 18 ('qapi: Delete all the "foo: dropped in n.n" notes')
* I have not made the change to be more consistent about treating an apparent heading-comment with trailing lines of rST the same way as we would treat one with leading lines of rST, just because the whole area of how we handle headings is up in the air anyway. If we decide the approach here is basically right I'll make this change in a v3; otherwise it's likely to be moot anyway.
* I have also not added a patch that rewraps long lines added by some of the earlier doc-comment adjustments; I figure we can come back and do that later.
* I haven't (yet) written an extra patch that tries to guess what might be a good sphinx-build binary to use (none of my systems put it anywhere except 'sphinx-build')

The basic approach is somewhat similar to how we deal with kerneldoc and hxtool: we have a custom Sphinx extension which is passed a filename which is the json file it should run the QAPI parser over and generate documentation for. Unlike 'kerneldoc' but somewhat like hxtool, I have chosed to generate documentation by generating a tree of docutils nodes, rather than by generating rST source that is then fed to the rST parser to generate docutils nodes. Individual lumps of doc comment go to the rST parser, but the structured parts we render directly. This makes it easier to get the structure and heading level nesting correct.

Rather than trying to exactly handle all the existing comments I have opted (as Markus suggested) to tweak them where this seemed more sensible than contorting the rST generator to deal with weirdnesses. The principal changes are:
* whitespace is now significant, and multiline definitions must have their second and subsequent lines indented to match the first line
* general rST format markup is permitted, not just the small set of markup the old texinfo generator handled. For most things (notably bulleted and itemized lists) the old format is the same as rST was.
* Specific things that might trip people up:
- instead of *bold* and _italic_ rST has **bold** and *italic*
- lists need a preceding and following blank line
- a lone literal '*' will need to be backslash-escaped to avoid a rST syntax error
* the old leading '|' for example (literal text) blocks is replaced by the standard rST '::' literal block.
* headings and subheadings must now be in a freeform documentation comment of their own
* we support arbitrary levels of sub- and sub-sub-heading, not just a main and sub-heading like the old texinfo generator
* as a special case, @foo is retained and is equivalent to ``foo``
Moving on to the actual code changes:
* we start by changing the existing parser code to be more careful with leading whitespace: instead of stripping it all, it strips only the amount required for indented multiline definitions, and complains if it finds an unexpected de-indent. The texinfo generator code is updated to do whitespace stripping itself, so there is no change to the generated texi source.
* then we add the new qapidoc Sphinx extension, which is not yet used by anything. This is a 500 line script, all added in one patch. I can split it if people think that would help, but I'm not sure I see a good split point.
* then we can convert the two generated reference documents, one at a time. This is mostly just updating makefile rules and the like.
* after that we can do some minor tweaks to doc comments that would have confused the texinfo parser: changing our two instances of '|'-markup literal blocks to rST '::' literal blocks, and adding some headings to the GA reference so the rST interop manual ToC looks better.
* finally, we can delete the old texinfo machinery and update the markup docs in docs/devel/qapi-code-gen.txt

On headings:
Because the rST generator works by assembling a tree of docutils nodes, it needs to know the structure of the document, in the sense that it wants to know that there is a "section with a level 1 heading titled Foo", which contains "section with a level 2 heading titled Bar", which in turn contains the documentation for commands Baz, Boz, Buz. This means we can't follow the texinfo generator's approach of just treating '= Foo' as another kind of markup to be turned into a '@section' texinfo and otherwise just written out into the output stream. Instead we need to be able to distinguish "this is a level 1 section heading" from any other kind of doc-comment, and the user shouldn't be able to insert directives specifying changes in the document structure randomly in the middle of what would otherwise be a lump of "just rST source to be fed to a rST parser".
The approach I've taken to letting the generator know the structure is to special-case headings into "must be in their own freeform doc-comment as a single line", like this:
##
# = Foo
##
This is easy to spot in the 'freeform' method, and matches how we already mark up headings in almost all cases. An alternative approach would be to have parser.py detect heading markup, so that instead of
for doc in schema.docs:
if doc.symbol:
vis.symbol(doc, schema.lookup_entity(doc.symbol))
else:
vis.freeform(doc)
(ie "everything the parser gives you is either documenting a symbol, or it is a freefrom comment") we have:
for doc in schema.docs:
if doc.symbol:
vis.symbol(doc, schema.lookup_entity(doc.symbol))
else if doc.is_section_header:
vis.new_section(doc.heading_text, doc.heading_level)
else:
vis.freeform(doc)
(ie "everything the parser gives you is either documenting a symbol, or a notification about the structure of the document, or a freeform comment".) I feel that would be less simple than we currently have, though.

There are a few things I have left out of this initial series:
* unlike the texinfo, there is no generation of index entries or an index in the HTML docs
* although there are HTML anchors on all the command/object/etc headings, they are not stable but just serial-number based tags like '#qapidoc-35', so not suitable for trying to link to from other parts of the docs
* unlike the old texinfo generation, we make no attempt to regression test the rST generation in 'make check'. This is trickier than the texinfo equivalent, because we never generate rST source that we could compare against a golden reference. Comparing against generated HTML is liable to break with new Sphinx versions; trying to compare the data structure of docutils nodes would be a bit more robust but would require a bunch of code to mock up running Sphinx somehow.

My view is that we can add niceties like this later; the series already seems big enough to me.

You can find the HTML rendered version of the results of this series at:
http://people.linaro.org/~peter.maydell/qdoc-snapshot/interop/qemu-ga-ref.html
http://people.linaro.org/~peter.maydell/qdoc-snapshot/interop/qemu-qmp-ref.html
(look also at
http://people.linaro.org/~peter.maydell/qdoc-snapshot/interop/index.html
if you want to see how the ToC for the interop manual comes out)
The manpages are
http://people.linaro.org/~peter.maydell/qemu-ga-ref.7
http://people.linaro.org/~peter.maydell/qemu-qmp-ref.7
(download and render with 'man -l path/to/foo.7')

For comparison, the old texinfo-to-HTML versions of the docs are:
https://www.qemu.org/docs/master/qemu-ga-ref.html
https://www.qemu.org/docs/master/qemu-qmp-ref.html

Git branch of this series also available at
https://git.linaro.org/people/peter.maydell/qemu-arm.git sphinx-conversions

thanks
-- PMM

Peter Maydell (18):
qapi/migration.json: Fix indentation qapi/qapi-schema.json: Put headers in their own doc-comment blocks qapi/machine.json: Escape a literal '*' in doc comment tests/qapi/doc-good.json: Clean up markup
scripts/qapi: Move doc-comment whitespace stripping to doc.py scripts/qapi/parser.py: improve doc comment indent handling docs/sphinx: Add new qapi-doc Sphinx extension docs/interop: Convert qemu-ga-ref to rST
docs/interop: Convert qemu-qmp-ref to rST
qapi: Use rST markup for literal blocks qga/qapi-schema.json: Add some headings
scripts/qapi: Remove texinfo generation support docs/devel/qapi-code-gen.txt: Update to new rST backend conventions
Makefile: Remove redundant Texinfo related rules scripts/texi2pod: Delete unused script
Remove Texinfo related files from .gitignore and git.orderfile
configure: Drop texinfo requirement
Remove texinfo dependency from docker and CI configs

 docs/devel/qapi-code-gen.txt               |  90 ++--
 configure                                  |  12 +-
 Makefile                                   |  86 +---
 tests/Makefile.include                     |  15 +-
 qapi/block-core.json                       |  16 +-
 qapi/machine.json                          |   2 +-
 qapi/migration.json                        |  60 +--
 qapi/qapi-schema.json                      |  18 +-
 qga/qapi-schema.json                       |  12 +-
 tests/qapi-schema/doc-good.json            |  25 +-
 .gitignore                                 |  15 -
 .travis.yml                                |   1 -
 MAINTAINERS                                |   3 +-
 docs/conf.py                               |   6 +-
 docs/index.html.in                         |   2 -
 docs/interop/conf.py                       |   4 +
 docs/interop/index.rst                     |   2 +
 docs/interop/qemu-ga-ref.rst               |   4 +
 docs/interop/qemu-ga-ref.texi              |  80 ---
 docs/interop/qemu-qmp-ref.rst              |   4 +
 docs/interop/qemu-qmp-ref.texi             |  80 ---
 docs/sphinx/qapidoc.py                     | 504 +++++++++++++++++++
 rules.mak                                  |  14 +-
 scripts/checkpatch.pl                      |   2 +-
 scripts/git.orderfile                      |   1 -
 scripts/qapi-gen.py                        |   2 -
 scripts/qapi/doc.py                        | 301 ------------
 scripts/qapi/gen.py                        |   7 -
 scripts/qapi/parser.py                     |  93 +++-
 scripts/texi2pod.pl                        | 536 ---------------------
 tests/docker/dockerfiles/debian10.docker   |   1 -
 tests/docker/dockerfiles/debian9.docker    |   1 -
 tests/docker/dockerfiles/fedora.docker     |   1 -
 tests/docker/dockerfiles/ubuntu.docker     |   1 -
 tests/docker/dockerfiles/ubuntu1804.docker |   1 -
 tests/qapi-schema/doc-good.out             |  22 +-
 tests/qapi-schema/doc-good.texi            | 287 -----------
 37 files changed, 759 insertions(+), 1552 deletions(-)
 create mode 100644 docs/interop/qemu-ga-ref.rst
 delete mode 100644 docs/interop/qemu-ga-ref.texi
 create mode 100644 docs/interop/qemu-qmp-ref.rst
 delete mode 100644 docs/interop/qemu-qmp-ref.texi
 create mode 100644 docs/sphinx/qapidoc.py
 delete mode 100644 scripts/qapi/doc.py
 delete mode 100755 scripts/texi2pod.pl
 delete mode 100644 tests/qapi-schema/doc-good.texi
Signature · 1 line
2.20.1
#1 lore raw

PATCH v4 1/18 qapi/migration.json: Fix indentation

Commits 6a9ad1542065ca0bd54c6 and 9004db48c080632aef23 added some new text to qapi/migration.json which doesn't fit the stricter indentation requirements imposed by the rST documentation generator. Reindent those lines to the new standard.

---
 qapi/migration.json | 60 ++++++++++++++++++++++-----------------------
 1 file changed, 30 insertions(+), 30 deletions(-)
qapi/migration.json +30 -30
index d44d99cd786..53437636a37 100644
@@ -606,18 +606,18 @@
 #                       Defaults to none. (Since 5.0)
 #
 # @multifd-zlib-level: Set the compression level to be used in live
-#          migration, the compression level is an integer between 0
-#          and 9, where 0 means no compression, 1 means the best
-#          compression speed, and 9 means best compression ratio which
-#          will consume more CPU.
-#          Defaults to 1. (Since 5.0)
+#                      migration, the compression level is an integer between 0
+#                      and 9, where 0 means no compression, 1 means the best
+#                      compression speed, and 9 means best compression ratio which
+#                      will consume more CPU.
+#                      Defaults to 1. (Since 5.0)
 #
 # @multifd-zstd-level: Set the compression level to be used in live
-#          migration, the compression level is an integer between 0
-#          and 20, where 0 means no compression, 1 means the best
-#          compression speed, and 20 means best compression ratio which
-#          will consume more CPU.
-#          Defaults to 1. (Since 5.0)
+#                      migration, the compression level is an integer between 0
+#                      and 20, where 0 means no compression, 1 means the best
+#                      compression speed, and 20 means best compression ratio which
+#                      will consume more CPU.
+#                      Defaults to 1. (Since 5.0)
 #
 # Since: 2.4
 ##
@@ -726,18 +726,18 @@
 #                       Defaults to none. (Since 5.0)
 #
 # @multifd-zlib-level: Set the compression level to be used in live
-#          migration, the compression level is an integer between 0
-#          and 9, where 0 means no compression, 1 means the best
-#          compression speed, and 9 means best compression ratio which
-#          will consume more CPU.
-#          Defaults to 1. (Since 5.0)
+#                      migration, the compression level is an integer between 0
+#                      and 9, where 0 means no compression, 1 means the best
+#                      compression speed, and 9 means best compression ratio which
+#                      will consume more CPU.
+#                      Defaults to 1. (Since 5.0)
 #
 # @multifd-zstd-level: Set the compression level to be used in live
-#          migration, the compression level is an integer between 0
-#          and 20, where 0 means no compression, 1 means the best
-#          compression speed, and 20 means best compression ratio which
-#          will consume more CPU.
-#          Defaults to 1. (Since 5.0)
+#                      migration, the compression level is an integer between 0
+#                      and 20, where 0 means no compression, 1 means the best
+#                      compression speed, and 20 means best compression ratio which
+#                      will consume more CPU.
+#                      Defaults to 1. (Since 5.0)
 #
 # Since: 2.4
 ##
@@ -881,18 +881,18 @@
 #                       Defaults to none. (Since 5.0)
 #
 # @multifd-zlib-level: Set the compression level to be used in live
-#          migration, the compression level is an integer between 0
-#          and 9, where 0 means no compression, 1 means the best
-#          compression speed, and 9 means best compression ratio which
-#          will consume more CPU.
-#          Defaults to 1. (Since 5.0)
+#                      migration, the compression level is an integer between 0
+#                      and 9, where 0 means no compression, 1 means the best
+#                      compression speed, and 9 means best compression ratio which
+#                      will consume more CPU.
+#                      Defaults to 1. (Since 5.0)
 #
 # @multifd-zstd-level: Set the compression level to be used in live
-#          migration, the compression level is an integer between 0
-#          and 20, where 0 means no compression, 1 means the best
-#          compression speed, and 20 means best compression ratio which
-#          will consume more CPU.
-#          Defaults to 1. (Since 5.0)
+#                      migration, the compression level is an integer between 0
+#                      and 20, where 0 means no compression, 1 means the best
+#                      compression speed, and 20 means best compression ratio which
+#                      will consume more CPU.
+#                      Defaults to 1. (Since 5.0)
 #
 # Since: 2.4
 ##
Signature · 1 line
2.20.1
Reviewed-by on v4 1/18
#2 lore raw

Re: [PATCH v4 01/18] qapi/migration.json: Fix indentation

Quoted 9 lines · Peter Maydell

Commits 6a9ad1542065ca0bd54c6 and 9004db48c080632aef23 added some new text to qapi/migration.json which doesn't fit the stricter indentation requirements imposed by the rST documentation generator. Reindent those lines to the new standard.

---
 qapi/migration.json | 60 ++++++++++++++++++++++-----------------------
 1 file changed, 30 insertions(+), 30 deletions(-)

r~

Reviewed-by on v4 1/18
#3 lore raw

Re: [PATCH v4 01/18] qapi/migration.json: Fix indentation

In reply to Peter Maydell
Quoted 6 lines · Peter Maydell

Commits 6a9ad1542065ca0bd54c6 and 9004db48c080632aef23 added some new text to qapi/migration.json which doesn't fit the stricter indentation requirements imposed by the rST documentation generator. Reindent those lines to the new standard.

#4 lore raw

PATCH v4 2/18 qapi/qapi-schema.json: Put headers in their own doc-comment blocks

In reply to Peter Maydell

Our current QAPI doc-comment markup allows section headers (introduced with a leading '=' or '==') anywhere in any documentation comment. This works for texinfo because the texi generator simply prints a texinfo heading directive at that point in the output stream. For rST generation, since we're assembling a tree of docutils nodes, this is awkward because a new section implies starting a new section node at the top level of the tree and generating text into there.

New section headings in the middle of the documentation of a command or event would be pretty nonsensical, and in fact we only ever output new headings using 'freeform' doc comment blocks whose only content is the single line of the heading, with two exceptions, which are in the introductory freeform-doc-block at the top of qapi/qapi-schema.json.

Split that doc-comment up so that the heading lines are in their own doc-comment. This will allow us to tighten the specification to insist that heading lines are always standalone, rather than requiring the rST document generator to look at every line in a doc comment block and handle headings in odd places.

This change makes no difference to the generated texi.

---
 qapi/qapi-schema.json | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
qapi/qapi-schema.json +9 -3
index fe980ce4370..ff5aea59451 100644
@@ -1,7 +1,9 @@
 # -*- Mode: Python -*-
 ##
 # = Introduction
-#
+##
+
+##
 # This document describes all commands currently supported by QMP.
 #
 # Most of the time their usage is exactly the same as in the user Monitor, this
@@ -25,9 +27,13 @@
 #
 # Please, refer to the QMP specification (docs/interop/qmp-spec.txt) for
 # detailed information on the Server command and response formats.
-#
+##
+
+##
 # = Stability Considerations
-#
+##
+
+##
 # The current QMP command set (described in this file) may be useful for a
 # number of use cases, however it's limited and several commands have bad
 # defined semantics, specially with regard to command completion.
Signature · 1 line
2.20.1
Reviewed-by on v4 2/18
#5 lore raw

Re: [PATCH v4 02/18] qapi/qapi-schema.json: Put headers in their own doc-comment blocks

Quoted 22 lines · Peter Maydell

Our current QAPI doc-comment markup allows section headers (introduced with a leading '=' or '==') anywhere in any documentation comment. This works for texinfo because the texi generator simply prints a texinfo heading directive at that point in the output stream. For rST generation, since we're assembling a tree of docutils nodes, this is awkward because a new section implies starting a new section node at the top level of the tree and generating text into there.

New section headings in the middle of the documentation of a command or event would be pretty nonsensical, and in fact we only ever output new headings using 'freeform' doc comment blocks whose only content is the single line of the heading, with two exceptions, which are in the introductory freeform-doc-block at the top of qapi/qapi-schema.json.

Split that doc-comment up so that the heading lines are in their own doc-comment. This will allow us to tighten the specification to insist that heading lines are always standalone, rather than requiring the rST document generator to look at every line in a doc comment block and handle headings in odd places.

Quoted 6 lines

This change makes no difference to the generated texi.

---
 qapi/qapi-schema.json | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

r~

#6 lore raw

Re: [PATCH v4 02/18] qapi/qapi-schema.json: Put headers in their own doc-comment blocks

In reply to Peter Maydell
Quoted 50 lines · Peter Maydell

Our current QAPI doc-comment markup allows section headers (introduced with a leading '=' or '==') anywhere in any documentation comment. This works for texinfo because the texi generator simply prints a texinfo heading directive at that point in the output stream. For rST generation, since we're assembling a tree of docutils nodes, this is awkward because a new section implies starting a new section node at the top level of the tree and generating text into there.

New section headings in the middle of the documentation of a command or event would be pretty nonsensical, and in fact we only ever output new headings using 'freeform' doc comment blocks whose only content is the single line of the heading, with two exceptions, which are in the introductory freeform-doc-block at the top of qapi/qapi-schema.json.

Split that doc-comment up so that the heading lines are in their own doc-comment. This will allow us to tighten the specification to insist that heading lines are always standalone, rather than requiring the rST document generator to look at every line in a doc comment block and handle headings in odd places.

This change makes no difference to the generated texi.

---
 qapi/qapi-schema.json | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
qapi/qapi-schema.json +4 -2
index fe980ce4370..ff5aea59451 100644
@@ -1,7 +1,9 @@
 # -*- Mode: Python -*-
 ##
 # = Introduction
-#
+##
+
+##
 # This document describes all commands currently supported by QMP.
 #
 # Most of the time their usage is exactly the same as in the user Monitor, this
@@ -25,9 +27,13 @@
 #
 # Please, refer to the QMP specification (docs/interop/qmp-spec.txt) for
 # detailed information on the Server command and response formats.
-#
+##

qapi/qapi-schema.json line 39

Quoted 10 lines
qapi/qapi-schema.json +5 -1
+
+##
 # = Stability Considerations
-#
+##
+
+##
 # The current QMP command set (described in this file) may be useful for a
 # number of use cases, however it's limited and several commands have bad
 # defined semantics, specially with regard to command completion.

The restriction you add is tolerable. But how does the doc generator behave when I get it wrong? The test case for getting it wrong is tests/qapi-schema/doc-bad-section.json.

In current master (commit f57587c7d47b35b2d9b31def3a74d81bdb5475d7),

    $ scripts/qapi-gen.py tests/qapi-schema/doc-bad-section.json 

produces this qapi-doc.texi:

@c AUTOMATICALLY GENERATED, DO NOT MODIFY

@deftp {Enum} Enum

@subsection Produces @strong{invalid} texinfo

@b{Values:}
@table @asis
@item @code{one}
The @emph{one} @{and only@}
@item @code{two}
Not documented
@end table
@code{two} is undocumented

@end deftp

This is invalid Texinfo:

    $ makeinfo qapi-doc.texi 
    qapi-output-master/qapi-doc.texi:4: warning: entry for index `tp' outside of any node
    qapi-output-master/qapi-doc.texi:6: @subsection seen before @end deftp
    qapi-output-master/qapi-doc.texi:17: unmatched `@end deftp'
    [Exit 1 ]

Ignore the warning, it's due to the harmlessly lazy test case.

A developer who puts a section heading in the wrong place in the schema gets to divine his mistake from makeinfo's error messages. Not nice.

After your rST conversion[*], ... Well, I tried to figure out how to build .html from tests/qapi-schema/doc-bad-section.json, but failed. Alright, use a heavier hammer: append that file to qapi-schema.json. Build succeeds, and produces a qemu-qmp-ref.7 that /usr/bin/man renders like this:

Enum (Enum)
== No good here

Values
one The _one_ {and only}

two Not documented
two is undocumented

I consider this even worse than before.

With my "[PATCH 1/2] qapi: Reject section markup in definition documentation", qapi-gen.py rejects it cleanly:

tests/qapi-schema/doc-bad-section.json:5:1: unexpected '=' markup in definition documentation

I believe it won't hinder your .rST conversion work. It might even help. Maybe only together with PATCH 2/2, but that's for you to decide.

[*] Fetched from
https://git.linaro.org/people/peter.maydell/qemu-arm.git
sphinx-conversions

#7 lore raw

PATCH v4 3/18 qapi/machine.json: Escape a literal '*' in doc comment

In reply to Peter Maydell

For rST, '*' is a kind of inline markup (for emphasis), so "*-softmmu" is a syntax error because of the missing closing '*'. Escape the '*' with a '\'.

The texinfo document generator will leave the '\' in the output, which is not ideal, but that generator is going to go away in a subsequent commit.

---
 qapi/machine.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qapi/machine.json +1 -1
index 6c11e3cf3a4..58580602524 100644
@@ -12,7 +12,7 @@
 #
 # The comprehensive enumeration of QEMU system emulation ("softmmu")
 # targets. Run "./configure --help" in the project root directory, and
-# look for the *-softmmu targets near the "--target-list" option. The
+# look for the \*-softmmu targets near the "--target-list" option. The
 # individual target constants are not documented here, for the time
 # being.
 #
Signature · 1 line
2.20.1
Reviewed-by on v4 3/18
#8 lore raw

Re: [PATCH v4 03/18] qapi/machine.json: Escape a literal '*' in doc comment

Quoted 4 lines · Peter Maydell

For rST, '*' is a kind of inline markup (for emphasis), so "*-softmmu" is a syntax error because of the missing closing '*'. Escape the '*' with a '\'.

Quoted 8 lines

The texinfo document generator will leave the '\' in the output, which is not ideal, but that generator is going to go away in a subsequent commit.

---
 qapi/machine.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

r~

#9 lore raw

PATCH v4 4/18 tests/qapi/doc-good.json: Clean up markup

In reply to Peter Maydell

doc-good.json tests some oddities of markup that we don't want to accept. Make them match the more restrictive rST syntax:

* in a single list the bullet types must all match
* lists must have leading and following blank lines
* indentation is important
* the '|' example syntax is going to go away entirely, so stop testing it

This will avoid the tests spuriously breaking when we tighten up the parser code in the following commits.

---
New patch in v2

---
 tests/qapi-schema/doc-good.json | 25 +++++++++++++------------
 tests/qapi-schema/doc-good.out  | 12 ++++++------
 tests/qapi-schema/doc-good.texi | 12 +++---------
 3 files changed, 22 insertions(+), 27 deletions(-)
tests/qapi-schema/doc-good.json +13 -12
index d992e713d97..a45dc22848c 100644
@@ -10,25 +10,25 @@
 #
 # *strong* _with emphasis_
 # @var {in braces}
+#
 # * List item one
-# - Two, multiple
+# * Two, multiple
 #   lines
 #
-# 3. Three
-# Still in list
+# * Three
+#   Still in list
+#
+# Not in list
 #
-#   Not in list
 # - Second list
-# Note: still in list
+#   Note: still in list
 #
 # Note: not in list
+#
 # 1. Third list
 #    is numbered
 #
-# - another item
-#
-# | example
-# | multiple lines
+# 2. another item
 #
 # Returns: the King
 # Since: the first age
@@ -62,7 +62,7 @@
 ##
 # @Base:
 # @base1:
-#   the first member
+# the first member
 ##
 { 'struct': 'Base', 'data': { 'base1': 'Enum' } }
 
@@ -101,7 +101,7 @@
 ##
 # @Alternate:
 # @i: an integer
-# @b is undocumented
+#     @b is undocumented
 ##
 { 'alternate': 'Alternate',
   'data': { 'i': 'int', 'b': 'bool' } }
@@ -115,7 +115,7 @@
 # @arg1: the first argument
 #
 # @arg2: the second
-# argument
+#        argument
 #
 # Features:
 # @cmd-feat1: a feature
@@ -124,6 +124,7 @@
 # Returns: @Object
 # TODO: frobnicate
 # Notes:
+#
 # - Lorem ipsum dolor sit amet
 # - Ut enim ad minim veniam
 #
tests/qapi-schema/doc-good.out +6 -6
index 4c9406a464d..9503a3a3178 100644
@@ -68,25 +68,25 @@ doc freeform
 
 *strong* _with emphasis_
 @var {in braces}
+
 * List item one
-- Two, multiple
+* Two, multiple
 lines
 
-3. Three
+* Three
 Still in list
 
 Not in list
+
 - Second list
 Note: still in list
 
 Note: not in list
+
 1. Third list
 is numbered
 
-- another item
-
-| example
-| multiple lines
+2. another item
 
 Returns: the King
 Since: the first age
tests/qapi-schema/doc-good.texi +3 -9
index d4b15dabf03..1e8063c8579 100644
@@ -6,6 +6,7 @@
 
 @strong{strong} @emph{with emphasis}
 @code{var} @{in braces@}
+
 @itemize @bullet
 @item
 List item one
@@ -20,6 +21,7 @@ Still in list
 @end itemize
 
 Not in list
+
 @itemize @minus
 @item
 Second list
@@ -28,6 +30,7 @@ Note: still in list
 @end itemize
 
 Note: not in list
+
 @enumerate
 @item
 Third list
@@ -36,15 +39,6 @@ is numbered
 @item
 another item
 
-@example
-example
-@end example
-
-@example
-multiple lines
-@end example
-
-
 @end enumerate
 
 Returns: the King
Signature · 1 line
2.20.1
Reviewed-by on v4 4/18
#10 lore raw

Re: [PATCH v4 04/18] tests/qapi/doc-good.json: Clean up markup

Quoted 12 lines · Peter Maydell

doc-good.json tests some oddities of markup that we don't want to accept. Make them match the more restrictive rST syntax:

* in a single list the bullet types must all match
* lists must have leading and following blank lines
* indentation is important
* the '|' example syntax is going to go away entirely, so stop testing it

This will avoid the tests spuriously breaking when we tighten up the parser code in the following commits.

Quoted 8 lines

---
New patch in v2

---
 tests/qapi-schema/doc-good.json | 25 +++++++++++++------------
 tests/qapi-schema/doc-good.out  | 12 ++++++------
 tests/qapi-schema/doc-good.texi | 12 +++---------
 3 files changed, 22 insertions(+), 27 deletions(-)

r~

#11 lore raw

Re: [PATCH v4 04/18] tests/qapi/doc-good.json: Clean up markup

In reply to Peter Maydell

The subject is a bit misleading. The markup doesn't need cleanup. It purposefully tests corner cases of the doc comment parser. For some of them, the conversion to rST will change the meaning. This commit tweaks the test so it passes before and after the conversion. Makes it a worse test for the doc comment parser, which doesn't matter, because the code in question is about to be deleted.

Quoted 6 lines · Peter Maydell

doc-good.json tests some oddities of markup that we don't want to accept. Make them match the more restrictive rST syntax:

* in a single list the bullet types must all match
* lists must have leading and following blank lines
* indentation is important

Actually, indentation has always been important, but the conversion to rST changes where and how it matters.

Quoted 2 lines

* the '|' example syntax is going to go away entirely, so stop testing it

Before the series, we (try to) cover all doc markup here.

The series replaces the doc markup language by rST + a little extra. The test must still cover the little extra then, and covering a bit of rST to ensure basic sanity won't hurt.

Correct?

I'm asking because a "yes" explains why we can drop coverage without
replacement: it's appropriate when the markup in question is replaced by rST.

Quoted 24 lines

This will avoid the tests spuriously breaking when we tighten up the parser code in the following commits.

---
New patch in v2

---
 tests/qapi-schema/doc-good.json | 25 +++++++++++++------------
 tests/qapi-schema/doc-good.out  | 12 ++++++------
 tests/qapi-schema/doc-good.texi | 12 +++---------
 3 files changed, 22 insertions(+), 27 deletions(-)
tests/qapi-schema/doc-good.json +2 -1
index d992e713d97..a45dc22848c 100644
@@ -10,25 +10,25 @@
 #
 # *strong* _with emphasis_
 # @var {in braces}
+#
 # * List item one
-# - Two, multiple
+# * Two, multiple

tests/qapi-schema/doc-good.json line 20

Quoted 10 lines
tests/qapi-schema/doc-good.json +4 -3
 #   lines
 #
-# 3. Three
-# Still in list
+# * Three
+#   Still in list
+#
+# Not in list
 #
-#   Not in list

This is an example for indentation becoming relevant where it wasn't before.

The old doc markup language uses blank lines to terminate list items. The new one uses indentation, which is more flexible.

Quoted 18 lines
tests/qapi-schema/doc-good.json +3 -5
 # - Second list
-# Note: still in list
+#   Note: still in list
 #
 # Note: not in list
+#
 # 1. Third list
 #    is numbered
 #
-# - another item
-#
-# | example
-# | multiple lines
+# 2. another item
 #
 # Returns: the King
 # Since: the first age

tests/qapi-schema/doc-good.json line 64

Quoted 3 lines
tests/qapi-schema/doc-good.json +0 -0
@@ -62,7 +62,7 @@
 ##
 # @Base:
 # @base1:

Here, indentation is relevant even before the series: @base: is only recognized as an argument section when it's not indented.

tests/qapi-schema/doc-good.json line 65

Quoted 2 lines
tests/qapi-schema/doc-good.json +1 -1
-#   the first member
+# the first member

Why do you need to unindent this line?

tests/qapi-schema/doc-good.json line 104

Quoted 9 lines
tests/qapi-schema/doc-good.json +1 -1
 ##
 { 'struct': 'Base', 'data': { 'base1': 'Enum' } }
 
@@ -101,7 +101,7 @@
 ##
 # @Alternate:
 # @i: an integer
-# @b is undocumented
+#     @b is undocumented

Why do you need to indent this line?

tests/qapi-schema/doc-good.json line 118

Quoted 9 lines
tests/qapi-schema/doc-good.json +1 -1
 ##
 { 'alternate': 'Alternate',
   'data': { 'i': 'int', 'b': 'bool' } }
@@ -115,7 +115,7 @@
 # @arg1: the first argument
 #
 # @arg2: the second
-# argument
+#        argument

Why do you need to indent this line?

Quoted 91 lines
tests/qapi-schema/doc-good.json +1 -0
 #
 # Features:
 # @cmd-feat1: a feature
@@ -124,6 +124,7 @@
 # Returns: @Object
 # TODO: frobnicate
 # Notes:
+#
 # - Lorem ipsum dolor sit amet
 # - Ut enim ad minim veniam
 #
tests/qapi-schema/doc-good.out +6 -6
index 4c9406a464d..9503a3a3178 100644
@@ -68,25 +68,25 @@ doc freeform
 
 *strong* _with emphasis_
 @var {in braces}
+
 * List item one
-- Two, multiple
+* Two, multiple
 lines
 
-3. Three
+* Three
 Still in list
 
 Not in list
+
 - Second list
 Note: still in list
 
 Note: not in list
+
 1. Third list
 is numbered
 
-- another item
-
-| example
-| multiple lines
+2. another item
 
 Returns: the King
 Since: the first age
tests/qapi-schema/doc-good.texi +3 -9
index d4b15dabf03..1e8063c8579 100644
@@ -6,6 +6,7 @@
 
 @strong{strong} @emph{with emphasis}
 @code{var} @{in braces@}
+
 @itemize @bullet
 @item
 List item one
@@ -20,6 +21,7 @@ Still in list
 @end itemize
 
 Not in list
+
 @itemize @minus
 @item
 Second list
@@ -28,6 +30,7 @@ Note: still in list
 @end itemize
 
 Note: not in list
+
 @enumerate
 @item
 Third list
@@ -36,15 +39,6 @@ is numbered
 @item
 another item
 
-@example
-example
-@end example
-
-@example
-multiple lines
-@end example
-
-
 @end enumerate
 
 Returns: the King
#12 lore raw

Re: [PATCH v4 04/18] tests/qapi/doc-good.json: Clean up markup

Quoted 13 lines · Markus Armbruster

The subject is a bit misleading. The markup doesn't need cleanup. It purposefully tests corner cases of the doc comment parser. For some of them, the conversion to rST will change the meaning. This commit tweaks the test so it passes before and after the conversion. Makes it a worse test for the doc comment parser, which doesn't matter, because the code in question is about to be deleted.

Quoted 3 lines · Peter Maydell

doc-good.json tests some oddities of markup that we don't want to accept. Make them match the more restrictive rST syntax:

Quoted 6 lines
Quoted 3 lines

* in a single list the bullet types must all match
* lists must have leading and following blank lines
* indentation is important

Actually, indentation has always been important, but the conversion to rST changes where and how it matters.

Mmm. More specifically, indentation was previously unimportant within a multiline block of text, and is now important there.

Quoted 9 lines
Quoted 2 lines

* the '|' example syntax is going to go away entirely, so stop testing it

Before the series, we (try to) cover all doc markup here.

The series replaces the doc markup language by rST + a little extra. The test must still cover the little extra then, and covering a bit of rST to ensure basic sanity won't hurt.

Quoted 5 lines

Correct?

I'm asking because a "yes" explains why we can drop coverage without
replacement: it's appropriate when the markup in question is replaced by rST.

I guess so. We still want some test coverage of the stuff the doc-comment parser is doing that's actually looking for arguments and so on; we don't really need to check that rst is rst.

It's been a while since I wrote this patch, but basically IIRC it's "make the minimal changes necessary so that the test does not start failing for the parser changes that will follow".

Quoted 11 lines

tests/qapi-schema/doc-good.json line 64

Quoted 7 lines

This will avoid the tests spuriously breaking when we tighten up the parser code in the following commits.

tests/qapi-schema/doc-good.json +0 -0
@@ -62,7 +62,7 @@
 ##
 # @Base:
 # @base1:

Here, indentation is relevant even before the series: @base: is only recognized as an argument section when it's not indented.

Quoted 4 lines

tests/qapi-schema/doc-good.json line 65

Quoted 2 lines
tests/qapi-schema/doc-good.json +1 -1
-#   the first member
+# the first member

Why do you need to unindent this line?

Because in the tightened syntax, you can either have:

@foo: line 1
line 2

(the definition part of the argument is multiple lines of rST, which all must be lined up to start at the same column)

or

@foo:
line1
line2

(the definition is multiple lines of rST, which all start in column 1)

But
@foo:
line1

is neither of the above, and will be invalid.

The old parser simply stripped all the leading whitespace from this kind of multiline lump-of-doc-text. That doesn't work for rST because we want to be able to have doc-text where leading whitespace matters. So we need to know how many characters of whitespace to delete from each line. The two options above basically correspond to the two major pre-existing kinds of doc-comment.

Compare commit 26ec4e53f2bf0a381, which fixed up the doc comments in qapi/ proper to follow this "one of these two indent models, but not anything else" pattern.

Quoted 11 lines

tests/qapi-schema/doc-good.json line 104

Quoted 9 lines
tests/qapi-schema/doc-good.json +1 -1
 ##
 { 'struct': 'Base', 'data': { 'base1': 'Enum' } }
 
@@ -101,7 +101,7 @@
 ##
 # @Alternate:
 # @i: an integer
-# @b is undocumented
+#     @b is undocumented

Why do you need to indent this line?

Again, because it needs to follow one of the two indent patterns described above. Either no text following the "@i:" and all lines start in column 1, or all lines have to start in the same column as the text following the "@i:". In this case I went for option 2.

The test input is a bit odd because it's talking about @b in the description-text for @i, but there you go. You could alternatively add a newline after the @i: line to put the text "@b is undocumented" into the doc-text for the whole @Alternate struct rather than into the doc-text for the @i member.

Quoted 10 lines

tests/qapi-schema/doc-good.json line 118

Quoted 8 lines
tests/qapi-schema/doc-good.json +1 -1
 { 'alternate': 'Alternate',
   'data': { 'i': 'int', 'b': 'bool' } }
@@ -115,7 +115,7 @@
 # @arg1: the first argument
 #
 # @arg2: the second
-# argument
+#        argument

Why do you need to indent this line?

As above, beacuse it's not in either of the two standard "this is what indent for a multi-line bit of doc text for an argument can be" patterns.

thanks
-- PMM

Reviewed-by
#13 lore raw

Re: [PATCH v4 04/18] tests/qapi/doc-good.json: Clean up markup

Quoted 39 lines · Peter Maydell
Quoted 13 lines · Markus Armbruster

The subject is a bit misleading. The markup doesn't need cleanup. It purposefully tests corner cases of the doc comment parser. For some of them, the conversion to rST will change the meaning. This commit tweaks the test so it passes before and after the conversion. Makes it a worse test for the doc comment parser, which doesn't matter, because the code in question is about to be deleted.

Quoted 3 lines · Peter Maydell

doc-good.json tests some oddities of markup that we don't want to accept. Make them match the more restrictive rST syntax:

Quoted 6 lines
Quoted 3 lines

* in a single list the bullet types must all match
* lists must have leading and following blank lines
* indentation is important

Actually, indentation has always been important, but the conversion to rST changes where and how it matters.

Mmm. More specifically, indentation was previously unimportant within a multiline block of text, and is now important there.

Quoted 9 lines
Quoted 2 lines

* the '|' example syntax is going to go away entirely, so stop testing it

Before the series, we (try to) cover all doc markup here.

The series replaces the doc markup language by rST + a little extra. The test must still cover the little extra then, and covering a bit of rST to ensure basic sanity won't hurt.

Quoted 5 lines

Correct?

I'm asking because a "yes" explains why we can drop coverage without
replacement: it's appropriate when the markup in question is replaced by rST.

Quoted 8 lines

I guess so. We still want some test coverage of the stuff the doc-comment parser is doing that's actually looking for arguments and so on; we don't really need to check that rst is rst.

It's been a while since I wrote this patch, but basically IIRC it's "make the minimal changes necessary so that the test does not start failing for the parser changes that will follow".

That's okay, but the commit message could be clearer. Perhaps:

tests/qapi/doc-good.json: Prepare for qapi-doc Sphinx extension

doc-good.json tests doc comment parser corner cases. We're about to largely replace it by a Sphinx extension, which will have different corner cases. Tweak the test so it passes both with the old parser and the Sphinx extension, by making it match the more restrictive rST syntax:

* in a single list the bullet types must all match
* lists must have leading and following blank lines
* indentation is important
* the '|' example syntax is going to go away entirely, so stop testing it

This will avoid the tests spuriously breaking when we tighten up the parser code in the following commits.

Quoted 47 lines
Quoted 11 lines

tests/qapi-schema/doc-good.json line 64

Quoted 7 lines

This will avoid the tests spuriously breaking when we tighten up the parser code in the following commits.

tests/qapi-schema/doc-good.json +0 -0
@@ -62,7 +62,7 @@
 ##
 # @Base:
 # @base1:

Here, indentation is relevant even before the series: @base: is only recognized as an argument section when it's not indented.

Quoted 4 lines

tests/qapi-schema/doc-good.json line 65

Quoted 2 lines
tests/qapi-schema/doc-good.json +1 -1
-#   the first member
+# the first member

Why do you need to unindent this line?

Because in the tightened syntax, you can either have:

@foo: line 1
line 2

(the definition part of the argument is multiple lines of rST, which all must be lined up to start at the same column)

or

@foo:
line1
line2

(the definition is multiple lines of rST, which all start in column 1)

But
@foo:
line1

is neither of the above, and will be invalid.

The old parser simply stripped all the leading whitespace from this kind of multiline lump-of-doc-text. That doesn't work for rST because we want to be able to have doc-text where leading whitespace matters. So we need to know how many characters of whitespace to delete from each line. The two options above basically correspond to the two major pre-existing kinds of doc-comment.

Quoted 3 lines

Compare commit 26ec4e53f2bf0a381, which fixed up the doc comments in qapi/ proper to follow this "one of these two indent models, but not anything else" pattern.

Ah, now I remember.

Remind me, how is messed up doc comment indentation reported in the brave new Sphinx world?

Quoted 19 lines
Quoted 11 lines

tests/qapi-schema/doc-good.json line 104

Quoted 9 lines
tests/qapi-schema/doc-good.json +1 -1
 ##
 { 'struct': 'Base', 'data': { 'base1': 'Enum' } }
 
@@ -101,7 +101,7 @@
 ##
 # @Alternate:
 # @i: an integer
-# @b is undocumented
+#     @b is undocumented

Why do you need to indent this line?

Again, because it needs to follow one of the two indent patterns described above. Either no text following the "@i:" and all lines start in column 1, or all lines have to start in the same column as the text following the "@i:". In this case I went for option 2.

Quoted 6 lines

The test input is a bit odd because it's talking about @b in the description-text for @i, but there you go. You could alternatively add a newline after the @i: line to put the text "@b is undocumented" into the doc-text for the whole @Alternate struct rather than into the doc-text for the @i member.

The test's purpose is to be mean to the doc parser, not pleasant to the reader's eye ;)

The doc before the patch tests the (less than ideal) handling of a mistake that is easy to make, namely forgetting the ':' after the member name.

Your change is okay.

Quoted 11 lines
Quoted 10 lines

tests/qapi-schema/doc-good.json line 118

Quoted 8 lines
tests/qapi-schema/doc-good.json +1 -1
 { 'alternate': 'Alternate',
   'data': { 'i': 'int', 'b': 'bool' } }
@@ -115,7 +115,7 @@
 # @arg1: the first argument
 #
 # @arg2: the second
-# argument
+#        argument

Why do you need to indent this line?

Quoted 3 lines

As above, beacuse it's not in either of the two standard "this is what indent for a multi-line bit of doc text for an argument can be" patterns.

Thanks!

Preferably with an improved commit message

#14 lore raw

Re: [PATCH v4 04/18] tests/qapi/doc-good.json: Clean up markup

Quoted 2 lines · Markus Armbruster

Remind me, how is messed up doc comment indentation reported in the brave new Sphinx world?

For insufficient indentatation, like this:

GEN qapi-gen
In file included from /home/petmay01/linaro/qemu-from-laptop/qemu/qapi/qapi-schema.json:91:
/home/petmay01/linaro/qemu-from-laptop/qemu/qapi/machine.json:194:1:
unexpected de-indent

(where the quoted line number in the .json file is the line that was insufficiently indented).

If you over-indent, then the QAPI parser assumes you intended to use some rST syntax which needed the extra indent, and passes it to Sphinx, which will either interpret it as per the rST spec or complain.

thanks
-- PMM

#15 lore raw

PATCH v4 5/18 scripts/qapi: Move doc-comment whitespace stripping to doc.py

In reply to Peter Maydell

As we accumulate lines from doc comments when parsing the JSON, the QAPIDoc class generally strips leading and trailing whitespace using line.strip() when it calls _append_freeform(). This is fine for texinfo, but for rST leading whitespace is significant. We'd like to move to having the text in doc comments be rST format rather than a custom syntax, so move the removal of leading whitespace from the QAPIDoc class to the texinfo-specific processing code in texi_format() in qapi/doc.py.

(Trailing whitespace will always be stripped by the rstrip() in Section::append regardless.)

In a followup commit we will make the whitespace in the lines of doc comment sections more consistently follow the input source.

There is no change to the generated .texi files before and after this commit.

Because the qapi-schema test checks the exact values of the documentation comments against a reference, we need to update that reference to match the new whitespace. In the first four places this is now correctly checking that we did put in the amount of whitespace to pass a rST-formatted list to the backend; in the last two places the extra whitespace is 'wrong' and will go away again in the following commit.

---
New in v2: update doc-good.out as noted in final para of commit msg

---
 scripts/qapi/doc.py            |  1 +
 scripts/qapi/parser.py         | 12 ++++--------
 tests/qapi-schema/doc-good.out | 12 ++++++------
 3 files changed, 11 insertions(+), 14 deletions(-)
scripts/qapi/doc.py +1 -0
index 1787a53d91a..26cd1a1751e 100644
@@ -79,6 +79,7 @@ def texi_format(doc):
     inlist = ''
     lastempty = False
     for line in doc.split('\n'):
+        line = line.strip()
         empty = line == ''
 
         # FIXME: Doing this in a single if / elif chain is
scripts/qapi/parser.py +4 -8
index abadacbb0e8..7fae4478d34 100644
@@ -417,10 +417,10 @@ class QAPIDoc:
                 self._append_line = self._append_various_line
                 self._append_various_line(line)
             else:
-                self._append_freeform(line.strip())
+                self._append_freeform(line)
         else:
             # This is a free-form documentation block
-            self._append_freeform(line.strip())
+            self._append_freeform(line)
 
     def _append_args_line(self, line):
         """
@@ -453,7 +453,7 @@ class QAPIDoc:
                 self._append_various_line(line)
             return
 
-        self._append_freeform(line.strip())
+        self._append_freeform(line)
 
     def _append_features_line(self, line):
         name = line.split(' ', 1)[0]
@@ -472,7 +472,7 @@ class QAPIDoc:
             self._append_various_line(line)
             return
 
-        self._append_freeform(line.strip())
+        self._append_freeform(line)
 
     def _append_various_line(self, line):
         """
@@ -495,10 +495,6 @@ class QAPIDoc:
             line = line[len(name)+1:]
             self._start_section(name[:-1])
 
-        if (not self._section.name or
-                not self._section.name.startswith('Example')):
-            line = line.strip()
-
         self._append_freeform(line)
 
     def _start_symbol_section(self, symbols_dict, name):
tests/qapi-schema/doc-good.out +6 -6
index 9503a3a3178..a65bce639ff 100644
@@ -71,20 +71,20 @@ doc freeform
 
 * List item one
 * Two, multiple
-lines
+  lines
 
 * Three
-Still in list
+  Still in list
 
 Not in list
 
 - Second list
-Note: still in list
+  Note: still in list
 
 Note: not in list
 
 1. Third list
-is numbered
+   is numbered
 
 2. another item
 
@@ -144,7 +144,7 @@ doc symbol=Alternate
 
     arg=i
 an integer
-@b is undocumented
+    @b is undocumented
     arg=b
 
 doc freeform
@@ -157,7 +157,7 @@ doc symbol=cmd
 the first argument
     arg=arg2
 the second
-argument
+       argument
     arg=arg3
 
     feature=cmd-feat1
Signature · 1 line
2.20.1
Reviewed-by on v4 5/18
#16 lore raw

Re: [PATCH v4 05/18] scripts/qapi: Move doc-comment whitespace stripping to doc.py

Quoted 26 lines · Peter Maydell

As we accumulate lines from doc comments when parsing the JSON, the QAPIDoc class generally strips leading and trailing whitespace using line.strip() when it calls _append_freeform(). This is fine for texinfo, but for rST leading whitespace is significant. We'd like to move to having the text in doc comments be rST format rather than a custom syntax, so move the removal of leading whitespace from the QAPIDoc class to the texinfo-specific processing code in texi_format() in qapi/doc.py.

(Trailing whitespace will always be stripped by the rstrip() in Section::append regardless.)

In a followup commit we will make the whitespace in the lines of doc comment sections more consistently follow the input source.

There is no change to the generated .texi files before and after this commit.

Because the qapi-schema test checks the exact values of the documentation comments against a reference, we need to update that reference to match the new whitespace. In the first four places this is now correctly checking that we did put in the amount of whitespace to pass a rST-formatted list to the backend; in the last two places the extra whitespace is 'wrong' and will go away again in the following commit.

Quoted 8 lines

---
New in v2: update doc-good.out as noted in final para of commit msg

---
 scripts/qapi/doc.py            |  1 +
 scripts/qapi/parser.py         | 12 ++++--------
 tests/qapi-schema/doc-good.out | 12 ++++++------
 3 files changed, 11 insertions(+), 14 deletions(-)

r~

Reviewed-by on v4 5/18
#17 lore raw

Re: [PATCH v4 05/18] scripts/qapi: Move doc-comment whitespace stripping to doc.py

In reply to Peter Maydell
Quoted 4 lines · Peter Maydell

As we accumulate lines from doc comments when parsing the JSON, the QAPIDoc class generally strips leading and trailing whitespace using line.strip() when it calls _append_freeform(). This is fine for texinfo,

Texinfo

Quoted 8 lines

but for rST leading whitespace is significant. We'd like to
move to having the text in doc comments be rST format rather than a custom syntax, so move the removal of leading whitespace from the QAPIDoc class to the texinfo-specific processing code in texi_format() in qapi/doc.py.

(Trailing whitespace will always be stripped by the rstrip() in Section::append regardless.)

We strip to keep the Texinfo source tidier. Stripping less as we move towards its replacement is fine.

Quoted 14 lines

In a followup commit we will make the whitespace in the lines of doc comment sections more consistently follow the input source.

There is no change to the generated .texi files before and after this commit.

Because the qapi-schema test checks the exact values of the documentation comments against a reference, we need to update that reference to match the new whitespace. In the first four places this is now correctly checking that we did put in the amount of whitespace to pass a rST-formatted list to the backend; in the last two places the extra whitespace is 'wrong' and will go away again in the following commit.

Quoted 1 line

The thorough explanation in the commit message made review easier. Thanks!

#18 lore raw

PATCH v4 6/18 scripts/qapi/parser.py: improve doc comment indent handling

In reply to Peter Maydell

Make the handling of indentation in doc comments more sophisticated, so that when we see a section like:

Notes: some text
some more text
indented line 3

we save it for the doc-comment processing code as:

some text
some more text
indented line 3

and when we see a section with the heading on its own line:

Notes:

some text
some more text
indented text

we also accept that and save it in the same form.

The exception is that we always retain indentation as-is for Examples sections, because these are literal text.

If we detect that the comment document text is not indented as much as we expect it to be, we throw a parse error. (We don't complain about over-indented sections, because for rST this can be legitimate markup.)

The golden reference for the doc comment text is updated to remove the two 'wrong' indents; these now form a test case that we correctly stripped leading whitespace from an indented multi-line argument definition.

---
v1->v2: Update doc-good.out as per final para.

---
 scripts/qapi/parser.py         | 81 +++++++++++++++++++++++++++-------
 tests/qapi-schema/doc-good.out |  4 +-
 2 files changed, 67 insertions(+), 18 deletions(-)
scripts/qapi/parser.py +65 -16
index 7fae4478d34..d9f11eadd96 100644
@@ -308,18 +308,32 @@ class QAPIDoc:
     """
 
     class Section:
-        def __init__(self, name=None):
+        def __init__(self, parser, name=None, indent=0):
+            # parser, for error messages about indentation
+            self._parser = parser
             # optional section name (argument/member or section name)
             self.name = name
             # the list of lines for this section
             self.text = ''
+            # the expected indent level of the text of this section
+            self._indent = indent
 
         def append(self, line):
+            # Strip leading spaces corresponding to the expected indent level
+            # Blank lines are always OK.
+            if line:
+                spacecount = len(line) - len(line.lstrip(" "))
+                if spacecount > self._indent:
+                    spacecount = self._indent
+                if spacecount < self._indent:
+                    raise QAPIParseError(self._parser, "unexpected de-indent")
+                line = line[spacecount:]
+
             self.text += line.rstrip() + '\n'
 
     class ArgSection(Section):
-        def __init__(self, name):
-            super().__init__(name)
+        def __init__(self, parser, name, indent=0):
+            super().__init__(parser, name, indent)
             self.member = None
 
         def connect(self, member):
@@ -333,7 +347,7 @@ class QAPIDoc:
         self._parser = parser
         self.info = info
         self.symbol = None
-        self.body = QAPIDoc.Section()
+        self.body = QAPIDoc.Section(parser)
         # dict mapping parameter name to ArgSection
         self.args = OrderedDict()
         self.features = OrderedDict()
@@ -438,7 +452,18 @@ class QAPIDoc:
 
         if name.startswith('@') and name.endswith(':'):
             line = line[len(name)+1:]
-            self._start_args_section(name[1:-1])
+            if not line or line.isspace():
+                # Line was just the "@arg:" header; following lines
+                # are not indented
+                indent = 0
+                line = ''
+            else:
+                # Line is "@arg: first line of description"; following
+                # lines should be indented by len(name) + 1, and we
+                # pad out this first line so it is handled the same way
+                indent = len(name) + 1
+                line = ' ' * indent + line
+            self._start_args_section(name[1:-1], indent)
         elif self._is_section_tag(name):
             self._append_line = self._append_various_line
             self._append_various_line(line)
@@ -460,7 +485,17 @@ class QAPIDoc:
 
         if name.startswith('@') and name.endswith(':'):
             line = line[len(name)+1:]
-            self._start_features_section(name[1:-1])
+            if not line or line.isspace():
+                # Line is just the "@name:" header, no ident for following lines
+                indent = 0
+                line = ''
+            else:
+                # Line is "@arg: first line of description"; following
+                # lines should be indented by len(name) + 3, and we
+                # pad out this first line so it is handled the same way
+                indent = len(name) + 1
+                line = ' ' * indent + line
+            self._start_features_section(name[1:-1], indent)
         elif self._is_section_tag(name):
             self._append_line = self._append_various_line
             self._append_various_line(line)
@@ -493,11 +528,23 @@ class QAPIDoc:
                                  % (name, self.sections[0].name))
         if self._is_section_tag(name):
             line = line[len(name)+1:]
-            self._start_section(name[:-1])
+            if not line or line.isspace():
+                # Line is just "SectionName:", no indent for following lines
+                indent = 0
+                line = ''
+            elif name.startswith("Example"):
+                # The "Examples" section is literal-text, so preserve
+                # all the indentation as-is
+                indent = 0
+            else:
+                # Line is "SectionName: some text", indent required
+                indent = len(name) + 1
+                line = ' ' * indent + line
+            self._start_section(name[:-1], indent)
 
         self._append_freeform(line)
 
-    def _start_symbol_section(self, symbols_dict, name):
+    def _start_symbol_section(self, symbols_dict, name, indent):
         # FIXME invalid names other than the empty string aren't flagged
         if not name:
             raise QAPIParseError(self._parser, "invalid parameter name")
@@ -506,21 +553,21 @@ class QAPIDoc:
                                  "'%s' parameter name duplicated" % name)
         assert not self.sections
         self._end_section()
-        self._section = QAPIDoc.ArgSection(name)
+        self._section = QAPIDoc.ArgSection(self._parser, name, indent)
         symbols_dict[name] = self._section
 
-    def _start_args_section(self, name):
-        self._start_symbol_section(self.args, name)
+    def _start_args_section(self, name, indent):
+        self._start_symbol_section(self.args, name, indent)
 
-    def _start_features_section(self, name):
-        self._start_symbol_section(self.features, name)
+    def _start_features_section(self, name, indent):
+        self._start_symbol_section(self.features, name, indent)
 
-    def _start_section(self, name=None):
+    def _start_section(self, name=None, indent=0):
         if name in ('Returns', 'Since') and self.has_section(name):
             raise QAPIParseError(self._parser,
                                  "duplicated '%s' section" % name)
         self._end_section()
-        self._section = QAPIDoc.Section(name)
+        self._section = QAPIDoc.Section(self._parser, name, indent)
         self.sections.append(self._section)
 
     def _end_section(self):
@@ -543,7 +590,7 @@ class QAPIDoc:
     def connect_member(self, member):
         if member.name not in self.args:
             # Undocumented TODO outlaw
-            self.args[member.name] = QAPIDoc.ArgSection(member.name)
+            self.args[member.name] = QAPIDoc.ArgSection(self._parser, member.name)
         self.args[member.name].connect(member)
 
     def connect_feature(self, feature):
@@ -551,6 +598,8 @@ class QAPIDoc:
             raise QAPISemError(feature.info,
                                "feature '%s' lacks documentation"
                                % feature.name)
+            self.features[feature.name] = QAPIDoc.ArgSection(self._parser,
+                                                             feature.name)
         self.features[feature.name].connect(feature)
 
     def check_expr(self, expr):
tests/qapi-schema/doc-good.out +2 -2
index a65bce639ff..0302ce0bde1 100644
@@ -144,7 +144,7 @@ doc symbol=Alternate
 
     arg=i
 an integer
-    @b is undocumented
+@b is undocumented
     arg=b
 
 doc freeform
@@ -157,7 +157,7 @@ doc symbol=cmd
 the first argument
     arg=arg2
 the second
-       argument
+argument
     arg=arg3
 
     feature=cmd-feat1
Signature · 1 line
2.20.1
Reviewed-by on v4 6/18
#19 lore raw

Re: [PATCH v4 06/18] scripts/qapi/parser.py: improve doc comment indent handling

Quoted 36 lines · Peter Maydell

Make the handling of indentation in doc comments more sophisticated, so that when we see a section like:

Notes: some text
some more text
indented line 3

we save it for the doc-comment processing code as:

some text
some more text
indented line 3

and when we see a section with the heading on its own line:

Notes:

some text
some more text
indented text

we also accept that and save it in the same form.

The exception is that we always retain indentation as-is for Examples sections, because these are literal text.

If we detect that the comment document text is not indented as much as we expect it to be, we throw a parse error. (We don't complain about over-indented sections, because for rST this can be legitimate markup.)

The golden reference for the doc comment text is updated to remove the two 'wrong' indents; these now form a test case that we correctly stripped leading whitespace from an indented multi-line argument definition.

Quoted 7 lines

---
v1->v2: Update doc-good.out as per final para.

---
 scripts/qapi/parser.py         | 81 +++++++++++++++++++++++++++-------
 tests/qapi-schema/doc-good.out |  4 +-
 2 files changed, 67 insertions(+), 18 deletions(-)

r~

#20 lore raw

PATCH v4 7/18 docs/sphinx: Add new qapi-doc Sphinx extension

In reply to Peter Maydell

Some of our documentation is auto-generated from documentation comments in the JSON schema.

For Sphinx, rather than creating a file to include, the most natural way to handle this is to have a small custom Sphinx extension which processes the JSON file and inserts documentation into the rST file being processed.

This is the same approach that kerneldoc and hxtool use.

---
 MAINTAINERS            |   1 +
 docs/conf.py           |   6 +-
 docs/sphinx/qapidoc.py | 504 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 510 insertions(+), 1 deletion(-)
 create mode 100644 docs/sphinx/qapidoc.py
MAINTAINERS +1 -0
index 36d0c6887a9..06a762b9dc4 100644
@@ -2822,3 +2822,4 @@ M: Peter Maydell <[email protected]>
 S: Maintained
 F: docs/conf.py
 F: docs/*/conf.py
+F: docs/sphinx/
docs/conf.py +5 -1
index 960043cb860..ac35922daf2 100644
@@ -51,7 +51,10 @@ except NameError:
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use an absolute path starting from qemu_docdir.
 #
+# Our extensions are in docs/sphinx; the qapidoc extension requires
+# the QAPI modules from scripts/.
 sys.path.insert(0, os.path.join(qemu_docdir, "sphinx"))
+sys.path.insert(0, os.path.join(qemu_docdir, "../scripts"))
 
 
 # -- General configuration ------------------------------------------------
@@ -64,7 +67,7 @@ needs_sphinx = '1.3'
 # Add any Sphinx extension module names here, as strings. They can be
 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
 # ones.
-extensions = ['kerneldoc', 'qmp_lexer', 'hxtool']
+extensions = ['kerneldoc', 'qmp_lexer', 'hxtool', 'qapidoc']
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
@@ -238,3 +241,4 @@ texinfo_documents = [
 kerneldoc_bin = os.path.join(qemu_docdir, '../scripts/kernel-doc')
 kerneldoc_srctree = os.path.join(qemu_docdir, '..')
 hxtool_srctree = os.path.join(qemu_docdir, '..')
+qapidoc_srctree = os.path.join(qemu_docdir, '..')
docs/sphinx/qapidoc.py new file +504 -0

504 lines not on this page · raw message

Signature · 1 line
2.20.1
#21 lore raw

PATCH v4 8/18 docs/interop: Convert qemu-ga-ref to rST

In reply to Peter Maydell

Convert qemu-ga-ref to rST format. This includes dropping the plain-text, pdf and info format outputs for this document; as with all our other Sphinx-based documentation, we provide HTML and manpage only.

The qemu-ga-ref.rst is somewhat more stripped down than the .texi was, because we do not (currently) attempt to generate indexes for the commands, events and data types being documented.

As the GA ref is now part of the Sphinx 'interop' manual, we can delete the direct link from index.html.in.

---
 Makefile                      | 41 ++++++++----------
 MAINTAINERS                   |  2 +-
 docs/index.html.in            |  1 -
 docs/interop/conf.py          |  2 +
 docs/interop/index.rst        |  1 +
 docs/interop/qemu-ga-ref.rst  |  4 ++
 docs/interop/qemu-ga-ref.texi | 80 -----------------------------------
 7 files changed, 25 insertions(+), 106 deletions(-)
 create mode 100644 docs/interop/qemu-ga-ref.rst
 delete mode 100644 docs/interop/qemu-ga-ref.texi
Makefile +17 -24
index 5847f8d41d9..14780878fad 100644
@@ -353,7 +353,7 @@ DOCS+=$(MANUAL_BUILDDIR)/tools/virtiofsd.1
 endif
 DOCS+=$(MANUAL_BUILDDIR)/system/qemu-block-drivers.7
 DOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7
-DOCS+=docs/interop/qemu-ga-ref.html docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7
+DOCS+=$(MANUAL_BUILDDIR)/interop/qemu-ga-ref.7
 DOCS+=$(MANUAL_BUILDDIR)/system/qemu-cpu-models.7
 DOCS+=$(MANUAL_BUILDDIR)/index.html
 ifdef CONFIG_VIRTFS
@@ -771,11 +771,11 @@ distclean: clean
 	rm -f config.log
 	rm -f linux-headers/asm
 	rm -f docs/version.texi
-	rm -f docs/interop/qemu-ga-qapi.texi docs/interop/qemu-qmp-qapi.texi
-	rm -f docs/interop/qemu-qmp-ref.7 docs/interop/qemu-ga-ref.7
-	rm -f docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
-	rm -f docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
-	rm -f docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
+	rm -f docs/interop/qemu-qmp-qapi.texi
+	rm -f docs/interop/qemu-qmp-ref.7
+	rm -f docs/interop/qemu-qmp-ref.txt
+	rm -f docs/interop/qemu-qmp-ref.pdf
+	rm -f docs/interop/qemu-qmp-ref.html
 	rm -rf .doctrees
 	$(call clean-manual,devel)
 	$(call clean-manual,interop)
@@ -830,7 +830,7 @@ endif
 # and also any sphinx-built manpages.
 define install-manual =
 for d in $$(cd $(MANUAL_BUILDDIR) && find $1 -type d); do $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/$$d"; done
-for f in $$(cd $(MANUAL_BUILDDIR) && find $1 -type f -a '!' '(' -name '*.[0-9]' -o -name 'qemu-*-qapi.*' -o -name 'qemu-*-ref.*' ')' ); do $(INSTALL_DATA) "$(MANUAL_BUILDDIR)/$$f" "$(DESTDIR)$(qemu_docdir)/$$f"; done
+for f in $$(cd $(MANUAL_BUILDDIR) && find $1 -type f -a '!' '(' -name '*.[0-9]' -o -name 'qemu-*-qapi.*' -o -name 'qemu-qmp-ref.*' ')' ); do $(INSTALL_DATA) "$(MANUAL_BUILDDIR)/$$f" "$(DESTDIR)$(qemu_docdir)/$$f"; done
 endef
 
 # Note that we deliberately do not install the "devel" manual: it is
@@ -865,9 +865,7 @@ ifdef CONFIG_TRACE_SYSTEMTAP
 endif
 ifneq (,$(findstring qemu-ga,$(TOOLS)))
 	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/interop/qemu-ga.8 "$(DESTDIR)$(mandir)/man8"
-	$(INSTALL_DATA) docs/interop/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)"
-	$(INSTALL_DATA) docs/interop/qemu-ga-ref.txt "$(DESTDIR)$(qemu_docdir)"
-	$(INSTALL_DATA) docs/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7"
+	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7"
 endif
 endif
 ifdef CONFIG_VIRTFS
@@ -1060,7 +1058,7 @@ endef
 $(MANUAL_BUILDDIR)/devel/index.html: $(call manual-deps,devel)
 	$(call build-manual,devel,html)
 
-$(MANUAL_BUILDDIR)/interop/index.html: $(call manual-deps,interop)
+$(MANUAL_BUILDDIR)/interop/index.html: $(call manual-deps,interop) $(SRC_PATH)/qga/qapi-schema.json $(qapi-py)
 	$(call build-manual,interop,html)
 
 $(MANUAL_BUILDDIR)/specs/index.html: $(call manual-deps,specs)
@@ -1075,7 +1073,10 @@ $(MANUAL_BUILDDIR)/tools/index.html: $(call manual-deps,tools) $(SRC_PATH)/qemu-
 $(MANUAL_BUILDDIR)/user/index.html: $(call manual-deps,user)
 	$(call build-manual,user,html)
 
-$(call define-manpage-rule,interop,qemu-ga.8)
+$(call define-manpage-rule,interop,\
+       qemu-ga.8 qemu-ga-ref.7,\
+       $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/qga/qapi-schema.json \
+       $(qapi-py))
 
 $(call define-manpage-rule,system,qemu.1 qemu-block-drivers.7 qemu-cpu-models.7)
 
@@ -1092,18 +1093,10 @@ $(MANUAL_BUILDDIR)/index.html: $(SRC_PATH)/docs/index.html.in qemu-version.h
 docs/interop/qemu-qmp-qapi.texi: qapi/qapi-doc.texi
 	@cp -p $< $@
 
-docs/interop/qemu-ga-qapi.texi: qga/qapi-generated/qga-qapi-doc.texi
-	@cp -p $< $@
-
-html: docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html sphinxdocs
-info: docs/interop/qemu-qmp-ref.info docs/interop/qemu-ga-ref.info
-pdf: docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
-txt: docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
-
-docs/interop/qemu-ga-ref.dvi docs/interop/qemu-ga-ref.html \
-    docs/interop/qemu-ga-ref.info docs/interop/qemu-ga-ref.pdf \
-    docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7: \
-	docs/interop/qemu-ga-ref.texi docs/interop/qemu-ga-qapi.texi
+html: docs/interop/qemu-qmp-ref.html sphinxdocs
+info: docs/interop/qemu-qmp-ref.info
+pdf: docs/interop/qemu-qmp-ref.pdf
+txt: docs/interop/qemu-qmp-ref.txt
 
 docs/interop/qemu-qmp-ref.dvi docs/interop/qemu-qmp-ref.html \
     docs/interop/qemu-qmp-ref.info docs/interop/qemu-qmp-ref.pdf \
MAINTAINERS +1 -1
index 06a762b9dc4..1f13db32d97 100644
@@ -2154,9 +2154,9 @@ M: Michael Roth <[email protected]>
 S: Maintained
 F: qga/
 F: docs/interop/qemu-ga.rst
+F: docs/interop/qemu-ga-ref.rst
 F: scripts/qemu-guest-agent/
 F: tests/test-qga.c
-F: docs/interop/qemu-ga-ref.texi
 T: git https://github.com/mdroth/qemu.git qga
 
 QOM
docs/index.html.in +0 -1
index e9a160384cf..f180770b052 100644
@@ -13,7 +13,6 @@
             <li><a href="interop/index.html">System Emulation Management and Interoperability Guide</a></li>
             <li><a href="specs/index.html">System Emulation Guest Hardware Specifications</a></li>
             <li><a href="qemu-qmp-ref.html">QMP Reference Manual</a></li>
-            <li><a href="qemu-ga-ref.html">Guest Agent Protocol Reference</a></li>
         </ul>
     </body>
 </html>
docs/interop/conf.py +2 -0
index 42ce7e3d365..e83632e0108 100644
@@ -19,4 +19,6 @@ html_theme_options['description'] = u'System Emulation Management and Interopera
 man_pages = [
     ('qemu-ga', 'qemu-ga', u'QEMU Guest Agent',
      ['Michael Roth <[email protected]>'], 8),
+    ('qemu-ga-ref', 'qemu-ga-ref', u'QEMU Guest Agent Protocol Reference',
+     [], 7),
 ]
docs/interop/index.rst +1 -0
index 049387ac6de..f3af38dce17 100644
@@ -18,5 +18,6 @@ Contents:
    live-block-operations
    pr-helper
    qemu-ga
+   qemu-ga-ref
    vhost-user
    vhost-user-gpu
docs/interop/qemu-ga-ref.rst new file +4 -0
new file mode 100644
index 00000000000..013eac0bb53
@@ -0,0 +1,4 @@
+QEMU Guest Agent Protocol Reference
+===================================
+
+.. qapi-doc:: qga/qapi-schema.json
docs/interop/qemu-ga-ref.texi deleted +0 -80

80 lines not on this page · raw message

Signature · 1 line
2.20.1
Reviewed-by on v4 8/18
#22 lore raw

Re: [PATCH v4 08/18] docs/interop: Convert qemu-ga-ref to rST

Quoted 14 lines · Peter Maydell

Convert qemu-ga-ref to rST format. This includes dropping the plain-text, pdf and info format outputs for this document; as with all our other Sphinx-based documentation, we provide HTML and manpage only.

The qemu-ga-ref.rst is somewhat more stripped down than the .texi was, because we do not (currently) attempt to generate indexes for the commands, events and data types being documented.

As the GA ref is now part of the Sphinx 'interop' manual, we can delete the direct link from index.html.in.

Quoted 11 lines
---
 Makefile                      | 41 ++++++++----------
 MAINTAINERS                   |  2 +-
 docs/index.html.in            |  1 -
 docs/interop/conf.py          |  2 +
 docs/interop/index.rst        |  1 +
 docs/interop/qemu-ga-ref.rst  |  4 ++
 docs/interop/qemu-ga-ref.texi | 80 -----------------------------------
 7 files changed, 25 insertions(+), 106 deletions(-)
 create mode 100644 docs/interop/qemu-ga-ref.rst
 delete mode 100644 docs/interop/qemu-ga-ref.texi

r~

#23 lore raw

PATCH v4 9/18 docs/interop: Convert qemu-qmp-ref to rST

In reply to Peter Maydell

Convert qemu-qmp-ref to rST format. This includes dropping the plain-text, pdf and info format outputs for this document; as with all our other Sphinx-based documentation, we provide HTML and manpage only.

The qemu-qmp-ref.rst is somewhat more stripped down than the .texi was, because we do not (currently) attempt to generate indexes for the commands, events and data types being documented.

Again, we drop the direct link from index.html.in now that the QMP ref is part of the interop manual.

This commit removes the 'info', 'txt' and 'pdf' Makefile targets, because we no longer generate any documentation except for the Sphinx HTML manuals and the manpages.

---
 Makefile                       | 39 ++++-------------
 docs/index.html.in             |  1 -
 docs/interop/conf.py           |  2 +
 docs/interop/index.rst         |  1 +
 docs/interop/qemu-qmp-ref.rst  |  4 ++
 docs/interop/qemu-qmp-ref.texi | 80 ----------------------------------
 6 files changed, 16 insertions(+), 111 deletions(-)
 create mode 100644 docs/interop/qemu-qmp-ref.rst
 delete mode 100644 docs/interop/qemu-qmp-ref.texi
Makefile +9 -30
index 14780878fad..6dcc39efcee 100644
@@ -126,7 +126,6 @@ GENERATED_QAPI_FILES += qapi/qapi-events.h qapi/qapi-events.c
 GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.h)
 GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.c)
 GENERATED_QAPI_FILES += qapi/qapi-introspect.c qapi/qapi-introspect.h
-GENERATED_QAPI_FILES += qapi/qapi-doc.texi
 
 generated-files-y += $(GENERATED_QAPI_FILES)
 
@@ -352,7 +351,6 @@ ifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
 DOCS+=$(MANUAL_BUILDDIR)/tools/virtiofsd.1
 endif
 DOCS+=$(MANUAL_BUILDDIR)/system/qemu-block-drivers.7
-DOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7
 DOCS+=$(MANUAL_BUILDDIR)/interop/qemu-ga-ref.7
 DOCS+=$(MANUAL_BUILDDIR)/system/qemu-cpu-models.7
 DOCS+=$(MANUAL_BUILDDIR)/index.html
@@ -628,8 +626,7 @@ $(SRC_PATH)/scripts/qapi-gen.py
 qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h \
 qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h \
 qga/qapi-generated/qga-qapi-commands.h qga/qapi-generated/qga-qapi-commands.c \
-qga/qapi-generated/qga-qapi-init-commands.h qga/qapi-generated/qga-qapi-init-commands.c \
-qga/qapi-generated/qga-qapi-doc.texi: \
+qga/qapi-generated/qga-qapi-init-commands.h qga/qapi-generated/qga-qapi-init-commands.c: \
 qga/qapi-generated/qapi-gen-timestamp ;
 qga/qapi-generated/qapi-gen-timestamp: $(SRC_PATH)/qga/qapi-schema.json $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
@@ -771,11 +768,6 @@ distclean: clean
 	rm -f config.log
 	rm -f linux-headers/asm
 	rm -f docs/version.texi
-	rm -f docs/interop/qemu-qmp-qapi.texi
-	rm -f docs/interop/qemu-qmp-ref.7
-	rm -f docs/interop/qemu-qmp-ref.txt
-	rm -f docs/interop/qemu-qmp-ref.pdf
-	rm -f docs/interop/qemu-qmp-ref.html
 	rm -rf .doctrees
 	$(call clean-manual,devel)
 	$(call clean-manual,interop)
@@ -830,7 +822,7 @@ endif
 # and also any sphinx-built manpages.
 define install-manual =
 for d in $$(cd $(MANUAL_BUILDDIR) && find $1 -type d); do $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/$$d"; done
-for f in $$(cd $(MANUAL_BUILDDIR) && find $1 -type f -a '!' '(' -name '*.[0-9]' -o -name 'qemu-*-qapi.*' -o -name 'qemu-qmp-ref.*' ')' ); do $(INSTALL_DATA) "$(MANUAL_BUILDDIR)/$$f" "$(DESTDIR)$(qemu_docdir)/$$f"; done
+for f in $$(cd $(MANUAL_BUILDDIR) && find $1 -type f -a '!' -name '*.[0-9]'); do $(INSTALL_DATA) "$(MANUAL_BUILDDIR)/$$f" "$(DESTDIR)$(qemu_docdir)/$$f"; done
 endef
 
 # Note that we deliberately do not install the "devel" manual: it is
@@ -846,13 +838,11 @@ install-sphinxdocs: sphinxdocs
 install-doc: $(DOCS) install-sphinxdocs
 	$(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
 	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/index.html "$(DESTDIR)$(qemu_docdir)"
-	$(INSTALL_DATA) docs/interop/qemu-qmp-ref.html "$(DESTDIR)$(qemu_docdir)"
-	$(INSTALL_DATA) docs/interop/qemu-qmp-ref.txt "$(DESTDIR)$(qemu_docdir)"
 ifdef CONFIG_POSIX
 	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
 	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu.1 "$(DESTDIR)$(mandir)/man1"
 	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7"
-	$(INSTALL_DATA) docs/interop/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7"
+	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/interop/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7"
 	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-block-drivers.7 "$(DESTDIR)$(mandir)/man7"
 	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-cpu-models.7 "$(DESTDIR)$(mandir)/man7"
 ifeq ($(CONFIG_TOOLS),y)
@@ -1058,7 +1048,7 @@ endef
 $(MANUAL_BUILDDIR)/devel/index.html: $(call manual-deps,devel)
 	$(call build-manual,devel,html)
 
-$(MANUAL_BUILDDIR)/interop/index.html: $(call manual-deps,interop) $(SRC_PATH)/qga/qapi-schema.json $(qapi-py)
+$(MANUAL_BUILDDIR)/interop/index.html: $(call manual-deps,interop) $(SRC_PATH)/qga/qapi-schema.json $(qapi-modules) $(qapi-py)
 	$(call build-manual,interop,html)
 
 $(MANUAL_BUILDDIR)/specs/index.html: $(call manual-deps,specs)
@@ -1074,9 +1064,9 @@ $(MANUAL_BUILDDIR)/user/index.html: $(call manual-deps,user)
 	$(call build-manual,user,html)
 
 $(call define-manpage-rule,interop,\
-       qemu-ga.8 qemu-ga-ref.7,\
+       qemu-ga.8 qemu-ga-ref.7 qemu-qmp-ref.7,\
        $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/qga/qapi-schema.json \
-       $(qapi-py))
+       $(qapi-modules) $(qapi-py))
 
 $(call define-manpage-rule,system,qemu.1 qemu-block-drivers.7 qemu-cpu-models.7)
 
@@ -1090,18 +1080,7 @@ $(MANUAL_BUILDDIR)/index.html: $(SRC_PATH)/docs/index.html.in qemu-version.h
 	$(call quiet-command, sed "s|@@VERSION@@|${VERSION}|g" $< >$@, \
              "GEN","$@")
 
-docs/interop/qemu-qmp-qapi.texi: qapi/qapi-doc.texi
-	@cp -p $< $@
-
-html: docs/interop/qemu-qmp-ref.html sphinxdocs
-info: docs/interop/qemu-qmp-ref.info
-pdf: docs/interop/qemu-qmp-ref.pdf
-txt: docs/interop/qemu-qmp-ref.txt
-
-docs/interop/qemu-qmp-ref.dvi docs/interop/qemu-qmp-ref.html \
-    docs/interop/qemu-qmp-ref.info docs/interop/qemu-qmp-ref.pdf \
-    docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7: \
-	docs/interop/qemu-qmp-ref.texi docs/interop/qemu-qmp-qapi.texi
+html: sphinxdocs
 
 $(filter %.1 %.7 %.8,$(DOCS)): scripts/texi2pod.pl
 
@@ -1225,8 +1204,8 @@ endif
 	@echo  '  vm-help         - Help about targets running tests inside VM'
 	@echo  ''
 	@echo  'Documentation targets:'
-	@echo  '  html info pdf txt'
-	@echo  '                  - Build documentation in specified format'
+	@echo  '  html'
+	@echo  '                  - Build HTML documentation'
 ifdef CONFIG_GCOV
 	@echo  '  coverage-report - Create code coverage report'
 endif
docs/index.html.in +0 -1
index f180770b052..b3dfb7a4611 100644
@@ -12,7 +12,6 @@
             <li><a href="tools/index.html">Tools Guide</a></li>
             <li><a href="interop/index.html">System Emulation Management and Interoperability Guide</a></li>
             <li><a href="specs/index.html">System Emulation Guest Hardware Specifications</a></li>
-            <li><a href="qemu-qmp-ref.html">QMP Reference Manual</a></li>
         </ul>
     </body>
 </html>
docs/interop/conf.py +2 -0
index e83632e0108..43de386d33d 100644
@@ -21,4 +21,6 @@ man_pages = [
      ['Michael Roth <[email protected]>'], 8),
     ('qemu-ga-ref', 'qemu-ga-ref', u'QEMU Guest Agent Protocol Reference',
      [], 7),
+    ('qemu-qmp-ref', 'qemu-qmp-ref', u'QEMU QMP Reference Manual',
+     [], 7),
 ]
docs/interop/index.rst +1 -0
index f3af38dce17..2cd97c6ff42 100644
@@ -19,5 +19,6 @@ Contents:
    pr-helper
    qemu-ga
    qemu-ga-ref
+   qemu-qmp-ref
    vhost-user
    vhost-user-gpu
docs/interop/qemu-qmp-ref.rst new file +4 -0
new file mode 100644
index 00000000000..e640903abaf
@@ -0,0 +1,4 @@
+QEMU QMP Reference Manual
+=========================
+
+.. qapi-doc:: qapi/qapi-schema.json
docs/interop/qemu-qmp-ref.texi deleted +0 -80

80 lines not on this page · raw message

Signature · 1 line
2.20.1
Reviewed-by on v4 9/18
#24 lore raw

Re: [PATCH v4 09/18] docs/interop: Convert qemu-qmp-ref to rST

Quoted 18 lines · Peter Maydell

Convert qemu-qmp-ref to rST format. This includes dropping the plain-text, pdf and info format outputs for this document; as with all our other Sphinx-based documentation, we provide HTML and manpage only.

The qemu-qmp-ref.rst is somewhat more stripped down than the .texi was, because we do not (currently) attempt to generate indexes for the commands, events and data types being documented.

Again, we drop the direct link from index.html.in now that the QMP ref is part of the interop manual.

This commit removes the 'info', 'txt' and 'pdf' Makefile targets, because we no longer generate any documentation except for the Sphinx HTML manuals and the manpages.

Quoted 10 lines
---
 Makefile                       | 39 ++++-------------
 docs/index.html.in             |  1 -
 docs/interop/conf.py           |  2 +
 docs/interop/index.rst         |  1 +
 docs/interop/qemu-qmp-ref.rst  |  4 ++
 docs/interop/qemu-qmp-ref.texi | 80 ----------------------------------
 6 files changed, 16 insertions(+), 111 deletions(-)
 create mode 100644 docs/interop/qemu-qmp-ref.rst
 delete mode 100644 docs/interop/qemu-qmp-ref.texi

r~

#25 lore raw

PATCH v4 10/18 qapi: Use rST markup for literal blocks

In reply to Peter Maydell

There are exactly two places in our json doc comments where we use the markup accepted by the texi doc generator where a '|' in the first line of a doc comment means the line should be emitted as a literal block (fixed-width font, whitespace preserved).

Since we use this syntax so rarely, instead of making the rST generator support it, instead just convert the two uses to rST-format literal blocks, which are indented and introduced with '::'.

(The rST generator doesn't complain about the old style syntax, it just emits it with the '|' and with the whitespace not preserved, which looks odd, but means we can safely leave this change until after we've stopped generating texinfo.)

---
 qapi/block-core.json  | 16 +++++++++-------
 qapi/qapi-schema.json |  6 ++++--
 2 files changed, 13 insertions(+), 9 deletions(-)
qapi/block-core.json +9 -7
index 85e27bb61f4..0c9c21927f9 100644
@@ -550,13 +550,15 @@
 #        For the example above, @bins may be something like [3, 1, 5, 2],
 #        and corresponding histogram looks like:
 #
-# |      5|           *
-# |      4|           *
-# |      3| *         *
-# |      2| *         *    *
-# |      1| *    *    *    *
-# |       +------------------
-# |           10   50   100
+# ::
+#
+#        5|           *
+#        4|           *
+#        3| *         *
+#        2| *         *    *
+#        1| *    *    *    *
+#         +------------------
+#             10   50   100
 #
 # Since: 4.0
 ##
qapi/qapi-schema.json +4 -2
index ff5aea59451..440fece703f 100644
@@ -22,8 +22,10 @@
 #
 # Example:
 #
-# | -> data issued by the Client
-# | <- Server data response
+# ::
+#
+#   -> data issued by the Client
+#   <- Server data response
 #
 # Please, refer to the QMP specification (docs/interop/qmp-spec.txt) for
 # detailed information on the Server command and response formats.
Signature · 1 line
2.20.1
Reviewed-by on v4 10/18
#26 lore raw

Re: [PATCH v4 10/18] qapi: Use rST markup for literal blocks

Quoted 15 lines · Peter Maydell

There are exactly two places in our json doc comments where we use the markup accepted by the texi doc generator where a '|' in the first line of a doc comment means the line should be emitted as a literal block (fixed-width font, whitespace preserved).

Since we use this syntax so rarely, instead of making the rST generator support it, instead just convert the two uses to rST-format literal blocks, which are indented and introduced with '::'.

(The rST generator doesn't complain about the old style syntax, it just emits it with the '|' and with the whitespace not preserved, which looks odd, but means we can safely leave this change until after we've stopped generating texinfo.)

Quoted 5 lines
---
 qapi/block-core.json  | 16 +++++++++-------
 qapi/qapi-schema.json |  6 ++++--
 2 files changed, 13 insertions(+), 9 deletions(-)

r~

#27 lore raw

PATCH v4 11/18 qga/qapi-schema.json: Add some headings

In reply to Peter Maydell

Add some section headings to the QGA json; this is purely so that we have some H1 headings, as otherwise each command ends up being visible in the interop/ manual's table of contents. In an ideal world there might be a proper 'Introduction' section the way there is in qapi/qapi-schema.json.

---
 qga/qapi-schema.json | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
qga/qapi-schema.json +8 -4
index f6fcb59f34b..d026f9478cf 100644
@@ -1,14 +1,18 @@
 # *-*- Mode: Python -*-*
 
 ##
-#
-# General note concerning the use of guest agent interfaces:
-#
+# = General note concerning the use of guest agent interfaces
+##
+
+##
 # "unsupported" is a higher-level error than the errors that individual
 # commands might document. The caller should always be prepared to receive
 # QERR_UNSUPPORTED, even if the given command doesn't specify it, or doesn't
 # document any failure mode at all.
-#
+##
+
+##
+# = QEMU guest agent protocol commands and structs
 ##
 
 { 'pragma': { 'doc-required': true } }
Signature · 1 line
2.20.1
Reviewed-by on v4 11/18
#28 lore raw

Re: [PATCH v4 11/18] qga/qapi-schema.json: Add some headings

Quoted 10 lines · Peter Maydell

Add some section headings to the QGA json; this is purely so that we have some H1 headings, as otherwise each command ends up being visible in the interop/ manual's table of contents. In an ideal world there might be a proper 'Introduction' section the way there is in qapi/qapi-schema.json.

---
 qga/qapi-schema.json | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

r~

#29 lore raw

PATCH v4 12/18 scripts/qapi: Remove texinfo generation support

In reply to Peter Maydell

We no longer use the generated texinfo format documentation, so delete the code that generates it, and the test case for the generation.

---
 Makefile                        |   1 -
 tests/Makefile.include          |  15 +-
 scripts/qapi-gen.py             |   2 -
 scripts/qapi/doc.py             | 302 --------------------------------
 scripts/qapi/gen.py             |   7 -
 tests/qapi-schema/doc-good.texi | 281 -----------------------------
 6 files changed, 1 insertion(+), 607 deletions(-)
 delete mode 100644 scripts/qapi/doc.py
 delete mode 100644 tests/qapi-schema/doc-good.texi
Makefile +0 -1
index 6dcc39efcee..98f58b84ef0 100644
@@ -610,7 +610,6 @@ qemu-keymap$(EXESUF): QEMU_CFLAGS += $(XKBCOMMON_CFLAGS)
 qapi-py = $(SRC_PATH)/scripts/qapi/__init__.py \
 $(SRC_PATH)/scripts/qapi/commands.py \
 $(SRC_PATH)/scripts/qapi/common.py \
-$(SRC_PATH)/scripts/qapi/doc.py \
 $(SRC_PATH)/scripts/qapi/error.py \
 $(SRC_PATH)/scripts/qapi/events.py \
 $(SRC_PATH)/scripts/qapi/expr.py \
tests/Makefile.include +1 -14
index edcbd475aa7..ee84107e1be 100644
@@ -32,7 +32,6 @@ export SRC_PATH
 qapi-py = $(SRC_PATH)/scripts/qapi/__init__.py \
 $(SRC_PATH)/scripts/qapi/commands.py \
 $(SRC_PATH)/scripts/qapi/common.py \
-$(SRC_PATH)/scripts/qapi/doc.py \
 $(SRC_PATH)/scripts/qapi/error.py \
 $(SRC_PATH)/scripts/qapi/events.py \
 $(SRC_PATH)/scripts/qapi/expr.py \
@@ -488,16 +487,8 @@ tests/test-qapi-gen-timestamp: \
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
 		-o tests -p "test-" $<, \
 		"GEN","$(@:%-timestamp=%)")
-	@rm -f tests/test-qapi-doc.texi
 	@>$@
 
-tests/qapi-schema/doc-good.test.texi: $(SRC_PATH)/tests/qapi-schema/doc-good.json $(qapi-py)
-	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
-		-o tests/qapi-schema -p "doc-good-" $<, \
-		"GEN","$@")
-	@mv tests/qapi-schema/doc-good-qapi-doc.texi $@
-	@rm -f tests/qapi-schema/doc-good-qapi-*.[ch] tests/qapi-schema/doc-good-qmp-*.[ch]
-
 tests/qtest/dbus-vmstate1.h tests/qtest/dbus-vmstate1.c: tests/qtest/dbus-vmstate1-gen-timestamp ;
 tests/qtest/dbus-vmstate1-gen-timestamp: $(SRC_PATH)/tests/qtest/dbus-vmstate1.xml
 	$(call quiet-command,$(GDBUS_CODEGEN) $< \
@@ -849,10 +840,6 @@ check-tests/qapi-schema/frontend: $(addprefix $(SRC_PATH)/, $(check-qapi-schema-
 	  PYTHONIOENCODING=utf-8 $(PYTHON) $(SRC_PATH)/tests/qapi-schema/test-qapi.py $^, \
 	  TEST, check-qapi-schema)
 
-.PHONY: check-tests/qapi-schema/doc-good.texi
-check-tests/qapi-schema/doc-good.texi: tests/qapi-schema/doc-good.test.texi
-	@diff -u $(SRC_PATH)/tests/qapi-schema/doc-good.texi $<
-
 .PHONY: check-decodetree
 check-decodetree:
 	$(call quiet-command, \
@@ -900,7 +887,7 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR)
 # Consolidated targets
 
 .PHONY: check-block check-qapi-schema check-qtest check-unit check check-clean
-check-qapi-schema: check-tests/qapi-schema/frontend check-tests/qapi-schema/doc-good.texi
+check-qapi-schema: check-tests/qapi-schema/frontend
 check-qtest: $(patsubst %,check-qtest-%, $(QTEST_TARGETS))
 ifeq ($(CONFIG_TOOLS),y)
 check-block: $(patsubst %,check-%, $(check-block-y))
scripts/qapi-gen.py +0 -2
index 4b03f7d53be..541e8c1f55d 100755
@@ -10,7 +10,6 @@ import re
 import sys
 
 from qapi.commands import gen_commands
-from qapi.doc import gen_doc
 from qapi.events import gen_events
 from qapi.introspect import gen_introspect
 from qapi.schema import QAPIError, QAPISchema
@@ -51,7 +50,6 @@ def main(argv):
     gen_commands(schema, args.output_dir, args.prefix)
     gen_events(schema, args.output_dir, args.prefix)
     gen_introspect(schema, args.output_dir, args.prefix, args.unmask)
-    gen_doc(schema, args.output_dir, args.prefix)
 
 
 if __name__ == '__main__':
scripts/qapi/doc.py deleted +0 -302

302 lines not on this page · raw message

scripts/qapi/gen.py +0 -7
index 33690bfa3bd..acb97cd61e1 100644
@@ -173,13 +173,6 @@ def ifcontext(ifcond, *args):
         arg.end_if()
 
 
-class QAPIGenDoc(QAPIGen):
-
-    def _top(self):
-        return (super()._top()
-                + '@c AUTOMATICALLY GENERATED, DO NOT MODIFY\n\n')
-
-
 class QAPISchemaMonolithicCVisitor(QAPISchemaVisitor):
 
     def __init__(self, prefix, what, blurb, pydoc):
tests/qapi-schema/doc-good.texi deleted +0 -281

281 lines not on this page · raw message

Signature · 1 line
2.20.1
Reviewed-by on v4 12/18
#30 lore raw

Re: [PATCH v4 12/18] scripts/qapi: Remove texinfo generation support

Quoted 5 lines · Peter Maydell

We no longer use the generated texinfo format documentation, so delete the code that generates it, and the test case for the generation.

Quoted 10 lines
---
 Makefile                        |   1 -
 tests/Makefile.include          |  15 +-
 scripts/qapi-gen.py             |   2 -
 scripts/qapi/doc.py             | 302 --------------------------------
 scripts/qapi/gen.py             |   7 -
 tests/qapi-schema/doc-good.texi | 281 -----------------------------
 6 files changed, 1 insertion(+), 607 deletions(-)
 delete mode 100644 scripts/qapi/doc.py
 delete mode 100644 tests/qapi-schema/doc-good.texi

r~

#31 lore raw

PATCH v4 13/18 docs/devel/qapi-code-gen.txt: Update to new rST backend conventions

In reply to Peter Maydell

Update the documentation of QAPI document comment syntax to match the new rST backend requirements. The principal changes are:
* whitespace is now significant, and multiline definitions must have their second and subsequent lines indented to match the first line
* general rST format markup is permitted, not just the small set of markup the old texinfo generator handled. For most things (notably bulleted and itemized lists) the old format is the same as rST was.
* Specific things that might trip people up:
- instead of *bold* and _italic_ rST has **bold** and *italic*
- lists need a preceding and following blank line
- a lone literal '*' will need to be backslash-escaped to avoid a rST syntax error
* the old leading '|' for example (literal text) blocks is replaced by the standard rST '::' literal block.
* headings and subheadings must now be in a freeform documentation comment of their own
* we support arbitrary levels of sub- and sub-sub-heading, not just a main and sub-heading like the old texinfo generator

---
 docs/devel/qapi-code-gen.txt | 90 ++++++++++++++++++++++++------------
 1 file changed, 61 insertions(+), 29 deletions(-)
docs/devel/qapi-code-gen.txt +61 -29
index 59d6973e1ec..688eb2a0237 100644
@@ -795,21 +795,39 @@ See below for more on definition documentation.
 Free-form documentation may be used to provide additional text and
 structuring content.
 
+==== Headings and subheadings ====
+
+A free-form documentation comment containing a single line
+which starts with some '=' symbols and then a space defines
+a section heading:
+
+    ##
+    # = This is a top level heading
+    ##
+
+    ##
+    # This is a free-form comment which will go under the
+    # top level heading.
+    ##
+
+    ##
+    # == This is a second level heading
+    ##
+
+Section headings must always be correctly nested, so you can only
+define a third-level heading inside a second-level heading, and so
+on. The documentation generator will catch nesting mistakes and report
+a syntax error.
 
 ==== Documentation markup ====
 
-Comment text starting with '=' is a section title:
+Documentation comments can use most rST markup. In particular,
+a '::' literal block can be used for examples:
 
-    # = Section title
-
-Double the '=' for a subsection title:
-
-    # == Subsection title
-
-'|' denotes examples:
-
-    # | Text of the example, may span
-    # | multiple lines
+    # ::
+    #
+    #   Text of the example, may span
+    #   multiple lines
 
 '*' starts an itemized list:
 
@@ -825,37 +843,35 @@ A decimal number followed by '.' starts a numbered list:
     #    multiple lines
     # 2. Second item
 
-The actual number doesn't matter.  You could even use '*' instead of
-'2.' for the second item.
+The actual number doesn't matter.
 
-Lists can't be nested.  Blank lines are currently not supported within
-lists.
+Lists of either kind must be preceded and followed by a blank line.
+If a list item's text spans multiple lines, then the second and
+subsequent lines must be correctly indented to line up with the
+first character of the first line.
 
-Additional whitespace between the initial '#' and the comment text is
-permitted.
-
-*foo* and _foo_ are for strong and emphasis styles respectively (they
-do not work over multiple lines).  @foo is used to reference a name in
-the schema.
+The usual '**strong**', '*emphasised*' and '``literal``' markup should
+be used. If you need a single literal '*' you will need to backslash-escape it.
+As an extension beyond the usual rST syntax, you can also
+use '@foo' to reference a name in the schema; this is rendered
+the same way as '``foo``'.
 
 Example:
 
 ##
-# = Section
-# == Subsection
-#
-# Some text foo with *strong* and _emphasis_
+# Some text foo with **bol** and *emphasis*
 # 1. with a list
 # 2. like that
 #
 # And some code:
-# | $ echo foo
-# | -> do this
-# | <- get that
 #
+# ::
+#
+#   $ echo foo
+#   -> do this
+#   <- get that
 ##
 
-
 ==== Definition documentation ====
 
 Definition documentation, if present, must immediately precede the
@@ -870,6 +886,12 @@ commands and events), member (for structs and unions), branch (for
 alternates), or value (for enums), and finally optional tagged
 sections.
 
+Descriptions of arguments can span multiple lines; if they
+do then the second and subsequent lines must be indented
+to line up with the first character of the first line of the
+description. The parser will report a syntax error if there
+is insufficient indentation.
+
 FIXME: the parser accepts these things in almost any order.
 FIXME: union branches should be described, too.
 
@@ -883,6 +905,16 @@ The section ends with the start of a new section.
 A 'Since: x.y.z' tagged section lists the release that introduced the
 definition.
 
+The text of a section can start on a new line, in
+which case it must not be indented at all. It can also start
+on the same line as the 'Note:', 'Returns:', etc tag. In this
+case if it spans multiple lines then second and subsequent
+lines must be indented to match the first.
+
+An 'Example' or 'Examples' section is automatically rendered
+entirely as literal fixed-width text. In other sections,
+the text is formatted, and rST markup can be used.
+
 For example:
 
 ##
Signature · 1 line
2.20.1
Reviewed-by on v4 13/18
#32 lore raw

Re: [PATCH v4 13/18] docs/devel/qapi-code-gen.txt: Update to new rST backend conventions

Quoted 21 lines · Peter Maydell

Update the documentation of QAPI document comment syntax to match the new rST backend requirements. The principal changes are:
* whitespace is now significant, and multiline definitions must have their second and subsequent lines indented to match the first line
* general rST format markup is permitted, not just the small set of markup the old texinfo generator handled. For most things (notably bulleted and itemized lists) the old format is the same as rST was.
* Specific things that might trip people up:
- instead of *bold* and _italic_ rST has **bold** and *italic*
- lists need a preceding and following blank line
- a lone literal '*' will need to be backslash-escaped to avoid a rST syntax error
* the old leading '|' for example (literal text) blocks is replaced by the standard rST '::' literal block.
* headings and subheadings must now be in a freeform documentation comment of their own
* we support arbitrary levels of sub- and sub-sub-heading, not just a main and sub-heading like the old texinfo generator

Quoted 4 lines
---
 docs/devel/qapi-code-gen.txt | 90 ++++++++++++++++++++++++------------
 1 file changed, 61 insertions(+), 29 deletions(-)

r~

#33 lore raw

PATCH v4 14/18 Makefile: Remove redundant Texinfo related rules

In reply to Peter Maydell

We now don't build anything from Texinfo, so we can remove some redundant Makefile pattern rules and the rule for generating the version.texi file that used to be included from many Texinfo source files.

---
 Makefile  | 31 +------------------------------
 rules.mak | 14 +-------------
 2 files changed, 2 insertions(+), 43 deletions(-)
Makefile +1 -30
index 98f58b84ef0..36fe8d6e641 100644
@@ -732,8 +732,7 @@ clean: recurse-clean
 		! -path ./roms/edk2/BaseTools/Source/Python/UPT/Dll/sqlite3.dll \
 		-exec rm {} +
 	rm -f $(edk2-decompressed)
-	rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) TAGS cscope.* *.pod *~ */*~
-	rm -f fsdev/*.pod scsi/*.pod
+	rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) TAGS cscope.* *~ */*~
 	rm -f qemu-img-cmds.h
 	rm -f ui/shader/*-vert.h ui/shader/*-frag.h
 	@# May not be present in generated-files-y
@@ -766,7 +765,6 @@ distclean: clean
 	rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
 	rm -f config.log
 	rm -f linux-headers/asm
-	rm -f docs/version.texi
 	rm -rf .doctrees
 	$(call clean-manual,devel)
 	$(call clean-manual,interop)
@@ -987,31 +985,6 @@ ui/shader.o: $(SRC_PATH)/ui/shader.c \
 	ui/shader/texture-blit-frag.h
 
 # documentation
-MAKEINFO=makeinfo
-MAKEINFOINCLUDES= -I docs -I $(<D) -I $(@D)
-MAKEINFOFLAGS=--no-split --number-sections $(MAKEINFOINCLUDES)
-TEXI2PODFLAGS=$(MAKEINFOINCLUDES) -DVERSION="$(VERSION)" -DCONFDIR="$(qemu_confdir)"
-TEXI2PDFFLAGS=$(if $(V),,--quiet) -I $(SRC_PATH) $(MAKEINFOINCLUDES)
-
-docs/version.texi: $(SRC_PATH)/VERSION config-host.mak
-	$(call quiet-command,(\
-		echo "@set VERSION $(VERSION)" && \
-		echo "@set CONFDIR $(qemu_confdir)" \
-	)> $@,"GEN","$@")
-
-%.html: %.texi docs/version.texi
-	$(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
-	--html $< -o $@,"GEN","$@")
-
-%.info: %.texi docs/version.texi
-	$(call quiet-command,$(MAKEINFO) $(MAKEINFOFLAGS) $< -o $@,"GEN","$@")
-
-%.txt: %.texi docs/version.texi
-	$(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
-	--plaintext $< -o $@,"GEN","$@")
-
-%.pdf: %.texi docs/version.texi
-	$(call quiet-command,texi2pdf $(TEXI2PDFFLAGS) $< -o $@,"GEN","$@")
 
 # Sphinx builds all its documentation at once in one invocation
 # and handles "don't rebuild things unless necessary" itself.
@@ -1081,8 +1054,6 @@ $(MANUAL_BUILDDIR)/index.html: $(SRC_PATH)/docs/index.html.in qemu-version.h
 
 html: sphinxdocs
 
-$(filter %.1 %.7 %.8,$(DOCS)): scripts/texi2pod.pl
-
 # Reports/Analysis
 
 %/coverage-report.html:
rules.mak +1 -13
index e39b073d464..00d323a071a 100644
@@ -144,7 +144,7 @@ cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \
 cc-c-option = $(if $(shell $(CC) $1 $2 -c -o /dev/null -xc /dev/null \
                 >/dev/null 2>&1 && echo OK), $2, $3)
 
-VPATH_SUFFIXES = %.c %.h %.S %.cc %.cpp %.m %.mak %.texi %.sh %.rc Kconfig% %.json.in
+VPATH_SUFFIXES = %.c %.h %.S %.cc %.cpp %.m %.mak %.sh %.rc Kconfig% %.json.in
 set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1)))
 
 # install-prog list, dir
@@ -381,18 +381,6 @@ define unnest-vars
         $(eval $v := $(filter-out %/,$($v))))
 endef
 
-TEXI2MAN = $(call quiet-command, \
-	perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $(TEXI2PODFLAGS) $< [email protected] && \
-	$(POD2MAN) --section=$(subst .,,$(suffix $@)) --center=" " --release=" " [email protected] > $@, \
-	"GEN","$@")
-
-%.1:
-	$(call TEXI2MAN)
-%.7:
-	$(call TEXI2MAN)
-%.8:
-	$(call TEXI2MAN)
-
 GEN_SUBST = $(call quiet-command, \
 	sed -e "s!@libexecdir@!$(libexecdir)!g" < $< > $@, \
 	"GEN","$@")
Signature · 1 line
2.20.1
Reviewed-by on v4 14/18
#34 lore raw

Re: [PATCH v4 14/18] Makefile: Remove redundant Texinfo related rules

Quoted 10 lines · Peter Maydell

We now don't build anything from Texinfo, so we can remove some redundant Makefile pattern rules and the rule for generating the version.texi file that used to be included from many Texinfo source files.

---
 Makefile  | 31 +------------------------------
 rules.mak | 14 +-------------
 2 files changed, 2 insertions(+), 43 deletions(-)

r~

#35 lore raw

PATCH v4 15/18 scripts/texi2pod: Delete unused script

In reply to Peter Maydell

We no longer need the texi2pod script, so we can delete it, and the special-casing it had in the checkpatch script.

---
 scripts/checkpatch.pl |   2 +-
 scripts/texi2pod.pl   | 536 ------------------------------------------
 2 files changed, 1 insertion(+), 537 deletions(-)
 delete mode 100755 scripts/texi2pod.pl
scripts/checkpatch.pl +1 -1
index b27e4ff5e95..701f76a6ccc 100755
@@ -1631,7 +1631,7 @@ sub process {
 # tabs are only allowed in assembly source code, and in
 # some scripts we imported from other projects.
 		next if ($realfile =~ /\.(s|S)$/);
-		next if ($realfile =~ /(checkpatch|get_maintainer|texi2pod)\.pl$/);
+		next if ($realfile =~ /(checkpatch|get_maintainer)\.pl$/);
 
 		if ($rawline =~ /^\+.*\t/) {
 			my $herevet = "$here\n" . cat_vet($rawline) . "\n";
scripts/texi2pod.pl deleted +0 -536

536 lines not on this page · raw message

Signature · 1 line
2.20.1
Reviewed-by on v4 15/18
#36 lore raw

Re: [PATCH v4 15/18] scripts/texi2pod: Delete unused script

Quoted 9 lines · Peter Maydell

We no longer need the texi2pod script, so we can delete it, and the special-casing it had in the checkpatch script.

---
 scripts/checkpatch.pl |   2 +-
 scripts/texi2pod.pl   | 536 ------------------------------------------
 2 files changed, 1 insertion(+), 537 deletions(-)
 delete mode 100755 scripts/texi2pod.pl

r~

#37 lore raw

PATCH v4 16/18 Remove Texinfo related files from .gitignore and git.orderfile

In reply to Peter Maydell

We don't use Texinfo any more; we can remove the references to the .texi source files and the generated output files from our .gitignore and git.orderfile.

---
 .gitignore            | 15 ---------------
 scripts/git.orderfile |  1 -
 2 files changed, 16 deletions(-)
.gitignore +0 -15
index 0c5af83aa74..920d523f40d 100644
@@ -45,20 +45,15 @@
 /qapi/qapi-visit-*.[ch]
 !/qapi/qapi-visit-core.c
 /qapi/qapi-visit.[ch]
-/qapi/qapi-doc.texi
 /qemu-edid
 /qemu-img
 /qemu-nbd
 /qemu-options.def
-/qemu-options.texi
-/qemu-img-cmds.texi
 /qemu-img-cmds.h
 /qemu-io
 /qemu-ga
 /qemu-bridge-helper
 /qemu-keymap
-/qemu-monitor.texi
-/qemu-monitor-info.texi
 /qemu-version.h
 /qemu-version.h.tmp
 /module_block.h
@@ -82,7 +77,6 @@
 *.ky
 *.log
 *.pdf
-*.pod
 *.cps
 *.fns
 *.kys
@@ -124,15 +118,6 @@
 /pc-bios/s390-ccw/s390-ccw.elf
 /pc-bios/s390-ccw/s390-ccw.img
 /docs/built
-/docs/interop/qemu-ga-qapi.texi
-/docs/interop/qemu-ga-ref.html
-/docs/interop/qemu-ga-ref.info*
-/docs/interop/qemu-ga-ref.txt
-/docs/interop/qemu-qmp-qapi.texi
-/docs/interop/qemu-qmp-ref.html
-/docs/interop/qemu-qmp-ref.info*
-/docs/interop/qemu-qmp-ref.txt
-/docs/version.texi
 /contrib/vhost-user-gpu/50-qemu-gpu.json
 *.tps
 .stgit-*
scripts/git.orderfile +0 -1
index 7cf22e0bf54..f69dff07dbc 100644
@@ -11,7 +11,6 @@
 
 # Documentation
 docs/*
-*.texi
 
 # build system
 configure
Signature · 1 line
2.20.1
Reviewed-by on v4 16/18
#38 lore raw

Re: [PATCH v4 16/18] Remove Texinfo related files from .gitignore and git.orderfile

Quoted 9 lines · Peter Maydell

We don't use Texinfo any more; we can remove the references to the .texi source files and the generated output files from our .gitignore and git.orderfile.

---
 .gitignore            | 15 ---------------
 scripts/git.orderfile |  1 -
 2 files changed, 16 deletions(-)

r~

#39 lore raw

PATCH v4 17/18 configure: Drop texinfo requirement

In reply to Peter Maydell

We don't need the texinfo and pod2man programs to build our documentation any more, so remove them from configure's tests.

---
 configure | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
configure +2 -10
index fab6281eb70..3b642136211 100755
@@ -4888,14 +4888,14 @@ if test "$docs" != "no" ; then
   else
     sphinx_ok=no
   fi
-  if has makeinfo && has pod2man && test "$sphinx_ok" = "yes"; then
+  if test "$sphinx_ok" = "yes"; then
     docs=yes
   else
     if test "$docs" = "yes" ; then
       if has $sphinx_build && test "$sphinx_ok" != "yes"; then
         echo "Warning: $sphinx_build exists but it is either too old or uses too old a Python version" >&2
       fi
-      feature_not_found "docs" "Install texinfo, Perl/perl-podlators and a Python 3 version of python-sphinx"
+      feature_not_found "docs" "Install a Python 3 version of python-sphinx"
     fi
     docs=no
   fi
@@ -6273,13 +6273,6 @@ if test "$solaris" = "no" ; then
     fi
 fi
 
-# test if pod2man has --utf8 option
-if pod2man --help | grep -q utf8; then
-    POD2MAN="pod2man --utf8"
-else
-    POD2MAN="pod2man"
-fi
-
 # Use ASLR, no-SEH and DEP if available
 if test "$mingw32" = "yes" ; then
     for flag in --dynamicbase --no-seh --nxcompat; do
@@ -7672,7 +7665,6 @@ echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
 echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
 echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
 echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
-echo "POD2MAN=$POD2MAN" >> $config_host_mak
 if test "$gcov" = "yes" ; then
   echo "CONFIG_GCOV=y" >> $config_host_mak
   echo "GCOV=$gcov_tool" >> $config_host_mak
Signature · 1 line
2.20.1
#41 lore raw

PATCH v4 18/18 Remove texinfo dependency from docker and CI configs

In reply to Peter Maydell

We don't need texinfo to build the docs any more, so we can drop that dependency from our docker and other CI configs.

---
 .travis.yml                                | 1 -
 tests/docker/dockerfiles/debian10.docker   | 1 -
 tests/docker/dockerfiles/debian9.docker    | 1 -
 tests/docker/dockerfiles/fedora.docker     | 1 -
 tests/docker/dockerfiles/ubuntu.docker     | 1 -
 tests/docker/dockerfiles/ubuntu1804.docker | 1 -
 6 files changed, 6 deletions(-)
.travis.yml +0 -1
index b92798ac3b9..71bee8d631c 100644
@@ -197,7 +197,6 @@ jobs:
         apt:
           packages:
             - python3-sphinx
-            - texinfo
             - perl
 
 
tests/docker/dockerfiles/debian10.docker +0 -1
index 5de79ae5527..f2744e18e5a 100644
@@ -29,5 +29,4 @@ RUN apt update && \
         psmisc \
         python3 \
         python3-sphinx \
-        texinfo \
         $(apt-get -s build-dep qemu | egrep ^Inst | fgrep '[all]' | cut -d\  -f2)
tests/docker/dockerfiles/debian9.docker +0 -1
index 8cbd742bb5f..f08442a436a 100644
@@ -28,5 +28,4 @@ RUN apt update && \
         psmisc \
         python3 \
         python3-sphinx \
-        texinfo \
         $(apt-get -s build-dep qemu | egrep ^Inst | fgrep '[all]' | cut -d\  -f2)
tests/docker/dockerfiles/fedora.docker +0 -1
index a6522228c02..db38d5e4c4a 100644
@@ -86,7 +86,6 @@ ENV PACKAGES \
     systemd-devel \
     systemtap-sdt-devel \
     tar \
-    texinfo \
     usbredir-devel \
     virglrenderer-devel \
     vte291-devel \
tests/docker/dockerfiles/ubuntu.docker +0 -1
index b6c7b41dddd..cfc55ed01c0 100644
@@ -63,7 +63,6 @@ ENV PACKAGES flex bison \
     python3-yaml \
     python3-sphinx \
     sparse \
-    texinfo \
     xfslibs-dev
 RUN apt-get update && \
     DEBIAN_FRONTEND=noninteractive apt-get -y install $PACKAGES
tests/docker/dockerfiles/ubuntu1804.docker +0 -1
index 1efedeef995..c265a952530 100644
@@ -49,7 +49,6 @@ ENV PACKAGES flex bison \
     python3-yaml \
     python3-sphinx \
     sparse \
-    texinfo \
     xfslibs-dev
 RUN apt-get update && \
     DEBIAN_FRONTEND=noninteractive apt-get -y install $PACKAGES
Signature · 1 line
2.20.1
Reviewed-by on v4 18/18
#42 lore raw

Re: [PATCH v4 18/18] Remove texinfo dependency from docker and CI configs

Quoted 4 lines · Peter Maydell

We don't need texinfo to build the docs any more, so we can drop that dependency from our docker and other CI configs.

Quoted 8 lines
---
 .travis.yml                                | 1 -
 tests/docker/dockerfiles/debian10.docker   | 1 -
 tests/docker/dockerfiles/debian9.docker    | 1 -
 tests/docker/dockerfiles/fedora.docker     | 1 -
 tests/docker/dockerfiles/ubuntu.docker     | 1 -
 tests/docker/dockerfiles/ubuntu1804.docker | 1 -
 6 files changed, 6 deletions(-)

r~

#43 lore raw
In reply to Peter Maydell

I let this series slide to get my Error API rework done, along with much else. My sincere apologies!

Unsurprisingly, it needs a rebase now. I suggest to let me resume review first.