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 <qemu-devel@nongnu.org>,
	 Peter Maydell <peter.maydell@linaro.org>,
	 Michael Roth <michael.roth@amd.com>
Subject: Re: [PATCH 04/23] qapi: expand tags to all doc sections
Date: Fri, 10 Jan 2025 08:33:29 +0100	[thread overview]
Message-ID: <87a5bz6s3a.fsf@pond.sub.org> (raw)
In-Reply-To: <CAFn=p-b51afQQDo7qd_T5EPyunuxGY-N8hjzbim5894JGwTEjA@mail.gmail.com> (John Snow's message of "Thu, 9 Jan 2025 13:49:13 -0500")

John Snow <jsnow@redhat.com> writes:

> On Fri, Dec 20, 2024, 8:13 AM Markus Armbruster <armbru@redhat.com> wrote:
>
>> John Snow <jsnow@redhat.com> writes:
>>
>> > This patch adds an explicit section tag to all QAPIDoc
>> > sections. Members/Features are now explicitly tagged as such, with the
>> > name now being stored in a dedicated "name" field (which qapidoc.py was
>> > not actually using anyway.)
>> >
>> > WIP: Yeah, the difference between "tagged" and "untagged" sections is
>> > now pretty poorly named, and explicitly giving "untagged" sections an
>> > "UNTAGGED" tag is ... well, worse. but mechanically, this accomplishes
>> > what I need for the series.
>> >
>> > Please suggest better naming conventions, keeping in mind that I
>> > currently have plans for a future patch that splits the "UNTAGGED" tag
>> > into "INTRO" and "DETAILS" tags. But, we still need a meta-name for the
>> > category of sections that are "formerly known as untagged" but cannot be
>> > called "freeform" because that name is used for the category of
>> > docblocks that are not attached to an entity (but happens to be
>> > comprised entirely of "formerly known as untagged" sections.)
>> >
>> > Signed-off-by: John Snow <jsnow@redhat.com>
>>
>> A free-form doc comment consists of just one untagged section, actually.
>> I don't remember whether anything relies on "just one".
>>
>
> Sure, yes. Sorry, I keep thinking of documentation as containing "any
> number of sections" but keep eliding the fact that our parser
> implementation currently will never actually create multiple adjacent
> "untagged" sections.

Yes, the parsers grows an untagged section until another section starts.
An untagged section can consist of multiple paragraphs, just like tagged
sections.

> I don't even change this anywhere even in my offline WIP, so it's just me
> being over-general.
>
> (I don't think it winds up being relevant or mattering to anything in this
> series or my larger project beyond some word choices.)
>
>> The term "tagged" is rooted in doc comment syntax.
>> docs/devel/qapi-code-gen.rst section "Definition documentation":
>>
>>     Definition documentation starts with a line naming the definition,
>>     followed by an optional overview, a description of each argument (for
>>     commands and events), member (for structs and unions), branch (for
>>     alternates), or value (for enums), a description of each feature (if
>>     any), and finally optional tagged sections.
>>
>> Sadly, this isn't fully accurate anymore.
>>
>>     Descriptions start with '\@name:'.  The description text must be
>>     indented [...]
>>
>>     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
>>     [...]
>>
>> Nothing about untagged sections.  These are sections that aren't
>> descriptions or tagged.  Example:
>>
>>     # @Returns: Lorem ipsum dolor sit amet, consectetur adipiscing elit,
>>     #     sed do eiusmod tempor incididunt ut labore et dolore magna
>>     #     aliqua.
>>     #
>>     # 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.
>>     ##
>>
>> Here, the tagged "Returns" section ends after "aliqua."  Why?  Because
>> "Ut enim" isn't indented.  The untagged section ends after "pariatur."
>>
>> We parse a definition doc comment as a sequence of sections.
>>
>> The first one is the overview.
>>
>> Member / argument descriptions, if any, are next.
>>
>> Then we may have any number of tagged or untagged sections.  If I
>> remember correctly, you'd like to banish them.  Let's pretend they can't
>> exist here.
>>
>
> I think you're referring to my desire to banish "untagged" sections from
> appearing *between* "tagged" sections.

Editing accident, sorry!  You interpreted it correctly.

>                                        Yes, that's still a desire; though I
> make no movement on it in this series as sent to list, and this change is
> entirely unrelated to that desire.
>
> (It's more related to being able to distinguish features from members, and
> later, distinguishing intro/details. This patch still serves a purpose even
> without the inliner or the complexities it brings, but serves both needs.)
>
> ((Reminder: the reason for this desire is because "tagged sections" are
> rendered in html as a two-column list, and free paragraphs appearing
> between list entries looks bad in the rendered documentation, because it
> means ending the table, starting paragraph(s), then starting a new table.
> If free text is meant to be associated with a specific
> member/feature/section-group, it should be marked up (in SOME way) so that
> the renderer can achieve that grouping visually.
>
> (There will be a standalone patch that implements this restriction and we
> can debate this there, I'm only giving you context here.)))
>
>
>> Then we may have a "Features:" line followed by feature descriptions.
>>
>> Finally, we may have any number of tagged or untagged sections.
>>
>> Each of these sections is represented as an instance of type Section,
>> and the entire definition doc as an instance of type QAPIDoc.
>>
>> Section has a member @tag of type str.
>>
>> For tagged sections, it's the tag, i.e "Since", "Returns", ...  Obvious
>> enough.
>>
>> For overview and other untagged sections, it's None.  Still obvious.
>>
>> For descriptions, it's the name of the thing being described.  Less than
>> obvious.  Note that descriptions are actually instances of ArgSection, a
>> subtype of Section, which prevents confusion with tagged sections.
>>
>
> Note that this patch changes this as well; it becomes "member" or "feature"
> as appropriate and the name is moved into a dedicated name field that
> belongs to the ArgSection class.
>
> (Turns out legacy qapidoc doesn't use this stored name at all anyway, it
> fetches the name via the linked feature/member instead.)
>
>
>> QAPIDoc has the overview in member @body, member / argument descriptions
>> in @args, feature descriptions in @features, and the remaining sections
>> in @sections.
>>
>> I'm in favor of cleaning this up some.
>>
>> I think we can keep the Section name.
>>
>> Moving the name of the thing being described from @tag to @name is good.
>> What value to put into @tag then?  Whatever suits you.
>>
>
> What suits me is "member" and "feature". :)

Okay.

Doesn't entirely clean up the terminology mess.  According to
docs/devel/qapi-code-gen.rst, struct and union types have members,
alternate types have alternatives, enum types have values, commands have
arguments, and events have event-specific data, which is a mouthful, so
we often say arguments.  Using one of them ("member") to refer to the
generalization of them all is suboptimal, but it's no worse than before.

ArgSection is even more general: it's features, too.  Again, no worse
than before.

I'm *not* asking you to clean this up.  I'm just pointing out we could
use fresh naming ideas here.

>> Perhaps we should rename @tag to avoid undue ties to tagged sections.
>> @kind would work for me.
>>
>
> Sold!
>
>
>> Value None for untagged sections is fine with me.  If a string suits you
>> better, that's fine, too.  "untagged", "plain", I don't know, propose
>> something.
>>
>
> For static typing reasons, an explicit tag is preferred to distinguish from
> it being "optional".
>
> I could cope with any of:
>
> "plain",
> "text",
> "plaintext",
> "paragraphs",
> "unstructured",
> "free"
>
> ... keeping in mind that I do intend to "split" this tag/kind into "intro"
> and "details" later. i.e. this is a temporary tag/kind label.
>
> I think I like "text" the most because it says the least. What about you?

Point, but the other kinds of section are text, too.  "plain"?

>> @body, @args, and so forth aren't exactly great names.  If they truly
>> annoy or confuse you, feel free to propose better ones.
>>
>
> I believe they can be removed entirely once the old qapidoc is sunset,
> leaving only .sections[] behind.
>
> This removes the temptation to pick out sections "out of order".

I've long wanted strict in-order processing, to avoid surprising
reordering of input in the output.

> We only need the list of sections in their source order to generate the
> appropriate rST.
>
> (Note: the inliner actually does need to filter sections somewhat to do its
> inlining magic, but we'll talk about that later. All you need to know right
> now is that my WIP does not utilize any field except .sections[], so the
> others can in fact be dropped as redundant once we make the switch. This
> patch helps enable the paradigm of "everything you need to render a section
> is contained within the Section object itself" which lends itself well to
> the new transmogrifier, the goal of always processing/rendering in source
> order, and facilitating the mechanics of the inliner.)
>
> ...
>
> In case I got too rambly, my action items for this patch are:
>
> - fix the test (already done)
> - rename tag to kind
> - rename "untagged" to "text", possibly changing it again pending your
> feedback.

Sounds good!



  reply	other threads:[~2025-01-10  7:34 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-13  2:18 [PATCH 00/23] docs: add basic sphinx-domain rST generator to qapidoc John Snow
2024-12-13  2:18 ` [PATCH 01/23] docs/qapidoc: support header-less freeform sections John Snow
2024-12-16 13:15   ` Markus Armbruster
2025-01-13 19:12     ` John Snow
2025-01-14  9:19       ` Markus Armbruster
2024-12-13  2:18 ` [PATCH 02/23] qapi/parser: adjust info location for doc body section John Snow
2024-12-13  2:18 ` [PATCH 03/23] docs/qapidoc: remove example section support John Snow
2024-12-18 12:27   ` Markus Armbruster
2024-12-18 15:15     ` John Snow
2025-01-09  7:50       ` Markus Armbruster
2024-12-13  2:18 ` [PATCH 04/23] qapi: expand tags to all doc sections John Snow
2024-12-18 10:58   ` Markus Armbruster
2024-12-18 15:14     ` John Snow
2025-01-09  7:51       ` Markus Armbruster
2024-12-20 13:13   ` Markus Armbruster
2025-01-09 18:49     ` John Snow
2025-01-10  7:33       ` Markus Armbruster [this message]
2024-12-13  2:18 ` [PATCH 05/23] qapi/schema: add __repr__ to QAPIDoc.Section John Snow
2024-12-13  2:18 ` [PATCH 06/23] docs/qapidoc: add transmogrifier stub John Snow
2024-12-13  2:18 ` [PATCH 07/23] docs/qapidoc: add transmogrifier class stub John Snow
2024-12-13  2:18 ` [PATCH 08/23] docs/qapidoc: add visit_module() method John Snow
2024-12-13  2:18 ` [PATCH 09/23] qapi/source: allow multi-line QAPISourceInfo advancing John Snow
2024-12-20 13:22   ` Markus Armbruster
2025-01-08 21:18     ` John Snow
2025-01-09  8:00       ` Markus Armbruster
2025-01-09 17:19         ` John Snow
2025-01-10  7:37           ` Markus Armbruster
2024-12-13  2:18 ` [PATCH 10/23] docs/qapidoc: add visit_freeform() method John Snow
2024-12-20 13:25   ` Markus Armbruster
2025-01-13 20:14     ` John Snow
2024-12-13  2:18 ` [PATCH 11/23] docs/qapidoc: add preamble() method John Snow
2024-12-20 14:15   ` Markus Armbruster
2025-01-08 22:58     ` John Snow
2025-01-09 10:34       ` Markus Armbruster
2025-01-09 18:04         ` John Snow
2025-01-10 12:19           ` Markus Armbruster
2025-01-13 20:53             ` John Snow
2025-01-14  9:30               ` Markus Armbruster
2024-12-13  2:18 ` [PATCH 12/23] docs/qapidoc: add visit_paragraph() method John Snow
2024-12-13  2:18 ` [PATCH 13/23] docs/qapidoc: add visit_errors() method John Snow
2024-12-13  2:18 ` [PATCH 14/23] docs/qapidoc: add format_type() method John Snow
2024-12-13  2:18 ` [PATCH 15/23] docs/qapidoc: add add_field() and generate_field() helper methods John Snow
2024-12-13  2:18 ` [PATCH 16/23] docs/qapidoc: add visit_feature() method John Snow
2024-12-20 14:21   ` Markus Armbruster
2025-01-08 22:46     ` John Snow
2024-12-13  2:18 ` [PATCH 17/23] docs/qapidoc: record current documented entity in transmogrifier John Snow
2024-12-20 14:23   ` Markus Armbruster
2025-01-08 21:11     ` John Snow
2025-01-09 10:35       ` Markus Armbruster
2024-12-13  2:18 ` [PATCH 18/23] docs/qapidoc: add visit_returns() method John Snow
2024-12-13  2:18 ` [PATCH 19/23] docs/qapidoc: add visit_member() method John Snow
2024-12-13  2:18 ` [PATCH 20/23] docs/qapidoc: add visit_sections() method John Snow
2024-12-13  2:18 ` [PATCH 21/23] docs/qapidoc: add visit_entity() John Snow
2024-12-13  2:18 ` [PATCH 22/23] docs/qapidoc: implement transmogrify() method John Snow
2024-12-13  2:18 ` [PATCH 23/23] docs/qapidoc: add transmogrifier test document John Snow
2024-12-19 12:31 ` [PATCH 00/23] docs: add basic sphinx-domain rST generator to qapidoc Markus Armbruster
2025-01-08 21:08   ` John Snow
2025-01-09 11:48     ` Markus Armbruster
2025-01-09 17:26       ` John Snow

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=87a5bz6s3a.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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.