76e375fc | 16-Jul-2024 |
John Snow <jsnow@redhat.com> |
docs/qapidoc: add QMP highlighting to annotated qmp-example blocks
For any code literal blocks inside of a qmp-example directive, apply and enforce the QMP lexer/highlighter to those blocks.
This w
docs/qapidoc: add QMP highlighting to annotated qmp-example blocks
For any code literal blocks inside of a qmp-example directive, apply and enforce the QMP lexer/highlighter to those blocks.
This way, you won't need to write:
``` .. qmp-example:: :annotated:
Blah blah
.. code-block:: QMP
-> { "lorem": "ipsum" } ```
But instead, simply:
``` .. qmp-example:: :annotated:
Blah blah::
-> { "lorem": "ipsum" } ```
Once the directive block is exited, whatever the previous default highlight language was will be restored; localizing the forced QMP lexing to exclusively this directive.
Note, if the default language is *already* QMP, this directive will not generate and restore redundant highlight configuration nodes. We may well decide that the default language ought to be QMP for any QAPI reference pages, but this way the directive behaves consistently no matter where it is used.
Signed-off-by: John Snow <jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240717021312.606116-5-jsnow@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
547864f9 | 16-Jul-2024 |
John Snow <jsnow@redhat.com> |
docs/qapidoc: create qmp-example directive
This is a directive that creates a syntactic sugar for creating "Example" boxes very similar to the ones already used in the bitmaps.rst document, please s
docs/qapidoc: create qmp-example directive
This is a directive that creates a syntactic sugar for creating "Example" boxes very similar to the ones already used in the bitmaps.rst document, please see e.g. https://www.qemu.org/docs/master/interop/bitmaps.html#creation-block-dirty-bitmap-add
In its simplest form, when a custom title is not needed or wanted, and the example body is *solely* a QMP example:
``` .. qmp-example::
{body} ```
is syntactic sugar for:
``` .. admonition:: Example:
.. code-block:: QMP
{body} ```
When a custom, plaintext title that describes the example is desired, this form:
``` .. qmp-example:: :title: Defrobnification
{body} ```
Is syntactic sugar for:
``` .. admonition:: Example: Defrobnification
.. code-block:: QMP
{body} ```
Lastly, when Examples are multi-step processes that require non-QMP exposition, have lengthy titles, or otherwise involve prose with rST markup (lists, cross-references, etc), the most complex form:
``` .. qmp-example:: :annotated:
This example shows how to use `foo-command`::
{body}
For more information, please see `frobnozz`. ```
Is desugared to:
``` .. admonition:: Example:
This example shows how to use `foo-command`::
{body}
For more information, please see `frobnozz`. ```
Note that :annotated: and :title: options can be combined together, if desired.
The primary benefit here being documentation source consistently using the same directive for all forms of examples to ensure consistent visual styling, and ensuring all relevant prose is visually grouped alongside the code literal block.
Note that as of this commit, the code-block rST syntax "::" does not apply QMP highlighting; you would need to use ".. code-block:: QMP". The very next commit changes this behavior to assume all "::" code blocks within this directive are QMP blocks.
Signed-off-by: John Snow <jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240717021312.606116-4-jsnow@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
e389929d | 28-Jun-2024 |
Markus Armbruster <armbru@redhat.com> |
sphinx/qapidoc: Fix to generate doc for explicit, unboxed arguments
When a command's arguments are specified as an explicit type T, generated documentation points to the members of T.
Example:
sphinx/qapidoc: Fix to generate doc for explicit, unboxed arguments
When a command's arguments are specified as an explicit type T, generated documentation points to the members of T.
Example:
## # @announce-self: # # Trigger generation of broadcast RARP frames to update network [...] ## { 'command': 'announce-self', 'boxed': true, 'data' : 'AnnounceParameters'}
generates
"announce-self" (Command) -------------------------
Trigger generation of broadcast RARP frames to update network [...]
Arguments ~~~~~~~~~
The members of "AnnounceParameters"
Except when the command takes its arguments unboxed , i.e. it doesn't have 'boxed': true, we generate *nothing*. A few commands have a reference in their doc comment to compensate, but most don't.
Example:
## # @blockdev-snapshot-sync: # # Takes a synchronous snapshot of a block device. # # For the arguments, see the documentation of BlockdevSnapshotSync. [...] ## { 'command': 'blockdev-snapshot-sync', 'data': 'BlockdevSnapshotSync', 'allow-preconfig': true }
generates
"blockdev-snapshot-sync" (Command) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Takes a synchronous snapshot of a block device.
For the arguments, see the documentation of BlockdevSnapshotSync. [...]
Same for event data.
Fix qapidoc.py to generate the reference regardless of boxing. Delete now redundant references in the doc comments.
Fixes: 4078ee5469e5 (docs/sphinx: Add new qapi-doc Sphinx extension) Cc: qemu-stable@nongnu.org Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240628112756.794237-1-armbru@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
show more ...
|
2664f317 | 26-Jun-2024 |
John Snow <jsnow@redhat.com> |
docs/qapidoc: fix nested parsing under untagged sections
Sphinx does not like sections without titles, because it wants to convert every section into a reference. When there is no title, it struggle
docs/qapidoc: fix nested parsing under untagged sections
Sphinx does not like sections without titles, because it wants to convert every section into a reference. When there is no title, it struggles to do this and transforms the tree inproperly.
Depending on the rST used, this may result in an assertion error deep in the docutils HTMLWriter.
(Observed when using ".. admonition:: Notes" under such a section - When this is transformed with its own <title> element, Sphinx is fooled into believing this title belongs to the section and incorrect mutates the docutils tree, leading to errors during rendering time.)
When parsing an untagged section (free paragraphs), skip making a hollow section and instead append the parse results to the prior section.
Many Bothans died to bring us this information.
The resulting output changes are basically invisible.
Signed-off-by: John Snow <jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240626222128.406106-8-jsnow@redhat.com> [Mention output changes in commit message] Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
939c639e | 26-Jun-2024 |
John Snow <jsnow@redhat.com> |
qapi/parser: preserve indentation in QAPIDoc sections
Change get_doc_indented() to preserve indentation on all subsequent text lines, and create a compatibility dedent() function for qapidoc.py that
qapi/parser: preserve indentation in QAPIDoc sections
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 <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240626222128.406106-6-jsnow@redhat.com> [Lost commit message paragraph restored] Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
36c6dcc2 | 26-Jun-2024 |
John Snow <jsnow@redhat.com> |
docs/qapidoc: delint a tiny portion of the module
In a forthcoming series that adds a new QMP documentation generator, it will be helpful to have a linting baseline. However, there's no need to shuf
docs/qapidoc: delint a tiny portion of the module
In a forthcoming series that adds a new QMP documentation generator, it will be helpful to have a linting baseline. However, there's no need to shuffle around the deck chairs too much, because most of this code will be removed once that new qapidoc generator (the "transmogrifier") is in place.
To ease my pain: just turn off the black auto-formatter for most, but not all, of qapidoc.py. This will help ensure that *new* code follows a coding standard without bothering too much with cleaning up the existing code.
Code that I intend to keep is still subject to the delinting beam.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240626222128.406106-5-jsnow@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
31c54b92 | 16-Feb-2024 |
Markus Armbruster <armbru@redhat.com> |
qapi: Rename QAPIDoc.Section.name to .tag
Since the previous commit, QAPIDoc.Section.name is either None (untagged section) or the section's tag string ('Returns', '@name', ...). Rename it to .tag.
qapi: Rename QAPIDoc.Section.name to .tag
Since the previous commit, QAPIDoc.Section.name is either None (untagged section) or the section's tag string ('Returns', '@name', ...). Rename it to .tag.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240216145841.2099240-9-armbru@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
show more ...
|