John Snow <js...@redhat.com> writes: > This adds the qapi:module directive, which just notes the current module > being documented and performs a nested parse of the content block, if > present. > > This code is based pretty heavily on Sphinx's PyModule directive, but > with unnecessary features excised. > > For example: > > .. qapi:module:: block-core > > Hello, and welcome to block-core! > ================================= > > lorem ipsum, dolor sit amet ... > > Signed-off-by: John Snow <js...@redhat.com> > --- > docs/sphinx/qapi_domain.py | 71 ++++++++++++++++++++++++++++++++++---- > 1 file changed, 65 insertions(+), 6 deletions(-) > > diff --git a/docs/sphinx/qapi_domain.py b/docs/sphinx/qapi_domain.py > index 0365891f354..a445150ae59 100644 > --- a/docs/sphinx/qapi_domain.py > +++ b/docs/sphinx/qapi_domain.py > @@ -19,6 +19,7 @@ > > from docutils import nodes > > +from sphinx import addnodes > from sphinx.addnodes import desc_signature, pending_xref > from sphinx.directives import ObjectDescription > from sphinx.domains import ( > @@ -34,7 +35,7 @@ > > > if TYPE_CHECKING: > - from docutils.nodes import Element > + from docutils.nodes import Element, Node > > from sphinx.application import Sphinx > from sphinx.builders import Builder > @@ -157,6 +158,60 @@ def add_target_and_index( > ) > > > +class QAPIModule(QAPIDescription): > + """ > + Directive to mark description of a new module. > + > + This directive doesn't generate any special formatting, and is just > + a pass-through for the content body. Named section titles are > + allowed in the content body. > + > + Use this directive to create entries for the QAPI module in the > + global index and the qapi index; as well as to associate subsequent
QAPI unless there's a reason for lower case. > + definitions with the module they are defined in for purposes of > + search and QAPI index organization. > + > + :arg: The name of the module. > + :opt no-index: Don't add cross-reference targets or index entries. > + :opt no-typesetting: Don't render the content body (but preserve any > + cross-reference target IDs in the squelched output.) > + > + Example:: > + > + .. qapi:module:: block-core > + :no-index: > + :no-typesetting: > + > + Lorem ipsum, dolor sit amet ... > + """ [...]