52c806ca | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapidoc: add visit_returns() method
Generates :return: fields for explicit returns statements. Note that this does not presently handle undocumented returns, which is handled in a later commit.
docs/qapidoc: add visit_returns() method
Generates :return: fields for explicit returns statements. Note that this does not presently handle undocumented returns, which is handled in a later commit.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-51-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
38a349ff | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapidoc: prepare to record entity being transmogrified
Prepare to keep a record of which entity we're working on documenting for the purposes of being able to change certain generative features
docs/qapidoc: prepare to record entity being transmogrified
Prepare to keep a record of which entity we're working on documenting for the purposes of being able to change certain generative features conditionally and create stronger assertions.
If you find yourself asking: "Wait, but where does the current entity actually get recorded?!", you're right! That part comes with the visit_entity() implementation, which gets added later.
This patch is front-loaded for the sake of type checking in the forthcoming commits before visit_entity() is ready to be added.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-50-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
6c43b008 | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapidoc: add visit_feature() method
This adds a simple ":feat name: lorem ipsum ..." line to the generated rST document, so at the moment it's only for "top level" features.
Features not attac
docs/qapidoc: add visit_feature() method
This adds a simple ":feat name: lorem ipsum ..." line to the generated rST document, so at the moment it's only for "top level" features.
Features not attached directly to a QAPI definition are not currently handled! This is a small regression over the prior documentation generator that will be addressed in a future patch.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-49-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
604df9bb | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapidoc: add add_field() and generate_field() helper methods
These are simple rST generation methods that assist in getting the types and formatting correct for a field list entry. add_field()
docs/qapidoc: add add_field() and generate_field() helper methods
These are simple rST generation methods that assist in getting the types and formatting correct for a field list entry. add_field() is a more raw, direct call while generate_field() is intended to be used for generating the correct field from a member object.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-48-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
3a396a86 | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapidoc: add format_type() method
This method is responsible for generating a type name for a given member with the correct annotations for the QAPI domain. Features and enums do not *have* typ
docs/qapidoc: add format_type() method
This method is responsible for generating a type name for a given member with the correct annotations for the QAPI domain. Features and enums do not *have* types, so they return None. Everything else returns the type name with a "?" suffix if that type is optional, and ensconced in [brackets] if it's an array type.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-47-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
e9fbf1a0 | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapidoc: add visit_errors() method
Notably, this method does not currently address the formatting issues present with the "errors" section in QAPIDoc and just vomits the text verbatim into the
docs/qapidoc: add visit_errors() method
Notably, this method does not currently address the formatting issues present with the "errors" section in QAPIDoc and just vomits the text verbatim into the rST doc, with somewhat inconsistent results.
To be addressed in a future patch.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-46-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
56e1adf2 | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapidoc: add visit_paragraph() method
This transforms "formerly known as untagged sections" into our pure intermediate rST format. These sections are already pure rST, so this method doesn't do
docs/qapidoc: add visit_paragraph() method
This transforms "formerly known as untagged sections" into our pure intermediate rST format. These sections are already pure rST, so this method doesn't do a whole lot except ensure appropriate newlines.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-45-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
803df114 | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapidoc: add preamble() method
This method adds the options/preamble to each definition block. Notably, :since: and :ifcond: are added, as are any "special features" such as :deprecated: and :u
docs/qapidoc: add preamble() method
This method adds the options/preamble to each definition block. Notably, :since: and :ifcond: are added, as are any "special features" such as :deprecated: and :unstable:.
If conditionals, if attached to special features, are currently unhandled in this patch and will be addressed at a future date. We currently do not have any if conditionals attached to special features.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-44-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
f0b2fe99 | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapidoc: add visit_freeform() method
Add the transmogrifier implementation for converting freeform doc blocks to rST.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75
docs/qapidoc: add visit_freeform() method
Add the transmogrifier implementation for converting freeform doc blocks to rST.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-43-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
5edd7411 | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapidoc: add visit_module() method
This method annotates the start of a new module, crediting the source location to the first line of the module file.
Signed-off-by: John Snow <jsnow@redhat.c
docs/qapidoc: add visit_module() method
This method annotates the start of a new module, crediting the source location to the first line of the module file.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-41-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
bd7c1496 | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapidoc: add transmogrifier class stub
Add the beginnings of the Transmogrifier class by adding the rST conversion helpers that will be used to build the virtual rST document.
This version of
docs/qapidoc: add transmogrifier class stub
Add the beginnings of the Transmogrifier class by adding the rST conversion helpers that will be used to build the virtual rST document.
This version of the class does not actually "do anything" yet; each individual feature is added one-at-a-time in the forthcoming commits.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-40-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
45d483a8 | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapidoc: Fix static typing on qapidoc.py
Now that the legacy code is factored out, fix up the typing on the remaining code in qapidoc.py. Add a type ignore to qapi_legacy.py to prevent the erro
docs/qapidoc: Fix static typing on qapidoc.py
Now that the legacy code is factored out, fix up the typing on the remaining code in qapidoc.py. Add a type ignore to qapi_legacy.py to prevent the errors there from bleeding out into qapidoc.py.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-38-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
7640410d | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapidoc: split old implementation into qapidoc_legacy.py
This is being done primarily to be able to type check and delint the new implementation without needing to worry about fixing up the old
docs/qapidoc: split old implementation into qapidoc_legacy.py
This is being done primarily to be able to type check and delint the new implementation without needing to worry about fixing up the old implementation.
I'm adding the new implementation into the existing file instead of into a new file so that when the dust settles, qapidoc.py will contain the full history of development on this generative module.
This patch *should* be pure motion, give or take the import statements.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-37-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
7d125c33 | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapidoc: add transmogrifier stub
This commit adds a stubbed option to the qapi-doc directive that opts-in to the new rST generator; the implementation of which will follow in subsequent commits
docs/qapidoc: add transmogrifier stub
This commit adds a stubbed option to the qapi-doc directive that opts-in to the new rST generator; the implementation of which will follow in subsequent commits.
Once all QAPI documents have been converted, this option and the old qapidoc implementation can be dropped.
Note that moving code outside of the try...except block has no impact because the code moved outside of that block does not ever raise a QAPIError.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-36-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
323c6689 | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
qapi: clean up encoding of section kinds
We have several kinds of sections, and to tell them apart, we use Section attribute @tag and also the section object's Python type:
type
qapi: clean up encoding of section kinds
We have several kinds of sections, and to tell them apart, we use Section attribute @tag and also the section object's Python type:
type @tag untagged Section None @foo: ArgSection 'foo' Returns: Section 'Returns' Errors: Section 'Errors' Since: Section 'Since' TODO: Section 'TODO'
Note:
* @foo can be a member or a feature description, depending on context.
* tag == 'Since' can be a Since: section or a member or feature description. If it's a Section, it's the former, and if it's an ArgSection, it's the latter.
Clean this up as follows. Move the member or feature name to new ArgSection attribute @name, and replace @tag by enum @kind like this:
type kind name untagged Section PLAIN @foo: ArgSection MEMBER 'foo' if member or argument ArgSection FEATURE 'foo' if feature Returns: Section RETURNS Errors: Section ERRORS Since: Section SINCE TODO: Section TODO
The qapi-schema tests are updated to account for the new section names; "TODO" becomes "Todo" and `None` becomes "Plain" there.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-34-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
707f2bbb | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapi-domain: Fix error context reporting in Sphinx 5.x and 6.x
Sphinx 5.3.0 to Sphinx 6.2.0 has a bug where nested content in an ObjectDescription content block has its error position reported
docs/qapi-domain: Fix error context reporting in Sphinx 5.x and 6.x
Sphinx 5.3.0 to Sphinx 6.2.0 has a bug where nested content in an ObjectDescription content block has its error position reported incorrectly due to an oversight when they added nested section support to this directive.
(This bug is present in Sphinx's own Python and C domains; test it yourself by creating a py:func directive and creating a syntax error in the directive's content block. The reporting will be incorrect.)
To avoid overriding and re-implementing the entirety of the run() method, a workaround is employed where we parse the content block ourselves in before_content(), then null the content block to make Sphinx's own parsing a no-op. Then, in transform_content (which occurs after Sphinx's nested parse), we simply swap our own parsed content tree back in for Sphinx's.
It appears a little tricky, but it's the nicest solution I can find.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-32-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
d48a8f8d | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapi-domain: warn when QAPI domain xrefs fail to resolve
This patch adds a warning (which is a build failure under our current build settings) whenever a QAPI cross-reference fails to resolve.
docs/qapi-domain: warn when QAPI domain xrefs fail to resolve
This patch adds a warning (which is a build failure under our current build settings) whenever a QAPI cross-reference fails to resolve.
This applies to any cross-references of the form :qapi:{role}:`foo`, which covers all of the automatically generated references by the qapi domain, and any such references that are manually written into the documentation rst files.
Cross-references of the form `foo` do not use this system, but are already configured to issue a warning (Again, a build failure) if the cross-reference isn't found anywhere.
Adds warnings that look like the following:
docs/qapi/index.rst:48: WARNING: qapi:type reference target not found: 'footype' [ref.qapi] docs/qapi/index.rst:50: WARNING: qapi:mod reference target not found: 'foomod' [ref.qapi]
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-31-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
a1fe2cd4 | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapi-domain: add XREF compatibility goop for Sphinx < 4.1
Sphinx < 4.1 handles cross-references ... differently. Factor out and isolate the compatibility goop we need to make cross references w
docs/qapi-domain: add XREF compatibility goop for Sphinx < 4.1
Sphinx < 4.1 handles cross-references ... differently. Factor out and isolate the compatibility goop we need to make cross references work properly in old versions of Sphinx.
Yes, it's ugly. Yes, it works. No, I don't want to talk about it.
Understand that this patch exists because of the overflowing love in my heart.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-30-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
03947c80 | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapi-domain: add type cross-refs to field lists
This commit, finally, adds cross-referencing support to various field lists; modeled tightly after Sphinx's own Python domain code.
Cross-refere
docs/qapi-domain: add type cross-refs to field lists
This commit, finally, adds cross-referencing support to various field lists; modeled tightly after Sphinx's own Python domain code.
Cross-referencing support is added to type names provided to :arg:, :memb:, :returns: and :choice:.
:feat:, :error: and :value:, which do not take type names, do not support this syntax.
The general syntax is simple:
:arg TypeName ArgName: Lorem Ipsum ...
The domain will transform TypeName into :qapi:type:`TypeName` in this basic case, and also apply the ``literal`` decoration to indicate that this is a type cross-reference.
For optional arguments, the special "?" suffix is used. Because "*" has special meaning in rST that would cause parsing errors, we elect to use "?" instead. The special syntax processing strips this character from the end of any type name argument and will append ", optional" to the rendered output, applying the cross-reference only to the actual type name.
The intent here is that the actual syntax in doc-blocks need not change; but e.g. qapidoc.py will need to process and transform "@arg foo lorem ipsum" into ":arg type? foo: lorem ipsum" based on the schema information. Therefore, nobody should ever actually witness this intermediate syntax unless they are writing manual documentation or the doc transmogrifier breaks.
For array arguments, type names can similarly be surrounded by "[]", which are stripped off and then re-appended outside of the cross-reference.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-28-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
ef137a22 | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapi-domain: add warnings for malformed field lists
Normally, Sphinx will silently fall back to its standard field list processing if it doesn't match one of your defined fields. A lot of the t
docs/qapi-domain: add warnings for malformed field lists
Normally, Sphinx will silently fall back to its standard field list processing if it doesn't match one of your defined fields. A lot of the time, that's not what we want - we want to be warned if we goof something up.
For instance, the canonical argument field list form is:
:arg type name: descr
This form is captured by Sphinx and transformed so that the field label will become "Arguments:". It's possible to omit the type name and descr and still have it be processed correctly. However, if you omit the type name, Sphinx no longer recognizes it:
:arg: this is not recognized.
This will turn into an arbitrary field list entry whose label is "Arg:", and it otherwise silently fails. You may also see failures for doing things like using :values: instead of :value:, or :errors: instead of :error:, and so on. It's also case sensitive, and easy to trip up.
Add a validator that guarantees all field list entries that are the direct child of an ObjectDescription use only recognized forms of field lists, and emit a warning (treated as error by default in most build configurations) whenever we detect one that is goofed up.
However, there's still benefit to allowing arbitrary fields -- they are after all not a Sphinx invention, but perfectly normal docutils syntax. Create an allow list for known spellings we don't mind letting through, but warn against anything else.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-27-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
6a413302 | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapi-domain: add :ifcond: directive option
Add a special :ifcond: option that allows us to annotate the definition-level conditionals.
The syntax of the argument is currently undefined, but it
docs/qapi-domain: add :ifcond: directive option
Add a special :ifcond: option that allows us to annotate the definition-level conditionals.
The syntax of the argument is currently undefined, but it's possible we can apply better formatting in the future. Currently, we just display the ifcond string as preformatted text.
Signed-off-by: Harmonie Snow <harmonie@gmail.com> Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-26-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
d25808c2 | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapi-domain: add :unstable: directive option
Although "unstable" is a feature (and *will* appear in the features list), add a special :unstable: option to generate an eye-catch that makes this
docs/qapi-domain: add :unstable: directive option
Although "unstable" is a feature (and *will* appear in the features list), add a special :unstable: option to generate an eye-catch that makes this information very hard to miss.
The forthcoming Transmogrifier in qapidoc.py will add this option whenever it detects that the features list attached to a definition contains the "unstable" entry.
Signed-off-by: Harmonie Snow <harmonie@gmail.com> Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-25-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
1a0c090a | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapi-domain: add :deprecated: directive option
Although "deprecated" is a feature (and *will* appear in the features list), add a special :deprecated: option to generate an eye-catch that makes
docs/qapi-domain: add :deprecated: directive option
Although "deprecated" is a feature (and *will* appear in the features list), add a special :deprecated: option to generate an eye-catch that makes this information very hard to miss.
The forthcoming Transmogrifier in qapidoc.py will add this option whenever it detects that the features list attached to a definition contains the "deprecated" entry.
P.S., I outsourced the CSS ;)
Signed-off-by: Harmonie Snow <harmonie@gmail.com> Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-24-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
3fe3349d | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapi-domain: add qapi:object directive
Adds the .. qapi:object:: directive, object, and :qapi:obj:`name` cross-referencing role. This directive is meant to document both structs and unions.
As
docs/qapi-domain: add qapi:object directive
Adds the .. qapi:object:: directive, object, and :qapi:obj:`name` cross-referencing role. This directive is meant to document both structs and unions.
As per usual, QAPI cross-referencing for types in the member field list will be added in a forthcoming commit.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-23-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
6d5f6f69 | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
docs/qapi-domain: add qapi:event directive
Adds the .. qapi:event:: directive, object, and :qapi:event:`name` cross-referencing role.
Adds the :memb type name: field list syntax for documenting eve
docs/qapi-domain: add qapi:event directive
Adds the .. qapi:event:: directive, object, and :qapi:event:`name` cross-referencing role.
Adds the :memb type name: field list syntax for documenting event data members. As this syntax and phrasing will be shared with Structs and Unions as well, add the field list definition to a shared abstract class.
As per usual, QAPI cross-referencing for types in the member field list will be added in a forthcoming commit.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-22-jsnow@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|