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 3/3] docs: remove special parsing for freeform sections
Date: Mon, 16 Jun 2025 14:35:33 +0200	[thread overview]
Message-ID: <87wm9bg8yy.fsf@pond.sub.org> (raw)
In-Reply-To: <20250612221051.1224565-4-jsnow@redhat.com> (John Snow's message of "Thu, 12 Jun 2025 18:10:51 -0400")

John Snow <jsnow@redhat.com> writes:

> This change removes special parsing for freeform sections and allows
> them to simply be unmodified rST syntax. The existing headings in the
> QAPI schema are adjusted to reflect the new paradigm.
>
> Signed-off-by: John Snow <jsnow@redhat.com>

[...]

> diff --git a/docs/devel/qapi-code-gen.rst b/docs/devel/qapi-code-gen.rst
> index 231cc0fecf7..dfdbeac5a5a 100644
> --- a/docs/devel/qapi-code-gen.rst
> +++ b/docs/devel/qapi-code-gen.rst
> @@ -876,25 +876,35 @@ structuring content.
>  Headings and subheadings
>  ~~~~~~~~~~~~~~~~~~~~~~~~
>  
> -A free-form documentation comment containing a line which starts with
> -some ``=`` symbols and then a space defines a section heading::
> +Free-form documentation does not start with ``@SYMBOL`` and can contain
> +arbitrary rST markup. Headings can be marked up using the standard rST

Two spaces between sentences for consistency, please.

> +syntax::
>  
>      ##
> -    # = This is a top level heading
> +    # *************************
> +    # This is a level 2 heading
> +    # *************************
>      #
>      # This is a free-form comment which will go under the
>      # top level heading.
>      ##
>  
>      ##
> -    # == This is a second level heading
> +    # This is a third level heading
> +    # ==============================
> +    #
> +    # Level 4
> +    # _______
> +    #
> +    # Level 5
> +    # ^^^^^^^
> +    #
> +    # Level 6
> +    # """""""
>      ##
>  
> -A heading line must be the first line of the documentation
> -comment block.
> -
> -Section headings must always be correctly nested, so you can only
> -define a third-level heading inside a second-level heading, and so on.
> +Level 1 headings are reserved for use by the generated documentation
> +page itself, leaving level 2 as the highest level that should be used.
>  
>  
>  Documentation markup
> diff --git a/docs/interop/firmware.json b/docs/interop/firmware.json
> index 745d21d8223..f46fdedfa89 100644
> --- a/docs/interop/firmware.json
> +++ b/docs/interop/firmware.json
> @@ -11,7 +11,9 @@
>  # later. See the COPYING file in the top-level directory.
>  
>  ##
> -# = Firmware
> +# ********
> +# Firmware
> +# ********
>  ##
>  
>  { 'pragma': {
> diff --git a/docs/interop/vhost-user.json b/docs/interop/vhost-user.json
> index b6ade9e4931..095eb99cf79 100644
> --- a/docs/interop/vhost-user.json
> +++ b/docs/interop/vhost-user.json
> @@ -10,7 +10,9 @@
>  # later. See the COPYING file in the top-level directory.
>  
>  ##
> -# = vhost user backend discovery & capabilities
> +# *******************************************
> +# vhost user backend discovery & capabilities
> +# *******************************************
>  ##
>  
>  ##

I dislike reST headings.  Sticking to plain reST makes sense regardless.

> diff --git a/docs/sphinx/qapidoc.py b/docs/sphinx/qapidoc.py
> index c9c477378f5..cdf556c2a3c 100644
> --- a/docs/sphinx/qapidoc.py
> +++ b/docs/sphinx/qapidoc.py
> @@ -391,44 +391,9 @@ def visit_module(self, path: str) -> None:
>          self.ensure_blank_line()
>  
>      def visit_freeform(self, doc: QAPIDoc) -> None:
> -        # TODO: Once the old qapidoc transformer is deprecated, freeform
> -        # sections can be updated to pure rST, and this transformed removed.
> -        #
> -        # For now, translate our micro-format into rST. Code adapted
> -        # from Peter Maydell's freeform().
> -
>          assert len(doc.all_sections) == 1, doc.all_sections
>          body = doc.all_sections[0]
> -        text = body.text
> -        info = doc.info
> -
> -        if re.match(r"=+ ", text):
> -            # Section/subsection heading (if present, will always be the
> -            # first line of the block)
> -            (heading, _, text) = text.partition("\n")
> -            (leader, _, heading) = heading.partition(" ")
> -            # Implicit +1 for heading in the containing .rst doc
> -            level = len(leader) + 1
> -
> -            # https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#sections
> -            markers = ' #*=_^"'
> -            overline = level <= 2
> -            marker = markers[level]
> -
> -            self.ensure_blank_line()
> -            # This credits all 2 or 3 lines to the single source line.
> -            if overline:
> -                self.add_line(marker * len(heading), info)
> -            self.add_line(heading, info)
> -            self.add_line(marker * len(heading), info)
> -            self.ensure_blank_line()
> -
> -            # Eat blank line(s) and advance info
> -            trimmed = text.lstrip("\n")
> -            text = trimmed
> -            info = info.next_line(len(text) - len(trimmed) + 1)
> -
> -        self.add_lines(text, info)
> +        self.add_lines(body.text, doc.info)
>          self.ensure_blank_line()
>  
>      def visit_entity(self, ent: QAPISchemaDefinition) -> None:

Lovely.

Left in scripts/qapi/parser.py:

                elif line.startswith('='):
                    raise QAPIParseError(
                        self,
                        "unexpected '=' markup in definition documentation")

with test case tests/qapi-schema/doc-bad-section.json.

We might want to reject '=' markup anywhere for a while, to catch
outmoded headings.

[...]

Fails "make check".  Fixup:

diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
index 3711cf5480..f60a24d1b7 100644
--- a/tests/qapi-schema/doc-good.out
+++ b/tests/qapi-schema/doc-good.out
@@ -55,13 +55,16 @@ event EVT_BOXED Object
     feature feat3
 doc freeform
     body=
-= Section
+*******
+Section
+*******
 doc freeform
     body=
 Just text, no heading.
 doc freeform
     body=
-== Subsection
+Subsection
+==========
 
 *with emphasis*
 @var {in braces}
@@ -155,7 +158,8 @@ description starts on the same line
 a feature
 doc freeform
     body=
-== Another subsection
+Another subsection
+==================
 doc symbol=cmd
     body=
 



      reply	other threads:[~2025-06-16 12:36 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
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 [this message]

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=87wm9bg8yy.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.