<feed xmlns='http://www.w3.org/2005/Atom'>
<title>qemu/scripts/qapi, branch master</title>
<subtitle>QEMU development tree</subtitle>
<id>https://git.zx2c4.com/qemu/atom/scripts/qapi?h=master</id>
<link rel='self' href='https://git.zx2c4.com/qemu/atom/scripts/qapi?h=master'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/'/>
<updated>2024-07-17T08:20:54Z</updated>
<entry>
<title>qapi: remove "Example" doc section</title>
<updated>2024-07-17T08:20:54Z</updated>
<author>
<name>John Snow</name>
<email>jsnow@redhat.com</email>
</author>
<published>2024-07-17T02:13:11Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=3c5f6114d9ffc70bc9b1a7cc0dddd72a911f966d'/>
<id>urn:sha1:3c5f6114d9ffc70bc9b1a7cc0dddd72a911f966d</id>
<content type='text'>
Fully eliminate the "Example" sections in QAPI doc blocks now that they
have all been converted to arbitrary rST syntax using the
".. qmp-example::" directive. Update tests to match.

Migrating to the new syntax
---------------------------

The old "Example:" or "Examples:" section syntax is now caught as an
error, but "Example::" is stil permitted as explicit rST syntax for an
un-lexed, generic preformatted text block.

('Example' is not special in this case, any sentence that ends with "::"
will start an indented code block in rST.)

Arbitrary rST for Examples is now possible, but it's strongly
recommended that documentation authors use the ".. qmp-example::"
directive for consistent visual formatting in rendered HTML docs. The
":title:" directive option may be used to add extra information into the
title bar for the example. The ":annotated:" option can be used to write
arbitrary rST instead, with nested "::" blocks applying QMP formatting
where desired.

Other choices available are ".. code-block:: QMP" which will not create
an "Example:" box, or the short-form "::" code-block syntax which will
not apply QMP highlighting when used outside of the qmp-example
directive.

Why?
----

This patch has several benefits:

1. Example sections can now be written more arbitrarily, mixing
   explanatory paragraphs and code blocks however desired.

2. Example sections can now use fully arbitrary rST.

3. All code blocks are now lexed and validated as QMP; increasing
   usability of the docs and ensuring validity of example snippets.

   (To some extent - This patch only gaurantees it lexes correctly, not
   that it's valid under the JSON or QMP grammars. It will catch most
   small mistakes, however.)

4. Each qmp-example can be titled or annotated independently without
   bypassing the QMP lexer/validator.

   (i.e. code blocks are now for *code* only, so we don't have to
   sacrifice exposition for having lexically valid examples.)

NOTE: As with the "Notes" conversion (d461c279737), this patch (and the
      three preceding) may change the rendering order for Examples in
      the current generator. The forthcoming qapidoc rewrite will fix
      this by always generating documentation in source order.

Signed-off-by: John Snow &lt;jsnow@redhat.com&gt;
Message-ID: &lt;20240717021312.606116-10-jsnow@redhat.com&gt;
Reviewed-by: Markus Armbruster &lt;armbru@redhat.com&gt;
Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
</content>
</entry>
<entry>
<title>qapi/parser: don't parse rST markup as section headers</title>
<updated>2024-07-06T06:58:24Z</updated>
<author>
<name>John Snow</name>
<email>jsnow@redhat.com</email>
</author>
<published>2024-06-26T22:21:19Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=65fa48c79f20a37c7204f9e43dd7cc3058aa066c'/>
<id>urn:sha1:65fa48c79f20a37c7204f9e43dd7cc3058aa066c</id>
<content type='text'>
The double-colon synax is rST formatting that precedes a literal code
block. We do not want to capture these as QAPI-specific sections.

Coerce blocks that start with e.g. "Example::" to be parsed as untagged
paragraphs instead of special tagged sections.

Signed-off-by: John Snow &lt;jsnow@redhat.com&gt;
Message-ID: &lt;20240626222128.406106-14-jsnow@redhat.com&gt;
Reviewed-by: Markus Armbruster &lt;armbru@redhat.com&gt;
[Indentation tweaked for consistency]
Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
</content>
</entry>
<entry>
<title>qapi: convert "Note" sections to plain rST</title>
<updated>2024-07-06T06:58:24Z</updated>
<author>
<name>John Snow</name>
<email>jsnow@redhat.com</email>
</author>
<published>2024-06-26T22:21:16Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=d461c2797374e0becc5227cdc099d85bc329b236'/>
<id>urn:sha1:d461c2797374e0becc5227cdc099d85bc329b236</id>
<content type='text'>
We do not need a dedicated section for notes. By eliminating a specially
parsed section, these notes can be treated as normal rST paragraphs in
the new QMP reference manual, and can be placed and styled much more
flexibly.

Convert all existing "Note" and "Notes" sections to pure rST. As part of
the conversion, capitalize the first letter of each sentence and add
trailing punctuation where appropriate to ensure notes look sensible and
consistent in rendered HTML documentation. Markup is also re-aligned to
the de-facto standard of 3 spaces for directives.

Update docs/devel/qapi-code-gen.rst to reflect the new paradigm, and
update the QAPI parser to prohibit "Note" sections while suggesting a
new syntax. The exact formatting to use is a matter of taste, but a good
candidate is simply:

.. note:: lorem ipsum ...
   ... dolor sit amet ...
   ... consectetur adipiscing elit ...

... but there are other choices, too. The Sphinx readthedocs theme
offers theming for the following forms (capitalization unimportant); all
are adorned with a (!) symbol () in the title bar for rendered HTML
docs.

See
https://sphinx-rtd-theme.readthedocs.io/en/stable/demo/demo.html#admonitions
for examples of each directive/admonition in use.

These are rendered in orange:

.. Attention:: ...
.. Caution:: ...
.. WARNING:: ...

These are rendered in red:

.. DANGER:: ...
.. Error:: ...

These are rendered in green:

.. Hint:: ...
.. Important:: ...
.. Tip:: ...

These are rendered in blue:

.. Note:: ...
.. admonition:: custom title

   admonition body text

This patch uses ".. note::" almost everywhere, with just two "caution"
directives. Several instances of "Notes:" have been converted to
merely ".. note::", or multiple ".. note::" where appropriate.
".. admonition:: notes" is used in a few places where we had an
ordered list of multiple notes that would not make sense as
standalone/separate admonitions.  Two "Note:" following "Example:"
have been turned into ordinary paragraphs within the example.

NOTE: Because qapidoc.py does not attempt to preserve source ordering of
sections, the conversion of Notes from a "tagged section" to an
"untagged section" means that rendering order for some notes *may
change* as a result of this patch. The forthcoming qapidoc.py rewrite
strictly preserves source ordering in the rendered documentation, so
this issue will be rectified in the new generator.

Signed-off-by: John Snow &lt;jsnow@redhat.com&gt;
Acked-by: Stefan Hajnoczi &lt;stefanha@redhat.com&gt; [for block*.json]
Message-ID: &lt;20240626222128.406106-11-jsnow@redhat.com&gt;
Reviewed-by: Markus Armbruster &lt;armbru@redhat.com&gt;
[Commit message clarified slightly, period added to one more note]
Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
</content>
</entry>
<entry>
<title>qapi/parser: fix comment parsing immediately following a doc block</title>
<updated>2024-07-06T06:58:24Z</updated>
<author>
<name>John Snow</name>
<email>jsnow@redhat.com</email>
</author>
<published>2024-06-26T22:21:12Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=83deda876940116d31bf47c51e62e0fe625e8655'/>
<id>urn:sha1:83deda876940116d31bf47c51e62e0fe625e8655</id>
<content type='text'>
If a comment immediately follows a doc block, the parser doesn't ignore
that token appropriately. Fix that.

e.g.

&gt; ##
&gt; # = Hello World!
&gt; ##
&gt;
&gt; # I'm a comment!

will break the parser, because it does not properly ignore the comment
token if it immediately follows a doc block.

Fixes: 3d035cd2cca6 (qapi: Rewrite doc comment parser)
Signed-off-by: John Snow &lt;jsnow@redhat.com&gt;
Reviewed-by: Markus Armbruster &lt;armbru@redhat.com&gt;
Message-ID: &lt;20240626222128.406106-7-jsnow@redhat.com&gt;
Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
</content>
</entry>
<entry>
<title>qapi/parser: preserve indentation in QAPIDoc sections</title>
<updated>2024-07-06T06:58:24Z</updated>
<author>
<name>John Snow</name>
<email>jsnow@redhat.com</email>
</author>
<published>2024-06-26T22:21:11Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=939c639e1d7c1d78bcc262368ab1fb78f09d0bfe'/>
<id>urn:sha1:939c639e1d7c1d78bcc262368ab1fb78f09d0bfe</id>
<content type='text'>
Change get_doc_indented() to preserve indentation on all subsequent text
lines, and create a compatibility dedent() function for qapidoc.py that
removes indentation the same way get_doc_indented() did.

This is being done for the benefit of a new qapidoc generator which
requires that indentation in argument and features sections are
preserved.

Prior to this patch, a section like this:

```
@name: lorem ipsum
   dolor sit amet
     consectetur adipiscing elit
```

would have its body text be parsed into:

```
lorem ipsum
dolor sit amet
  consectetur adipiscing elit
```

We want to preserve the indentation for even the first body line so that
the entire block can be parsed directly as rST. This patch would now
parse that segment into:

```
lorem ipsum
   dolor sit amet
     consectetur adipiscing elit
```

This is helpful for formatting arguments and features as field lists in
rST, where the new generator will format this information as:

```
:arg type name: lorem ipsum
   dolor sit amet
     consectetur apidiscing elit
```

...and can be formed by the simple concatenation of the field list
construct and the body text. The indents help preserve the continuation
of a block-level element, and further allow the use of additional rST
block-level constructs such as code blocks, lists, and other such
markup.

This understandably breaks the existing qapidoc.py; so a new function is
added there to dedent the text for compatibility. Once the new generator
is merged, this function will not be needed any longer and can be
dropped.

I verified this patch changes absolutely nothing by comparing the
md5sums of the QMP ref html pages both before and after the change, so
it's certified inert. QAPI test output has been updated to reflect the
new strategy of preserving indents for rST.

Signed-off-by: John Snow &lt;jsnow@redhat.com&gt;
Reviewed-by: Markus Armbruster &lt;armbru@redhat.com&gt;
Message-ID: &lt;20240626222128.406106-6-jsnow@redhat.com&gt;
[Lost commit message paragraph restored]
Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
</content>
</entry>
<entry>
<title>qapi: linter fixups</title>
<updated>2024-07-06T06:58:24Z</updated>
<author>
<name>John Snow</name>
<email>jsnow@redhat.com</email>
</author>
<published>2024-06-26T22:21:08Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=f64e753149a0472e381246f0e06e5b293aa40541'/>
<id>urn:sha1:f64e753149a0472e381246f0e06e5b293aa40541</id>
<content type='text'>
Fix minor irritants to pylint/flake8 et al.

(Yes, these need to be guarded by the Python tests. That's a work in
progress, a series that's quite likely to follow once I finish this
Sphinx project. Please pardon the temporary irritation.)

Signed-off-by: John Snow &lt;jsnow@redhat.com&gt;
Reviewed-by: Markus Armbruster &lt;armbru@redhat.com&gt;
Message-ID: &lt;20240626222128.406106-3-jsnow@redhat.com&gt;
Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
</content>
</entry>
<entry>
<title>qapi: Simplify QAPISchemaVariants @tag_member</title>
<updated>2024-05-06T10:38:27Z</updated>
<author>
<name>Markus Armbruster</name>
<email>armbru@redhat.com</email>
</author>
<published>2024-03-16T07:46:12Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=285a8f209af7b4992aa91e8bea03a303fb6406ab'/>
<id>urn:sha1:285a8f209af7b4992aa91e8bea03a303fb6406ab</id>
<content type='text'>
For union types, the tag member is known only after .check().

We used to code this in a simple way: QAPISchemaVariants attribute
.tag_member was None for union types until .check().

Since this complicated typing, recent commit "qapi/schema: fix typing
for QAPISchemaVariants.tag_member" hid it behind a property.

The previous commit lets us treat .tag_member just like the other
attributes that become known only in .check(): declare, but don't
initialize it in .__init__().

Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
</content>
</entry>
<entry>
<title>qapi: Move conditional code from QAPISchemaVariants to its subtypes</title>
<updated>2024-05-06T10:38:27Z</updated>
<author>
<name>Markus Armbruster</name>
<email>armbru@redhat.com</email>
</author>
<published>2024-03-15T19:57:56Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=8152bc7de6d4377d5104078115aa61986b436f44'/>
<id>urn:sha1:8152bc7de6d4377d5104078115aa61986b436f44</id>
<content type='text'>
QAPISchemaVariants.check()'s code is almost entirely conditional on
union vs. alternate type.

Move the conditional code to QAPISchemaBranches.check() and
QAPISchemaAlternatives.check(), where the conditions are always
satisfied.

Attribute QAPISchemaVariants.tag_name is now only used by
QAPISchemaBranches.  Move it there.

Refactor the three types' .__init__() to make them a bit simpler.

Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
</content>
</entry>
<entry>
<title>qapi: Rename QAPISchemaAlternateType.variants to .alternatives</title>
<updated>2024-05-06T10:38:27Z</updated>
<author>
<name>Markus Armbruster</name>
<email>armbru@redhat.com</email>
</author>
<published>2024-03-15T15:36:02Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=e0a28f39b4602de56d3c0f66a386ededd25ea109'/>
<id>urn:sha1:e0a28f39b4602de56d3c0f66a386ededd25ea109</id>
<content type='text'>
A previous commit narrowed the type of
QAPISchemaAlternateType.variants from QAPISchemaVariants to
QAPISchemaAlternatives.  Rename it to .alternatives.

Same for .__init__() parameter @variants.

Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
</content>
</entry>
<entry>
<title>qapi: Rename QAPISchemaObjectType.variants to .branches</title>
<updated>2024-05-06T10:38:27Z</updated>
<author>
<name>Markus Armbruster</name>
<email>armbru@redhat.com</email>
</author>
<published>2024-03-15T15:33:23Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/qemu/commit/?id=3ff2a5a35c387a4deb86101474c7e181b36e82f2'/>
<id>urn:sha1:3ff2a5a35c387a4deb86101474c7e181b36e82f2</id>
<content type='text'>
A previous commit narrowed the type of QAPISchemaObjectType.variants
from QAPISchemaVariants to QAPISchemaBranches.  Rename it to
.branches.

Same for .__init__() parameter @variants.

Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
</content>
</entry>
</feed>
