From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D2B1C27C53 for ; Wed, 19 Jun 2024 17:33:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJzBD-0006Jz-F0; Wed, 19 Jun 2024 13:33:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJzBC-0006Jh-Qt for qemu-devel@nongnu.org; Wed, 19 Jun 2024 13:33:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJzBA-0004Qj-LK for qemu-devel@nongnu.org; Wed, 19 Jun 2024 13:33:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718818384; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6nz4sDMlkhC/G+NOoN1TcyhswwSBHtT2TzqqP2NtNzU=; b=YOD3YHbQA9p2YNHqknGJUc0qlyHADZiscyXsgTmmXuBs67ACiSeyXvoImit0ysvPJshNdy J1KML+IuzYgJnf++jMtK3Zg2YWFLWIoRgiMpC5yJ1T8+yr2F3qL1FQ1eEe2rJDo0e+QZqR Z03jOpC91nusLSUSRSHcWA9VL1PD8YM= Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-14-8A1Tb4x3NPmSMGrRILzb_Q-1; Wed, 19 Jun 2024 13:33:02 -0400 X-MC-Unique: 8A1Tb4x3NPmSMGrRILzb_Q-1 Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-1f6efc8759dso5875ad.2 for ; Wed, 19 Jun 2024 10:33:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718818376; x=1719423176; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6nz4sDMlkhC/G+NOoN1TcyhswwSBHtT2TzqqP2NtNzU=; b=fNrN1oNN08tsn2WFT2Q7lQvhPcmBF+S8sg7Dz3PWyXtREOhsMEI03PYcUHXzm8P66n klS4FR129ZV0wmdCro9LpP6hpQq6zI9upi+VHnOndGSCdFerTt0rDREYxsCxUtgcC1W9 9BLQ/TLcN8YMnIBekqKkDehY8nuPCod3QmAthuTjdCegaeolw+wFEvc3CkHc1Dw+5VxD Fpx+URB7rgoY2qez+OcZv21XWrqsVQ3MN1pko1yaCLxUqz75hCURQZ2Kwxt45x/Qeglk EpL65iSnLNrdf/SaFlCinRyOfDBoBID/J766DcE9X4NFcVmQEtlMkW3moLLQY61FUUge POxg== X-Gm-Message-State: AOJu0YzfLkdPGxnfYVer2qmSLJVGsvh/FR2iKRDsnyEh295JS47Q9jmI WePhZXjvcf+oG5wwY2Ewmt0dvWA24FndjgKns4q/JXEGKvXM6575CHFNwjlWR0BQPxIXNPRE1Kv TjzdlEyI5RFG8AQkveGNm4bnRBuS90WFU7n1ko9po+W8X8tnf2EdkAE5zNcO1of6gYBrI2rBaLH +SCoYlbstNIiTtI+dPB8Lpg4pOiMc= X-Received: by 2002:a17:902:a3ce:b0:1f9:b807:21ac with SMTP id d9443c01a7336-1f9b80721fcmr16181025ad.51.1718818376632; Wed, 19 Jun 2024 10:32:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFNFD7yhI3NZF3+Icm/wI2ujBuBVTfUlkptNZLWsrOO2xcdMg3izaHKkUvMsU4/GKnRXMmHKSbiWDr6edt7KM= X-Received: by 2002:a17:902:a3ce:b0:1f9:b807:21ac with SMTP id d9443c01a7336-1f9b80721fcmr16180745ad.51.1718818376250; Wed, 19 Jun 2024 10:32:56 -0700 (PDT) MIME-Version: 1.0 References: <20240619003012.1753577-1-jsnow@redhat.com> <20240619003012.1753577-14-jsnow@redhat.com> <87sex9xe5u.fsf@pond.sub.org> In-Reply-To: <87sex9xe5u.fsf@pond.sub.org> From: John Snow Date: Wed, 19 Jun 2024 13:32:44 -0400 Message-ID: Subject: Re: [PATCH 13/13] qapi: convert "Example" sections to rST To: Markus Armbruster Cc: qemu-devel , Stefan Hajnoczi , Hanna Reitz , Michael Roth , =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= , Victor Toso de Carvalho , "Michael S. Tsirkin" , Konstantin Kostiuk , Yanan Wang , Pavel Dovgalyuk , =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= , Marcel Apfelbaum , Fabiano Rosas , Lukas Straub , Eduardo Habkost , Mads Ynddal , =?UTF-8?Q?Daniel_P=2E_Berrang=C3=A9?= , Gerd Hoffmann , Stefan Berger , Peter Xu , Igor Mammedov , =?UTF-8?Q?C=C3=A9dric_Le_Goater?= , Jason Wang , Ani Sinha , Paolo Bonzini , Peter Maydell , Qemu-block , Jiri Pirko , Alex Williamson , Kevin Wolf , Eric Blake Content-Type: multipart/alternative; boundary="000000000000c01c43061b4196b4" Received-SPF: pass client-ip=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org --000000000000c01c43061b4196b4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jun 19, 2024, 9:20=E2=80=AFAM Markus Armbruster = wrote: > John Snow writes: > > > Eliminate the "Example" sections in QAPI doc blocks, converting them > > into QMP example code blocks. This is generally done in this patch by > > converting "Example:" or "Examples:" lines into ".. code-block:: QMP" > > lines. > > > > The old "Example:" or "Examples:" syntax is now caught as an error; but > > with the previous commit, "Example::" is still permitted as explicit rS= T > > syntax. ('Example' is not special in this case; any sentence that ends > > with "::" will start an indented code block in rST.) > > > > The ".. code-block:: QMP" form explicitly applies the QMP lexer and wil= l > > loosely validate an example as valid QMP/JSON. The "::" form does not > > apply any lexer in particular and will not emit any errors. > > > > It is possible to choose the QMP lexer with the "::" form by using the > > Sphinx directive ".. highlight:: QMP" in the document above where the > > example appears; but this changes the lexer for *all* subsequent "::" > > style code-blocks in the document thereafter. > > > > This patch does not change the default lexer for the legacy qapidoc > > generator documents; future patches for the new qapidoc generator *may* > > change this default. > > > > This patch has several benefits: > > > > 1. Example sections can now be written more arbitrarily, mixing > > explanatory paragraphs and code blocks however desired. > > > > 2. "Example sections" can now use fully arbitrary rST. > > Do the double-quotes signify something I'm missing? > They aren't *sections* (QAPIDoc terminology) anymore, but was at a loss for more precise phrasing. > > > > 3. All code blocks are now lexed and validated as QMP; increasing > > usability of the docs and ensuring validity of example snippets. > > > > (To some extent - This patch only gaurantees it lexes correctly, not > > that it's valid under the JSON or QMP grammars. It will catch most > > small mistakes, however.) > > > > 4. Each code-block can be captioned independently without bypassing the > > QMP lexer/validator. > > > > (i.e. code blocks are now for *code* only, so we don't have to > > sacrifice annotations/captions for having lexicographically correct > > examples.) > > > > For any sections with more than one example, examples are split up into > > multiple code-block regions. If annotations are present, those > > annotations are converted into code-block captions instead, e.g. > > > > ``` > > Examples: > > > > 1. Lorem Ipsum > > > > -> { "foo": "bar" } > > ``` > > > > Is rewritten as: > > > > ``` > > .. code-block:: QMP > > :caption: Example: Lorem Ipsum > > > > -> { "foo": "bar" } > > ``` > > > > This process was only semi-automated: > > > > 1. Replace "Examples?:" sections with sed: > > > > sed -i 's|# Example:|# .. code-block:: QMP|' *.json > > sed -i 's|# Examples:|# .. code-block:: QMP|' *.json > > > > 2. Identify sections that no longer parse successfully by attempting th= e > > doc build, convert annotations into captions manually. > > (Tedious, oh well.) > > > > 3. Add captions where still needed: > > > > sed -zi 's|# .. code-block:: QMP\n#\n|# .. code-block:: QMP\n# > :caption: Example\n#\n|g' *.json > > > > Not fully ideal, but hopefully not something that has to be done very > > often. (Or ever again.) > > > > Signed-off-by: John Snow > > Acked-by: Stefan Hajnoczi [for block*.json] > > [...] > > > diff --git a/qapi/pci.json b/qapi/pci.json > > index f51159a2c4c..9192212661b 100644 > > --- a/qapi/pci.json > > +++ b/qapi/pci.json > > @@ -182,7 +182,8 @@ > > # > > # Since: 0.14 > > # > > -# Example: > > +# .. code-block:: QMP > > +# :caption: Example > > # > > # -> { "execute": "query-pci" } > > # <- { "return": [ > > @@ -311,8 +312,7 @@ > > # ] > > # } > > # > > -# Note: This example has been shortened as the real response is to= o > > -# long. > > +# This example has been shortened as the real response is too long. > > Squash into PATCH 09. > > > # > > ## > > { 'command': 'query-pci', 'returns': ['PciInfo'] } > > Otherwise looks good to me except for the somewhat ugly rendering in > HTML mentioned in the commit message. > ACK > [...] > > --000000000000c01c43061b4196b4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Wed, Jun 19, 2024, 9:20=E2=80=AFAM Markus Armbruste= r <armbru@redhat.com> wrote:=
John Snow <jsnow@redhat.com&g= t; writes:

> Eliminate the "Example" sections in QAPI doc blocks, convert= ing them
> into QMP example code blocks. This is generally done in this patch by<= br> > converting "Example:" or "Examples:" lines into &q= uot;.. code-block:: QMP"
> lines.
>
> The old "Example:" or "Examples:" syntax is now ca= ught as an error; but
> with the previous commit, "Example::" is still permitted as = explicit rST
> syntax. ('Example' is not special in this case; any sentence t= hat ends
> with "::" will start an indented code block in rST.)
>
> The ".. code-block:: QMP" form explicitly applies the QMP le= xer and will
> loosely validate an example as valid QMP/JSON. The "::" form= does not
> apply any lexer in particular and will not emit any errors.
>
> It is possible to choose the QMP lexer with the "::" form by= using the
> Sphinx directive ".. highlight:: QMP" in the document above = where the
> example appears; but this changes the lexer for *all* subsequent "= ;::"
> style code-blocks in the document thereafter.
>
> This patch does not change the default lexer for the legacy qapidoc > generator documents; future patches for the new qapidoc generator *may= *
> change this default.
>
> This patch has several benefits:
>
> 1. Example sections can now be written more arbitrarily, mixing
>=C2=A0 =C2=A0 explanatory paragraphs and code blocks however desired. >
> 2. "Example sections" can now use fully arbitrary rST.

Do the double-quotes signify something I'm missing?

They aren't *sec= tions* (QAPIDoc terminology) anymore, but was at a loss for more precise ph= rasing.


>
> 3. All code blocks are now lexed and validated as QMP; increasing
>=C2=A0 =C2=A0 usability of the docs and ensuring validity of example sn= ippets.
>
>=C2=A0 =C2=A0 (To some extent - This patch only gaurantees it lexes cor= rectly, not
>=C2=A0 =C2=A0 that it's valid under the JSON or QMP grammars. It wi= ll catch most
>=C2=A0 =C2=A0 small mistakes, however.)
>
> 4. Each code-block can be captioned independently without bypassing th= e
>=C2=A0 =C2=A0 QMP lexer/validator.
>
>=C2=A0 =C2=A0 (i.e. code blocks are now for *code* only, so we don'= t have to
>=C2=A0 =C2=A0 sacrifice annotations/captions for having lexicographical= ly correct
>=C2=A0 =C2=A0 examples.)
>
> For any sections with more than one example, examples are split up int= o
> multiple code-block regions. If annotations are present, those
> annotations are converted into code-block captions instead, e.g.
>
> ```
> Examples:
>
>=C2=A0 =C2=A0 1. Lorem Ipsum
>
>=C2=A0 =C2=A0 -> { "foo": "bar" }
> ```
>
> Is rewritten as:
>
> ```
> .. code-block:: QMP
>=C2=A0 =C2=A0 :caption: Example: Lorem Ipsum
>
>=C2=A0 =C2=A0 -> { "foo": "bar" }
> ```
>
> This process was only semi-automated:
>
> 1. Replace "Examples?:" sections with sed:
>
> sed -i 's|# Example:|# .. code-block:: QMP|' *.json
> sed -i 's|# Examples:|# .. code-block:: QMP|' *.json
>
> 2. Identify sections that no longer parse successfully by attempting t= he
>=C2=A0 =C2=A0 doc build, convert annotations into captions manually. >=C2=A0 =C2=A0 (Tedious, oh well.)
>
> 3. Add captions where still needed:
>
> sed -zi 's|# .. code-block:: QMP\n#\n|# .. code-block:: QMP\n#=C2= =A0 =C2=A0 :caption: Example\n#\n|g' *.json
>
> Not fully ideal, but hopefully not something that has to be done very<= br> > often. (Or ever again.)
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> Acked-by: Stefan Hajnoczi <stefanha@redhat.com> [for block*= .json]

[...]

> diff --git a/qapi/pci.json b/qapi/pci.json
> index f51159a2c4c..9192212661b 100644
> --- a/qapi/pci.json
> +++ b/qapi/pci.json
> @@ -182,7 +182,8 @@
>=C2=A0 #
>=C2=A0 # Since: 0.14
>=C2=A0 #
> -# Example:
> +# .. code-block:: QMP
> +#=C2=A0 =C2=A0 :caption: Example
>=C2=A0 #
>=C2=A0 #=C2=A0 =C2=A0 =C2=A0-> { "execute": "query-pc= i" }
>=C2=A0 #=C2=A0 =C2=A0 =C2=A0<- { "return": [
> @@ -311,8 +312,7 @@
>=C2=A0 #=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0]
>=C2=A0 #=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
>=C2=A0 #
> -#=C2=A0 =C2=A0 =C2=A0Note: This example has been shortened as the rea= l response is too
> -#=C2=A0 =C2=A0 =C2=A0long.
> +# This example has been shortened as the real response is too long.
Squash into PATCH 09.

>=C2=A0 #
>=C2=A0 ##
>=C2=A0 { 'command': 'query-pci', 'returns': [&#= 39;PciInfo'] }

Otherwise looks good to me except for the somewhat ugly rendering in
HTML mentioned in the commit message.

ACK

=

[...]

--000000000000c01c43061b4196b4--