All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: qemu-devel@nongnu.org, "Zhenwei Pi" <pizhenwei@bytedance.com>,
	"Stefan Berger" <stefanb@linux.vnet.ibm.com>,
	"Jiri Pirko" <jiri@resnulli.us>,
	"Ani Sinha" <anisinha@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Mads Ynddal" <mads@ynddal.dk>, "Zhao Liu" <zhao1.liu@intel.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Kashyap Chamarthy" <kchamart@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Hanna Reitz" <hreitz@redhat.com>,
	"Cleber Rosa" <crosa@redhat.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	qemu-block@nongnu.org, "Igor Mammedov" <imammedo@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Eric Blake" <eblake@redhat.com>,
	"Gonglei (Arei)" <arei.gonglei@huawei.com>,
	"Lukas Straub" <lukasstraub2@web.de>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Vladimir Sementsov-Ogievskiy" <vsementsov@yandex-team.ru>,
	"Fan Ni" <fan.ni@samsung.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Peter Xu" <peterx@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Yanan Wang" <wangyanan55@huawei.com>,
	"Stefano Garzarella" <sgarzare@redhat.com>,
	"Alex Williamson" <alex.williamson@redhat.com>,
	"Fabiano Rosas" <farosas@suse.de>,
	"Jonathan Cameron" <jonathan.cameron@huawei.com>,
	"Cédric Le Goater" <clg@redhat.com>,
	"Michael Roth" <michael.roth@amd.com>,
	"Kevin Wolf" <kwolf@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Konstantin Kostiuk" <kkostiuk@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>
Subject: Re: [PATCH v2 1/3] docs: fix errors formatting in tests/qapi-schema/doc-good
Date: Mon, 16 Jun 2025 13:36:05 +0200	[thread overview]
Message-ID: <87ecvjj4uy.fsf@pond.sub.org> (raw)
In-Reply-To: <20250612221051.1224565-2-jsnow@redhat.com> (John Snow's message of "Thu, 12 Jun 2025 18:10:49 -0400")

John Snow <jsnow@redhat.com> writes:

> If we remove the legacy parser, the doc-good.json formatting begins to

"parser"?  You mean docs/sphinx/qapidoc_legacy.py, don't you?

> fail because the body text is appended directly after the field list
> entry, which is invalid rST syntax.

We've been running the test suite with the legacy doc generator.
Unwise; we should've switched to the new one right away.

> Without this change, we see this error:
>
> /home/jsnow/src/qemu/docs/../tests/qapi-schema/doc-good.json:169:
> WARNING: Field list ends without a blank line; unexpected
> unindent. [docutils]

The reporting is less than helpful.

> And this intermediate rST source:
>
> tests/qapi-schema/doc-good.json:0167 |    :error:
> tests/qapi-schema/doc-good.json:0168 |    some
>
> With this patch applied, we instead generate this source:
>
> tests/qapi-schema/doc-good.json:0167 |    :error:
> tests/qapi-schema/doc-good.json:0168 |        - some
>
> which compiles successfully.

Hmm.

As far as I can tell, the problem is lack of indentation[*].

By convention, the contents of an Errors: section is a list.
docs/devel/qapi-code-gen.rst:

    "Errors" sections should be formatted as an rST list, each entry
    detailing a relevant error condition.  For example::

     # Errors:
     #     - If @device does not exist, DeviceNotFound
     #     - Any other error returns a GenericError.

This test case is the only instance of something else.

It's just a convention, though.

Your change to the positive test case makes some sense all the same; it
should cover how we want the thing to be used.

What I don't like is how the new doc generator fails when we fail to
adhere to the convention.

Here's docs/devel/qapi-code-gen.rst on tagged sections:

    A tagged section begins with a paragraph that starts with one of the
    following words: "Since:", "Returns:", "Errors:", "TODO:".  It ends with
    the start of a new section.

    The second and subsequent lines of tagged sections must be indented
    like this::

     # TODO: Ut enim ad minim veniam, quis nostrud exercitation ullamco
     #     laboris nisi ut aliquip ex ea commodo consequat.
     #
     #     Duis aute irure dolor in reprehenderit in voluptate velit esse
     #     cillum dolore eu fugiat nulla pariatur.

This tells us that

    # Errors: some

and

    # Errors:
    #     some

and

    # Errors: some
    #     more

should all work, just like for any other tag.  However, only the second
one works in my testing.  With qapidoc_legacy.py, all three work.

We can make Errors: unlike the other tags.  But it needs to be done
properly, i.e. in scripts/qapi/parser.py (for decent error reporting),
and documented in docs/devel/qapi-code-gen.rst.

Keeping the QAPI domain accept what the generator generates might be
easier.

Thoughts?

>
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  tests/qapi-schema/doc-good.json | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.json
> index 14b808f9090..6dcde8fd7e8 100644
> --- a/tests/qapi-schema/doc-good.json
> +++ b/tests/qapi-schema/doc-good.json
> @@ -165,7 +165,8 @@
>  #
>  # Returns: @Object
>  #
> -# Errors: some
> +# Errors:
> +#     - some
>  #
>  # TODO: frobnicate
>  #

Fails "make check".  Fixup appended.



[*] Evidence:

    # Errors:
    #     - some

which expands into

    :error:
        - some

and

    # Errors:
    #     some

which expands into

    :error:
        some

both work.

docs/devel/qapi-domain.rst:

    ``:error:``
    -----------

    Document the error condition(s) of a QAPI command.

    :availability: This field list is only available in the body of the
                   Command directive.
--> :syntax: ``:error: Lorem ipsum dolor sit amet ...``
    :type: `sphinx.util.docfields.Field
           <https://pydoc.dev/sphinx/latest/sphinx.util.docfields.Field.html?private=1>`_

    The format of the :errors: field list description is free-form rST. The
    alternative spelling ":errors:" is also permitted, but strictly
    analogous.

    Example::

       .. qapi:command:: block-job-set-speed
          :since: 1.1

          Set maximum speed for a background block operation.

          This command can only be issued when there is an active block job.

          Throttling can be disabled by setting the speed to 0.

          :arg string device: The job identifier.  This used to be a device
              name (hence the name of the parameter), but since QEMU 2.7 it
              can have other values.
          :arg int speed: the maximum speed, in bytes per second, or 0 for
              unlimited.  Defaults to 0.
-->       :error:
-->           - If no background operation is active on this device,
-->             DeviceNotActive

This makes me expect

    :error: some

also works.  However, the obvious

    # Errors: some

produces

    :error:
    some

which doesn't work.


diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
index dc8352eed4..3711cf5480 100644
--- a/tests/qapi-schema/doc-good.out
+++ b/tests/qapi-schema/doc-good.out
@@ -176,7 +176,7 @@ another feature
     section=Returns
 @Object
     section=Errors
-some
+    - some
     section=Todo
 frobnicate
     section=Plain
diff --git a/tests/qapi-schema/doc-good.txt b/tests/qapi-schema/doc-good.txt
index 17a1d56ef1..e54cc95f4a 100644
--- a/tests/qapi-schema/doc-good.txt
+++ b/tests/qapi-schema/doc-good.txt
@@ -207,7 +207,7 @@ Returns
 Errors
 ~~~~~~
 
-some
+* some
 
 Notes:
 



  reply	other threads:[~2025-06-16 11:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-12 22:10 [PATCH v2 0/3] docs: remove legacy qapidoc John Snow
2025-06-12 22:10 ` [PATCH v2 1/3] docs: fix errors formatting in tests/qapi-schema/doc-good John Snow
2025-06-16 11:36   ` Markus Armbruster [this message]
2025-06-16 21:47     ` John Snow
2025-06-12 22:10 ` [PATCH v2 2/3] docs: remove legacy QAPI manual generator John Snow
2025-06-16 12:20   ` Markus Armbruster
2025-06-17 19:54     ` John Snow
2025-06-18  6:21       ` Markus Armbruster
2025-06-12 22:10 ` [PATCH v2 3/3] docs: remove special parsing for freeform sections John Snow
2025-06-16 12:35   ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ecvjj4uy.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=alex.williamson@redhat.com \
    --cc=anisinha@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=berrange@redhat.com \
    --cc=clg@redhat.com \
    --cc=crosa@redhat.com \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=fan.ni@samsung.com \
    --cc=farosas@suse.de \
    --cc=hreitz@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=jiri@resnulli.us \
    --cc=jonathan.cameron@huawei.com \
    --cc=jsnow@redhat.com \
    --cc=kchamart@redhat.com \
    --cc=kkostiuk@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=lukasstraub2@web.de \
    --cc=mads@ynddal.dk \
    --cc=marcandre.lureau@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=michael.roth@amd.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --cc=pizhenwei@bytedance.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sgarzare@redhat.com \
    --cc=stefanb@linux.vnet.ibm.com \
    --cc=stefanha@redhat.com \
    --cc=vsementsov@yandex-team.ru \
    --cc=wangyanan55@huawei.com \
    --cc=zhao1.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.