qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] docs: convert qapi-code-gen.txt to qapi-code-gen.rst
@ 2021-07-20 23:56 John Snow
  2021-07-20 23:56 ` [PATCH 1/3] docs: convert qapi-code-gen.txt to ReST John Snow
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: John Snow @ 2021-07-20 23:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael Roth, John Snow, Markus Armbruster

Patch 1 does (roughly) the bare minimum, patch 2 adds some formatting,
and patch 3 adds cross-references.

John Snow (3):
  docs: convert qapi-code-gen.txt to ReST
  docs/qapi-code-gen: Beautify formatting
  docs/qapi-code-gen: add cross-references

 docs/devel/index.rst                          |   1 +
 .../{qapi-code-gen.txt => qapi-code-gen.rst}  | 800 ++++++++++--------
 2 files changed, 441 insertions(+), 360 deletions(-)
 rename docs/devel/{qapi-code-gen.txt => qapi-code-gen.rst} (76%)

-- 
2.31.1




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] docs: convert qapi-code-gen.txt to ReST
  2021-07-20 23:56 [PATCH 0/3] docs: convert qapi-code-gen.txt to qapi-code-gen.rst John Snow
@ 2021-07-20 23:56 ` John Snow
  2021-07-20 23:56 ` [PATCH 2/3] docs/qapi-code-gen: Beautify formatting John Snow
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: John Snow @ 2021-07-20 23:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael Roth, John Snow, Markus Armbruster

This is a very rudimentary conversion from .txt to .rst changing as
little as possible, but getting it to render somewhat nicely; without
using any Sphinx directives. (It is 'native' ReST.)

Further patches will add cross-references and Sphinx-specific extensions
to make it sparkle.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 docs/devel/index.rst                          |   1 +
 .../{qapi-code-gen.txt => qapi-code-gen.rst}  | 559 ++++++++++--------
 2 files changed, 312 insertions(+), 248 deletions(-)
 rename docs/devel/{qapi-code-gen.txt => qapi-code-gen.rst} (86%)

diff --git a/docs/devel/index.rst b/docs/devel/index.rst
index 153979caf4b..bfba3a8daa6 100644
--- a/docs/devel/index.rst
+++ b/docs/devel/index.rst
@@ -42,3 +42,4 @@ modifying QEMU's source code.
    multi-process
    ebpf_rss
    vfio-migration
+   qapi-code-gen
diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.rst
similarity index 86%
rename from docs/devel/qapi-code-gen.txt
rename to docs/devel/qapi-code-gen.rst
index c1cb6f987de..b79ecddb599 100644
--- a/docs/devel/qapi-code-gen.txt
+++ b/docs/devel/qapi-code-gen.rst
@@ -1,12 +1,17 @@
-= How to use the QAPI code generator =
+==================================
+How to use the QAPI code generator
+==================================
 
-Copyright IBM Corp. 2011
-Copyright (C) 2012-2016 Red Hat, Inc.
+..
+   Copyright IBM Corp. 2011
+   Copyright (C) 2012-2016 Red Hat, Inc.
 
-This work is licensed under the terms of the GNU GPL, version 2 or
-later.  See the COPYING file in the top-level directory.
+   This work is licensed under the terms of the GNU GPL, version 2 or
+   later.  See the COPYING file in the top-level directory.
 
-== Introduction ==
+
+Introduction
+============
 
 QAPI is a native C API within QEMU which provides management-level
 functionality to internal and external users.  For external
@@ -23,7 +28,8 @@ Protocol and to C.  It additionally provides guidance on maintaining
 Client JSON Protocol compatibility.
 
 
-== The QAPI schema language ==
+The QAPI schema language
+========================
 
 The QAPI schema defines the Client JSON Protocol's commands and
 events, as well as types used by them.  Forward references are
@@ -39,9 +45,10 @@ complex types (structs and two flavors of unions), and alternate types
 (a choice between other types).
 
 
-=== Schema syntax ===
+Schema syntax
+-------------
 
-Syntax is loosely based on JSON (http://www.ietf.org/rfc/rfc8259.txt).
+Syntax is loosely based on `JSON <http://www.ietf.org/rfc/rfc8259.txt>`_.
 Differences:
 
 * Comments: start with a hash character (#) that is not part of a
@@ -79,7 +86,7 @@ syntax in an EBNF-like notation:
 The order of members within JSON objects does not matter unless
 explicitly noted.
 
-A QAPI schema consists of a series of top-level expressions:
+A QAPI schema consists of a series of top-level expressions::
 
     SCHEMA = TOP-LEVEL-EXPR...
 
@@ -87,11 +94,11 @@ The top-level expressions are all JSON objects.  Code and
 documentation is generated in schema definition order.  Code order
 should not matter.
 
-A top-level expressions is either a directive or a definition:
+A top-level expressions is either a directive or a definition::
 
     TOP-LEVEL-EXPR = DIRECTIVE | DEFINITION
 
-There are two kinds of directives and six kinds of definitions:
+There are two kinds of directives and six kinds of definitions::
 
     DIRECTIVE = INCLUDE | PRAGMA
     DEFINITION = ENUM | STRUCT | UNION | ALTERNATE | COMMAND | EVENT
@@ -99,9 +106,10 @@ There are two kinds of directives and six kinds of definitions:
 These are discussed in detail below.
 
 
-=== Built-in Types ===
+Built-in Types
+--------------
 
-The following types are predefined, and map to C as follows:
+The following types are predefined, and map to C as follows::
 
   Schema    C          JSON
   str       char *     any JSON string, UTF-8
@@ -124,12 +132,14 @@ The following types are predefined, and map to C as follows:
   QType     QType      JSON string matching enum QType values
 
 
-=== Include directives ===
+Include directives
+------------------
+
+Syntax::
 
-Syntax:
     INCLUDE = { 'include': STRING }
 
-The QAPI schema definitions can be modularized using the 'include' directive:
+The QAPI schema definitions can be modularized using the 'include' directive::
 
  { 'include': 'path/to/file.json' }
 
@@ -144,9 +154,11 @@ an outer file.  The parser may be made stricter in the future to
 prevent incomplete include files.
 
 
-=== Pragma directives ===
+Pragma directives
+-----------------
+
+Syntax::
 
-Syntax:
     PRAGMA = { 'pragma': {
                    '*doc-required': BOOL,
                    '*command-name-exceptions': [ STRING, ... ],
@@ -172,9 +184,11 @@ names may contain uppercase letters, and '_' instead of '-'.  Default
 is none.
 
 
-=== Enumeration types ===
+Enumeration types
+-----------------
+
+Syntax::
 
-Syntax:
     ENUM = { 'enum': STRING,
              'data': [ ENUM-VALUE, ... ],
              '*prefix': STRING,
@@ -189,7 +203,7 @@ Each member of the 'data' array defines a value of the enumeration
 type.  The form STRING is shorthand for { 'name': STRING }.  The
 'name' values must be be distinct.
 
-Example:
+Example::
 
  { 'enum': 'MyEnum', 'data': [ 'value1', 'value2', 'value3' ] }
 
@@ -218,9 +232,11 @@ The optional 'features' member specifies features.  See "Features"
 below for more on this.
 
 
-=== Type references and array types ===
+Type references and array types
+-------------------------------
+
+Syntax::
 
-Syntax:
     TYPE-REF = STRING | ARRAY-TYPE
     ARRAY-TYPE = [ STRING ]
 
@@ -230,9 +246,11 @@ A one-element array containing a string denotes an array of the type
 named by the string.  Example: ['int'] denotes an array of 'int'.
 
 
-=== Struct types ===
+Struct types
+------------
+
+Syntax::
 
-Syntax:
     STRUCT = { 'struct': STRING,
                'data': MEMBERS,
                '*base': STRING,
@@ -254,7 +272,7 @@ struct member name.  If '*' is present, the member is optional.
 The MEMBER's value defines its properties, in particular its type.
 The form TYPE-REF is shorthand for { 'type': TYPE-REF }.
 
-Example:
+Example::
 
  { 'struct': 'MyType',
    'data': { 'member1': 'str', 'member2': ['int'], '*member3': 'str' } }
@@ -265,7 +283,7 @@ The C struct's members are generated in QAPI schema order.
 The optional 'base' member names a struct type whose members are to be
 included in this type.  They go first in the C struct.
 
-Example:
+Example::
 
  { 'struct': 'BlockdevOptionsGenericFormat',
    'data': { 'file': 'str' } }
@@ -274,7 +292,7 @@ Example:
    'data': { '*backing': 'str' } }
 
 An example BlockdevOptionsGenericCOWFormat object on the wire could use
-both members like this:
+both members like this::
 
  { "file": "/some/place/my-image",
    "backing": "/some/place/my-backing-file" }
@@ -286,9 +304,11 @@ The optional 'features' member specifies features.  See "Features"
 below for more on this.
 
 
-=== Union types ===
+Union types
+-----------
+
+Syntax::
 
-Syntax:
     UNION = { 'union': STRING,
               'data': BRANCHES,
               '*if': COND,
@@ -317,7 +337,7 @@ The BRANCH's value defines the branch's properties, in particular its
 type.  The form TYPE-REF is shorthand for { 'type': TYPE-REF }.
 
 A simple union type defines a mapping from automatic discriminator
-values to data types like in this example:
+values to data types like in this example::
 
  { 'struct': 'BlockdevOptionsFile', 'data': { 'filename': 'str' } }
  { 'struct': 'BlockdevOptionsQcow2',
@@ -330,7 +350,7 @@ values to data types like in this example:
 In the Client JSON Protocol, a simple union is represented by an
 object that contains the 'type' member as a discriminator, and a
 'data' member that is of the specified data type corresponding to the
-discriminator value, as in these examples:
+discriminator value, as in these examples::
 
  { "type": "file", "data": { "filename": "/some/place/my-image" } }
  { "type": "qcow2", "data": { "backing": "/some/place/my-image",
@@ -361,7 +381,7 @@ struct.
 The following example enhances the above simple union example by
 adding an optional common member 'read-only', renaming the
 discriminator to something more applicable than the simple union's
-default of 'type', and reducing the number of {} required on the wire:
+default of 'type', and reducing the number of {} required on the wire::
 
  { 'enum': 'BlockdevDriver', 'data': [ 'file', 'qcow2' ] }
  { 'union': 'BlockdevOptions',
@@ -370,7 +390,7 @@ default of 'type', and reducing the number of {} required on the wire:
    'data': { 'file': 'BlockdevOptionsFile',
              'qcow2': 'BlockdevOptionsQcow2' } }
 
-Resulting in these JSON objects:
+Resulting in these JSON objects::
 
  { "driver": "file", "read-only": true,
    "filename": "/some/place/my-image" }
@@ -390,11 +410,11 @@ struct.
 
 A simple union can always be re-written as a flat union where the base
 class has a single member named 'type', and where each branch of the
-union has a struct with a single member named 'data'.  That is,
+union has a struct with a single member named 'data'.  That is, ::
 
  { 'union': 'Simple', 'data': { 'one': 'str', 'two': 'int' } }
 
-is identical on the wire to:
+is identical on the wire to::
 
  { 'enum': 'Enum', 'data': ['one', 'two'] }
  { 'struct': 'Branch1', 'data': { 'data': 'str' } }
@@ -409,9 +429,11 @@ The optional 'features' member specifies features.  See "Features"
 below for more on this.
 
 
-=== Alternate types ===
+Alternate types
+---------------
+
+Syntax::
 
-Syntax:
     ALTERNATE = { 'alternate': STRING,
                   'data': ALTERNATIVES,
                   '*if': COND,
@@ -430,7 +452,7 @@ The ALTERNATIVE's STRING name is the branch name.
 The ALTERNATIVE's value defines the branch's properties, in particular
 its type.  The form STRING is shorthand for { 'type': STRING }.
 
-Example:
+Example::
 
  { 'alternate': 'BlockdevRef',
    'data': { 'definition': 'BlockdevOptions',
@@ -449,7 +471,7 @@ as the 'null' built-in, it accepts JSON null; and if it is typed as a
 complex type (struct or union), it accepts a JSON object.
 
 The example alternate declaration above allows using both of the
-following example objects:
+following example objects::
 
  { "file": "my_existing_block_device_id" }
  { "file": { "driver": "file",
@@ -463,9 +485,11 @@ The optional 'features' member specifies features.  See "Features"
 below for more on this.
 
 
-=== Commands ===
+Commands
+--------
+
+Syntax::
 
-Syntax:
     COMMAND = { 'command': STRING,
                 (
                 '*data': ( MEMBERS | STRING ),
@@ -508,7 +532,7 @@ member is the command name.  The value of the "arguments" member then
 has to conform to the arguments, and the value of the success
 response's "return" member will conform to the return type.
 
-Some example commands:
+Some example commands::
 
  { 'command': 'my-first-command',
    'data': { 'arg1': 'str', '*arg2': 'str' } }
@@ -516,7 +540,7 @@ Some example commands:
  { 'command': 'my-second-command',
    'returns': [ 'MyType' ] }
 
-which would validate this Client JSON Protocol transaction:
+which would validate this Client JSON Protocol transaction::
 
  => { "execute": "my-first-command",
       "arguments": { "arg1": "hello" } }
@@ -543,7 +567,7 @@ In rare cases, QAPI cannot express a type-safe representation of a
 corresponding Client JSON Protocol command.  You then have to suppress
 generation of a marshalling function by including a member 'gen' with
 boolean value false, and instead write your own function.  For
-example:
+example::
 
  { 'command': 'netdev_add',
    'data': {'type': 'str', 'id': 'str'},
@@ -561,7 +585,7 @@ the command definition includes the optional member 'success-response'
 with boolean value false.  So far, only QGA makes use of this member.
 
 Member 'allow-oob' declares whether the command supports out-of-band
-(OOB) execution.  It defaults to false.  For example:
+(OOB) execution.  It defaults to false.  For example::
 
  { 'command': 'migrate_recover',
    'data': { 'uri': 'str' }, 'allow-oob': true }
@@ -594,7 +618,7 @@ other "slow" lock.
 When in doubt, do not implement OOB execution support.
 
 Member 'allow-preconfig' declares whether the command is available
-before the machine is built.  It defaults to false.  For example:
+before the machine is built.  It defaults to false.  For example::
 
  { 'enum': 'QMPCapability',
    'data': [ 'oob' ] }
@@ -640,9 +664,11 @@ The optional 'features' member specifies features.  See "Features"
 below for more on this.
 
 
-=== Events ===
+Events
+------
+
+Syntax::
 
-Syntax:
     EVENT = { 'event': STRING,
               (
               '*data': ( MEMBERS | STRING ),
@@ -665,16 +691,16 @@ data just like a struct type's 'data' defines struct type members.
 If 'data' is a STRING, then STRING names a complex type whose members
 are the event-specific data.  A union type requires 'boxed': true.
 
-An example event is:
+An example event is::
 
-{ 'event': 'EVENT_C',
-  'data': { '*a': 'int', 'b': 'str' } }
+ { 'event': 'EVENT_C',
+   'data': { '*a': 'int', 'b': 'str' } }
 
-Resulting in this JSON object:
+Resulting in this JSON object::
 
-{ "event": "EVENT_C",
-  "data": { "b": "test string" },
-  "timestamp": { "seconds": 1267020223, "microseconds": 435656 } }
+ { "event": "EVENT_C",
+   "data": { "b": "test string" },
+   "timestamp": { "seconds": 1267020223, "microseconds": 435656 } }
 
 The generator emits a function to send the event.  When member 'boxed'
 is absent, it takes event-specific data one by one, in QAPI schema
@@ -688,9 +714,11 @@ The optional 'features' member specifies features.  See "Features"
 below for more on this.
 
 
-=== Features ===
+Features
+--------
+
+Syntax::
 
-Syntax:
     FEATURES = [ FEATURE, ... ]
     FEATURE = STRING
             | { 'name': STRING, '*if': COND }
@@ -701,17 +729,17 @@ that previously resulted in an error).  QMP clients may still need to
 know whether the extension is available.
 
 For this purpose, a list of features can be specified for a command or
-struct type.  Each list member can either be { 'name': STRING, '*if':
-COND }, or STRING, which is shorthand for { 'name': STRING }.
+struct type.  Each list member can either be ``{ 'name': STRING, '*if':
+COND }``, or STRING, which is shorthand for ``{ 'name': STRING }``.
 
 The optional 'if' member specifies a conditional.  See "Configuring
 the schema" below for more on this.
 
-Example:
+Example::
 
-{ 'struct': 'TestType',
-  'data': { 'number': 'int' },
-  'features': [ 'allow-negative-numbers' ] }
+ { 'struct': 'TestType',
+   'data': { 'number': 'int' },
+   'features': [ 'allow-negative-numbers' ] }
 
 The feature strings are exposed to clients in introspection, as
 explained in section "Client JSON Protocol introspection".
@@ -720,20 +748,22 @@ Intended use is to have each feature string signal that this build of
 QEMU shows a certain behaviour.
 
 
-==== Special features ====
+Special features
+~~~~~~~~~~~~~~~~
 
 Feature "deprecated" marks a command, event, or struct member as
 deprecated.  It is not supported elsewhere so far.
 
 
-=== Naming rules and reserved names ===
+Naming rules and reserved names
+-------------------------------
 
 All names must begin with a letter, and contain only ASCII letters,
 digits, hyphen, and underscore.  There are two exceptions: enum values
 may start with a digit, and names that are downstream extensions (see
 section Downstream extensions) start with underscore.
 
-Names beginning with 'q_' are reserved for the generator, which uses
+Names beginning with 'q\_' are reserved for the generator, which uses
 them for munging QMP names that resemble C keywords or other
 problematic strings.  For example, a member named "default" in qapi
 becomes "q_default" in the generated C code.
@@ -753,7 +783,7 @@ consistency is preferred over blindly avoiding underscore.
 
 Event names should be ALL_CAPS with words separated by underscore.
 
-Member name 'u' and names starting with 'has-' or 'has_' are reserved
+Member name 'u' and names starting with 'has-' or 'has\_' are reserved
 for the generator, which uses them for unions and for tracking
 optional members.
 
@@ -765,7 +795,8 @@ Pragmas 'command-name-exceptions' and 'member-name-exceptions' let you
 violate naming rules.  Use for new code is strongly discouraged.
 
 
-=== Downstream extensions ===
+Downstream extensions
+---------------------
 
 QAPI schema names that are externally visible, say in the Client JSON
 Protocol, need to be managed with care.  Names starting with a
@@ -777,9 +808,11 @@ Example: Red Hat, Inc. controls redhat.com, and may therefore add a
 downstream command __com.redhat_drive-mirror.
 
 
-=== Configuring the schema ===
+Configuring the schema
+----------------------
+
+Syntax::
 
-Syntax:
     COND = STRING
          | [ STRING, ... ]
 
@@ -788,12 +821,12 @@ string or a list of strings.  A string is shorthand for a list
 containing just that string.  The code generated for the definition
 will then be guarded by #if STRING for each STRING in the COND list.
 
-Example: a conditional struct
+Example: a conditional struct ::
 
  { 'struct': 'IfStruct', 'data': { 'foo': 'int' },
    'if': ['defined(CONFIG_FOO)', 'defined(HAVE_BAR)'] }
 
-gets its generated code guarded like this:
+gets its generated code guarded like this::
 
  #if defined(CONFIG_FOO)
  #if defined(HAVE_BAR)
@@ -806,11 +839,11 @@ event-specific data can also be made conditional.  This requires the
 longhand form of MEMBER.
 
 Example: a struct type with unconditional member 'foo' and conditional
-member 'bar'
+member 'bar' ::
 
-{ 'struct': 'IfStruct', 'data':
-  { 'foo': 'int',
-    'bar': { 'type': 'int', 'if': 'defined(IFCOND)'} } }
+ { 'struct': 'IfStruct', 'data':
+   { 'foo': 'int',
+     'bar': { 'type': 'int', 'if': 'defined(IFCOND)'} } }
 
 A union's discriminator may not be conditional.
 
@@ -818,21 +851,21 @@ Likewise, individual enumeration values be conditional.  This requires
 the longhand form of ENUM-VALUE.
 
 Example: an enum type with unconditional value 'foo' and conditional
-value 'bar'
+value 'bar' ::
 
-{ 'enum': 'IfEnum', 'data':
-  [ 'foo',
-    { 'name' : 'bar', 'if': 'defined(IFCOND)' } ] }
+ { 'enum': 'IfEnum', 'data':
+   [ 'foo',
+     { 'name' : 'bar', 'if': 'defined(IFCOND)' } ] }
 
 Likewise, features can be conditional.  This requires the longhand
 form of FEATURE.
 
-Example: a struct with conditional feature 'allow-negative-numbers'
+Example: a struct with conditional feature 'allow-negative-numbers' ::
 
-{ 'struct': 'TestType',
-  'data': { 'number': 'int' },
-  'features': [ { 'name': 'allow-negative-numbers',
-                  'if': 'defined(IFCOND)' } ] }
+ { 'struct': 'TestType',
+   'data': { 'number': 'int' },
+   'features': [ { 'name': 'allow-negative-numbers',
+                   'if': 'defined(IFCOND)' } ] }
 
 Please note that you are responsible to ensure that the C code will
 compile with an arbitrary combination of conditions, since the
@@ -843,12 +876,13 @@ shows a conditional entity only when the condition is satisfied in
 this particular build.
 
 
-=== Documentation comments ===
+Documentation comments
+----------------------
 
 A multi-line comment that starts and ends with a '##' line is a
 documentation comment.
 
-If the documentation comment starts like
+If the documentation comment starts like ::
 
     ##
     # @SYMBOL:
@@ -861,10 +895,12 @@ See below for more on definition documentation.
 Free-form documentation may be used to provide additional text and
 structuring content.
 
-==== Headings and subheadings ====
+
+Headings and subheadings
+~~~~~~~~~~~~~~~~~~~~~~~~
 
 A free-form documentation comment containing a line which starts with
-some '=' symbols and then a space defines a section heading:
+some '=' symbols and then a space defines a section heading::
 
     ##
     # = This is a top level heading
@@ -883,17 +919,19 @@ 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.
 
-==== Documentation markup ====
+
+Documentation markup
+~~~~~~~~~~~~~~~~~~~~
 
 Documentation comments can use most rST markup.  In particular,
-a '::' literal block can be used for examples:
+a '::' literal block can be used for examples::
 
     # ::
     #
     #   Text of the example, may span
     #   multiple lines
 
-'*' starts an itemized list:
+'*' starts an itemized list::
 
     # * First item, may span
     #   multiple lines
@@ -901,7 +939,7 @@ a '::' literal block can be used for examples:
 
 You can also use '-' instead of '*'.
 
-A decimal number followed by '.' starts a numbered list:
+A decimal number followed by '.' starts a numbered list::
 
     # 1. First item, may span
     #    multiple lines
@@ -920,24 +958,25 @@ backslash-escape it.  As an extension beyond the usual rST syntax, you
 can also use '@foo' to reference a name in the schema; this is
 rendered the same way as '``foo``'.
 
-Example:
+Example::
 
-##
-# Some text foo with **bold** and *emphasis*
-# 1. with a list
-# 2. like that
-#
-# And some code:
-#
-# ::
-#
-#   $ echo foo
-#   -> do this
-#   <- get that
-##
+ ##
+ # Some text foo with **bold** and *emphasis*
+ # 1. with a list
+ # 2. like that
+ #
+ # And some code:
+ #
+ # ::
+ #
+ #   $ echo foo
+ #   -> do this
+ #   <- get that
+ ##
 
 
-==== Definition documentation ====
+Definition documentation
+~~~~~~~~~~~~~~~~~~~~~~~~
 
 Definition documentation, if present, must immediately precede the
 definition it documents.
@@ -956,14 +995,14 @@ text can start on the line following the '@argname:', in which case it
 must not be indented at all.  It can also start on the same line as
 the '@argname:'.  In this case if it spans multiple lines then second
 and subsequent lines must be indented to line up with the first
-character of the first line of the description:
+character of the first line of the description::
 
-# @argone:
-# This is a two line description
-# in the first style.
-#
-# @argtwo: This is a two line description
-#          in the second style.
+ # @argone:
+ # This is a two line description
+ # in the first style.
+ #
+ # @argtwo: This is a two line description
+ #          in the second style.
 
 The number of spaces between the ':' and the text is not significant.
 
@@ -997,52 +1036,53 @@ An 'Example' or 'Examples' section is automatically rendered
 entirely as literal fixed-width text.  In other sections,
 the text is formatted, and rST markup can be used.
 
-For example:
+For example::
 
-##
-# @BlockStats:
-#
-# Statistics of a virtual block device or a block backing device.
-#
-# @device: If the stats are for a virtual block device, the name
-#          corresponding to the virtual block device.
-#
-# @node-name: The node name of the device. (since 2.3)
-#
-# ... more members ...
-#
-# Since: 0.14.0
-##
-{ 'struct': 'BlockStats',
-  'data': {'*device': 'str', '*node-name': 'str',
-           ... more members ... } }
+ ##
+ # @BlockStats:
+ #
+ # Statistics of a virtual block device or a block backing device.
+ #
+ # @device: If the stats are for a virtual block device, the name
+ #          corresponding to the virtual block device.
+ #
+ # @node-name: The node name of the device. (since 2.3)
+ #
+ # ... more members ...
+ #
+ # Since: 0.14.0
+ ##
+ { 'struct': 'BlockStats',
+   'data': {'*device': 'str', '*node-name': 'str',
+            ... more members ... } }
 
-##
-# @query-blockstats:
-#
-# Query the @BlockStats for all virtual block devices.
-#
-# @query-nodes: If true, the command will query all the
-#               block nodes ... explain, explain ...  (since 2.3)
-#
-# Returns: A list of @BlockStats for each virtual block devices.
-#
-# Since: 0.14.0
-#
-# Example:
-#
-# -> { "execute": "query-blockstats" }
-# <- {
-#      ... lots of output ...
-#    }
-#
-##
-{ 'command': 'query-blockstats',
-  'data': { '*query-nodes': 'bool' },
-  'returns': ['BlockStats'] }
+ ##
+ # @query-blockstats:
+ #
+ # Query the @BlockStats for all virtual block devices.
+ #
+ # @query-nodes: If true, the command will query all the
+ #               block nodes ... explain, explain ...  (since 2.3)
+ #
+ # Returns: A list of @BlockStats for each virtual block devices.
+ #
+ # Since: 0.14.0
+ #
+ # Example:
+ #
+ # -> { "execute": "query-blockstats" }
+ # <- {
+ #      ... lots of output ...
+ #    }
+ #
+ ##
+ { 'command': 'query-blockstats',
+   'data': { '*query-nodes': 'bool' },
+   'returns': ['BlockStats'] }
 
 
-== Client JSON Protocol introspection ==
+Client JSON Protocol introspection
+==================================
 
 Clients of a Client JSON Protocol commonly need to figure out what
 exactly the server (QEMU) supports.
@@ -1114,13 +1154,13 @@ If the command takes no arguments, "arg-type" names an object type
 without members.  Likewise, if the command returns nothing, "ret-type"
 names an object type without members.
 
-Example: the SchemaInfo for command query-qmp-schema
+Example: the SchemaInfo for command query-qmp-schema ::
 
-    { "name": "query-qmp-schema", "meta-type": "command",
-      "arg-type": "q_empty", "ret-type": "SchemaInfoList" }
+ { "name": "query-qmp-schema", "meta-type": "command",
+   "arg-type": "q_empty", "ret-type": "SchemaInfoList" }
 
-    Type "q_empty" is an automatic object type without members, and type
-    "SchemaInfoList" is the array of SchemaInfo type.
+   Type "q_empty" is an automatic object type without members, and type
+   "SchemaInfoList" is the array of SchemaInfo type.
 
 The SchemaInfo for an event has meta-type "event", and variant member
 "arg-type".  On the wire, a "data" member that the server passes in an
@@ -1133,7 +1173,7 @@ the wire then.
 Each command or event defined with 'data' as MEMBERS object in the
 QAPI schema implicitly defines an object type.
 
-Example: the SchemaInfo for EVENT_C from section Events
+Example: the SchemaInfo for EVENT_C from section Events ::
 
     { "name": "EVENT_C", "meta-type": "event",
       "arg-type": "q_obj-EVENT_C-arg" }
@@ -1157,7 +1197,7 @@ extensions.  The "members" array is in no particular order; clients
 must search the entire object when learning whether a particular
 member is supported.
 
-Example: the SchemaInfo for MyType from section Struct types
+Example: the SchemaInfo for MyType from section Struct types ::
 
     { "name": "MyType", "meta-type": "object",
       "members": [
@@ -1168,7 +1208,7 @@ Example: the SchemaInfo for MyType from section Struct types
 "features" exposes the command's feature strings as a JSON array of
 strings.
 
-Example: the SchemaInfo for TestType from section Features:
+Example: the SchemaInfo for TestType from section Features::
 
     { "name": "TestType", "meta-type": "object",
       "members": [
@@ -1184,7 +1224,7 @@ that provides the variant members for this type tag value).  The
 list cases in the same order as the corresponding "tag" enum type.
 
 Example: the SchemaInfo for flat union BlockdevOptions from section
-Union types
+Union types ::
 
     { "name": "BlockdevOptions", "meta-type": "object",
       "members": [
@@ -1205,7 +1245,7 @@ A simple union implicitly defines an object type for each of its
 variants.
 
 Example: the SchemaInfo for simple union BlockdevOptionsSimple from section
-Union types
+Union types ::
 
     { "name": "BlockdevOptionsSimple", "meta-type": "object",
       "members": [
@@ -1225,7 +1265,7 @@ a JSON object with member "type", which names a type.  Values of the
 alternate type conform to exactly one of its member types.  There is
 no guarantee on the order in which "members" will be listed.
 
-Example: the SchemaInfo for BlockdevRef from section Alternate types
+Example: the SchemaInfo for BlockdevRef from section Alternate types ::
 
     { "name": "BlockdevRef", "meta-type": "alternate",
       "members": [
@@ -1239,7 +1279,7 @@ resemble the element type; however, clients should examine member
 "element-type" instead of making assumptions based on parsing member
 "name".
 
-Example: the SchemaInfo for ['str']
+Example: the SchemaInfo for ['str'] ::
 
     { "name": "[str]", "meta-type": "array",
       "element-type": "str" }
@@ -1249,7 +1289,7 @@ variant member "values".  The values are listed in no particular
 order; clients must search the entire enum when learning whether a
 particular value is supported.
 
-Example: the SchemaInfo for MyEnum from section Enumeration types
+Example: the SchemaInfo for MyEnum from section Enumeration types ::
 
     { "name": "MyEnum", "meta-type": "enum",
       "values": [ "value1", "value2", "value3" ] }
@@ -1259,7 +1299,7 @@ the QAPI schema (see section Built-in Types), with one exception
 detailed below.  It has variant member "json-type" that shows how
 values of this type are encoded on the wire.
 
-Example: the SchemaInfo for str
+Example: the SchemaInfo for str ::
 
     { "name": "str", "meta-type": "builtin", "json-type": "string" }
 
@@ -1273,7 +1313,8 @@ the names of built-in types.  Clients should examine member
 "json-type" instead of hard-coding names of built-in types.
 
 
-== Compatibility considerations ==
+Compatibility considerations
+============================
 
 Maintaining backward compatibility at the Client JSON Protocol level
 while evolving the schema requires some care.  This section is about
@@ -1333,7 +1374,8 @@ may be freely renamed.  Even certain refactorings are invisible, such
 as splitting members from one type into a common base type.
 
 
-== Code generation ==
+Code generation
+===============
 
 The QAPI code generator qapi-gen.py generates code and documentation
 from the schema.  Together with the core QAPI libraries, this code
@@ -1347,7 +1389,7 @@ As an example, we'll use the following schema, which describes a
 single complex user-defined type, along with command which takes a
 list of that type as a parameter, and returns a single element of that
 type.  The user is responsible for writing the implementation of
-qmp_my_command(); everything else is produced by the generator.
+qmp_my_command(); everything else is produced by the generator. ::
 
     $ cat example-schema.json
     { 'struct': 'UserDefOne',
@@ -1359,7 +1401,7 @@ qmp_my_command(); everything else is produced by the generator.
 
     { 'event': 'MY_EVENT' }
 
-We run qapi-gen.py like this:
+We run qapi-gen.py like this::
 
     $ python scripts/qapi-gen.py --output-dir="qapi-generated" \
     --prefix="example-" example-schema.json
@@ -1369,24 +1411,27 @@ tests/qapi-schema/qapi-schema-tests.json that covers more examples of
 what the generator will accept, and compiles the resulting C code as
 part of 'make check-unit'.
 
-=== Code generated for QAPI types ===
+
+Code generated for QAPI types
+-----------------------------
 
 The following files are created:
 
-$(prefix)qapi-types.h - C types corresponding to types defined in
-                        the schema
+ ``$(prefix)qapi-types.h``
+     C types corresponding to types defined in the schema
 
-$(prefix)qapi-types.c - Cleanup functions for the above C types
+ ``$(prefix)qapi-types.c``
+     Cleanup functions for the above C types
 
 The $(prefix) is an optional parameter used as a namespace to keep the
 generated code from one schema/code-generation separated from others so code
 can be generated/used from multiple schemas without clobbering previously
 created code.
 
-Example:
+Example::
 
     $ cat qapi-generated/example-qapi-types.h
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
 
     #ifndef EXAMPLE_QAPI_TYPES_H
     #define EXAMPLE_QAPI_TYPES_H
@@ -1422,7 +1467,7 @@ Example:
 
     #endif /* EXAMPLE_QAPI_TYPES_H */
     $ cat qapi-generated/example-qapi-types.c
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
 
     void qapi_free_UserDefOne(UserDefOne *obj)
     {
@@ -1450,22 +1495,26 @@ Example:
         visit_free(v);
     }
 
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
 
 For a modular QAPI schema (see section Include directives), code for
-each sub-module SUBDIR/SUBMODULE.json is actually generated into
+each sub-module SUBDIR/SUBMODULE.json is actually generated into ::
 
-SUBDIR/$(prefix)qapi-types-SUBMODULE.h
-SUBDIR/$(prefix)qapi-types-SUBMODULE.c
+ SUBDIR/$(prefix)qapi-types-SUBMODULE.h
+ SUBDIR/$(prefix)qapi-types-SUBMODULE.c
 
 If qapi-gen.py is run with option --builtins, additional files are
 created:
 
-qapi-builtin-types.h - C types corresponding to built-in types
+ ``qapi-builtin-types.h``
+     C types corresponding to built-in types
 
-qapi-builtin-types.c - Cleanup functions for the above C types
+ ``qapi-builtin-types.c``
+     Cleanup functions for the above C types
 
-=== Code generated for visiting QAPI types ===
+
+Code generated for visiting QAPI types
+--------------------------------------
 
 These are the visitor functions used to walk through and convert
 between a native QAPI C data structure and some other format (such as
@@ -1474,19 +1523,18 @@ visit_type_FOO_members().
 
 The following files are generated:
 
-$(prefix)qapi-visit.c: Visitor function for a particular C type, used
-                       to automagically convert QObjects into the
-                       corresponding C type and vice-versa, as well
-                       as for deallocating memory for an existing C
-                       type
+ ``$(prefix)qapi-visit.c``
+     Visitor function for a particular C type, used to automagically
+     convert QObjects into the corresponding C type and vice-versa, as
+     well as for deallocating memory for an existing C type
 
-$(prefix)qapi-visit.h: Declarations for previously mentioned visitor
-                       functions
+ ``$(prefix)qapi-visit.h``
+     Declarations for previously mentioned visitor functions
 
-Example:
+Example::
 
     $ cat qapi-generated/example-qapi-visit.h
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
 
     #ifndef EXAMPLE_QAPI_VISIT_H
     #define EXAMPLE_QAPI_VISIT_H
@@ -1503,7 +1551,7 @@ Example:
 
     #endif /* EXAMPLE_QAPI_VISIT_H */
     $ cat qapi-generated/example-qapi-visit.c
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
 
     bool visit_type_UserDefOne_members(Visitor *v, UserDefOne *obj, Error **errp)
     {
@@ -1578,22 +1626,26 @@ Example:
         return true;
     }
 
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
 
 For a modular QAPI schema (see section Include directives), code for
-each sub-module SUBDIR/SUBMODULE.json is actually generated into
+each sub-module SUBDIR/SUBMODULE.json is actually generated into ::
 
-SUBDIR/$(prefix)qapi-visit-SUBMODULE.h
-SUBDIR/$(prefix)qapi-visit-SUBMODULE.c
+ SUBDIR/$(prefix)qapi-visit-SUBMODULE.h
+ SUBDIR/$(prefix)qapi-visit-SUBMODULE.c
 
 If qapi-gen.py is run with option --builtins, additional files are
 created:
 
-qapi-builtin-visit.h - Visitor functions for built-in types
+ ``qapi-builtin-visit.h``
+     Visitor functions for built-in types
 
-qapi-builtin-visit.c - Declarations for these visitor functions
+ ``qapi-builtin-visit.c``
+     Declarations for these visitor functions
 
-=== Code generated for commands ===
+
+Code generated for commands
+---------------------------
 
 These are the marshaling/dispatch functions for the commands defined
 in the schema.  The generated code provides qmp_marshal_COMMAND(), and
@@ -1601,20 +1653,23 @@ declares qmp_COMMAND() that the user must implement.
 
 The following files are generated:
 
-$(prefix)qapi-commands.c: Command marshal/dispatch functions for each
-                          QMP command defined in the schema
+ ``$(prefix)qapi-commands.c``
+     Command marshal/dispatch functions for each QMP command defined in
+     the schema
 
-$(prefix)qapi-commands.h: Function prototypes for the QMP commands
-                          specified in the schema
+ ``$(prefix)qapi-commands.h``
+     Function prototypes for the QMP commands specified in the schema
 
-$(prefix)qapi-init-commands.h - Command initialization prototype
+ ``$(prefix)qapi-init-commands.h``
+     Command initialization prototype
 
-$(prefix)qapi-init-commands.c - Command initialization code
+ ``$(prefix)qapi-init-commands.c``
+     Command initialization code
 
-Example:
+Example::
 
     $ cat qapi-generated/example-qapi-commands.h
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
 
     #ifndef EXAMPLE_QAPI_COMMANDS_H
     #define EXAMPLE_QAPI_COMMANDS_H
@@ -1626,7 +1681,7 @@ Example:
 
     #endif /* EXAMPLE_QAPI_COMMANDS_H */
     $ cat qapi-generated/example-qapi-commands.c
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
 
     static void qmp_marshal_output_UserDefOne(UserDefOne *ret_in, QObject **ret_out, Error **errp)
     {
@@ -1679,9 +1734,9 @@ Example:
         visit_free(v);
     }
 
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
     $ cat qapi-generated/example-qapi-init-commands.h
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
     #ifndef EXAMPLE_QAPI_INIT_COMMANDS_H
     #define EXAMPLE_QAPI_INIT_COMMANDS_H
 
@@ -1691,7 +1746,7 @@ Example:
 
     #endif /* EXAMPLE_QAPI_INIT_COMMANDS_H */
     $ cat qapi-generated/example-qapi-init-commands.c
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
     void example_qmp_init_marshal(QmpCommandList *cmds)
     {
         QTAILQ_INIT(cmds);
@@ -1699,34 +1754,39 @@ Example:
         qmp_register_command(cmds, "my-command",
                              qmp_marshal_my_command, QCO_NO_OPTIONS);
     }
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
 
 For a modular QAPI schema (see section Include directives), code for
-each sub-module SUBDIR/SUBMODULE.json is actually generated into
+each sub-module SUBDIR/SUBMODULE.json is actually generated into::
 
-SUBDIR/$(prefix)qapi-commands-SUBMODULE.h
-SUBDIR/$(prefix)qapi-commands-SUBMODULE.c
+ SUBDIR/$(prefix)qapi-commands-SUBMODULE.h
+ SUBDIR/$(prefix)qapi-commands-SUBMODULE.c
 
-=== Code generated for events ===
+
+Code generated for events
+-------------------------
 
 This is the code related to events defined in the schema, providing
 qapi_event_send_EVENT().
 
 The following files are created:
 
-$(prefix)qapi-events.h - Function prototypes for each event type
+ ``$(prefix)qapi-events.h``
+     Function prototypes for each event type
 
-$(prefix)qapi-events.c - Implementation of functions to send an event
+ ``$(prefix)qapi-events.c``
+     Implementation of functions to send an event
 
-$(prefix)qapi-emit-events.h - Enumeration of all event names, and
-                              common event code declarations
+ ``$(prefix)qapi-emit-events.h``
+     Enumeration of all event names, and common event code declarations
 
-$(prefix)qapi-emit-events.c - Common event code definitions
+ ``$(prefix)qapi-emit-events.c``
+     Common event code definitions
 
-Example:
+Example::
 
     $ cat qapi-generated/example-qapi-events.h
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
 
     #ifndef EXAMPLE_QAPI_EVENTS_H
     #define EXAMPLE_QAPI_EVENTS_H
@@ -1738,7 +1798,7 @@ Example:
 
     #endif /* EXAMPLE_QAPI_EVENTS_H */
     $ cat qapi-generated/example-qapi-events.c
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
 
     void qapi_event_send_my_event(void)
     {
@@ -1751,9 +1811,9 @@ Example:
         qobject_unref(qmp);
     }
 
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
     $ cat qapi-generated/example-qapi-emit-events.h
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
 
     #ifndef EXAMPLE_QAPI_EMIT_EVENTS_H
     #define EXAMPLE_QAPI_EMIT_EVENTS_H
@@ -1774,7 +1834,7 @@ Example:
 
     #endif /* EXAMPLE_QAPI_EMIT_EVENTS_H */
     $ cat qapi-generated/example-qapi-emit-events.c
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
 
     const QEnumLookup example_QAPIEvent_lookup = {
         .array = (const char *const[]) {
@@ -1783,27 +1843,30 @@ Example:
         .size = EXAMPLE_QAPI_EVENT__MAX
     };
 
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
 
 For a modular QAPI schema (see section Include directives), code for
-each sub-module SUBDIR/SUBMODULE.json is actually generated into
+each sub-module SUBDIR/SUBMODULE.json is actually generated into ::
 
-SUBDIR/$(prefix)qapi-events-SUBMODULE.h
-SUBDIR/$(prefix)qapi-events-SUBMODULE.c
+ SUBDIR/$(prefix)qapi-events-SUBMODULE.h
+ SUBDIR/$(prefix)qapi-events-SUBMODULE.c
 
-=== Code generated for introspection ===
+
+Code generated for introspection
+--------------------------------
 
 The following files are created:
 
-$(prefix)qapi-introspect.c - Defines a string holding a JSON
-                            description of the schema
+ ``$(prefix)qapi-introspect.c``
+     Defines a string holding a JSON description of the schema
 
-$(prefix)qapi-introspect.h - Declares the above string
+ ``$(prefix)qapi-introspect.h``
+     Declares the above string
 
-Example:
+Example::
 
     $ cat qapi-generated/example-qapi-introspect.h
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
 
     #ifndef EXAMPLE_QAPI_INTROSPECT_H
     #define EXAMPLE_QAPI_INTROSPECT_H
@@ -1814,7 +1877,7 @@ Example:
 
     #endif /* EXAMPLE_QAPI_INTROSPECT_H */
     $ cat qapi-generated/example-qapi-introspect.c
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
 
     const QLitObject example_qmp_schema_qlit = QLIT_QLIST(((QLitObject[]) {
         QLIT_QDICT(((QLitDictEntry[]) {
@@ -1894,4 +1957,4 @@ Example:
         {}
     }));
 
-[Uninteresting stuff omitted...]
+    [Uninteresting stuff omitted...]
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] docs/qapi-code-gen: Beautify formatting
  2021-07-20 23:56 [PATCH 0/3] docs: convert qapi-code-gen.txt to qapi-code-gen.rst John Snow
  2021-07-20 23:56 ` [PATCH 1/3] docs: convert qapi-code-gen.txt to ReST John Snow
@ 2021-07-20 23:56 ` John Snow
  2021-07-20 23:56 ` [PATCH 3/3] docs/qapi-code-gen: add cross-references John Snow
  2021-07-27 12:48 ` [PATCH 0/3] docs: convert qapi-code-gen.txt to qapi-code-gen.rst Peter Maydell
  3 siblings, 0 replies; 8+ messages in thread
From: John Snow @ 2021-07-20 23:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael Roth, John Snow, Markus Armbruster

Mostly, add ``literal`` markers to a lot of things like C types, add
code blocks, and fix the way a few things render.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 docs/devel/qapi-code-gen.rst | 172 ++++++++++++++++++-----------------
 1 file changed, 90 insertions(+), 82 deletions(-)

diff --git a/docs/devel/qapi-code-gen.rst b/docs/devel/qapi-code-gen.rst
index b79ecddb599..4a28118d951 100644
--- a/docs/devel/qapi-code-gen.rst
+++ b/docs/devel/qapi-code-gen.rst
@@ -40,7 +40,7 @@ by any commands or events, for the side effect of generated C code
 used internally.
 
 There are several kinds of types: simple types (a number of built-in
-types, such as 'int' and 'str'; as well as enumerations), arrays,
+types, such as ``int`` and ``str``; as well as enumerations), arrays,
 complex types (structs and two flavors of unions), and alternate types
 (a choice between other types).
 
@@ -51,37 +51,37 @@ Schema syntax
 Syntax is loosely based on `JSON <http://www.ietf.org/rfc/rfc8259.txt>`_.
 Differences:
 
-* Comments: start with a hash character (#) that is not part of a
+* Comments: start with a hash character (``#``) that is not part of a
   string, and extend to the end of the line.
 
-* Strings are enclosed in 'single quotes', not "double quotes".
+* Strings are enclosed in ``'single quotes'``, not ``"double quotes"``.
 
 * Strings are restricted to printable ASCII, and escape sequences to
-  just '\\'.
+  just ``\\``.
 
-* Numbers and null are not supported.
+* Numbers and ``null`` are not supported.
 
 A second layer of syntax defines the sequences of JSON texts that are
 a correctly structured QAPI schema.  We provide a grammar for this
 syntax in an EBNF-like notation:
 
-* Production rules look like non-terminal = expression
-* Concatenation: expression A B matches expression A, then B
-* Alternation: expression A | B matches expression A or B
-* Repetition: expression A... matches zero or more occurrences of
-  expression A
-* Repetition: expression A, ... matches zero or more occurrences of
-  expression A separated by ,
-* Grouping: expression ( A ) matches expression A
-* JSON's structural characters are terminals: { } [ ] : ,
-* JSON's literal names are terminals: false true
-* String literals enclosed in 'single quotes' are terminal, and match
-  this JSON string, with a leading '*' stripped off
-* When JSON object member's name starts with '*', the member is
+* Production rules look like ``non-terminal = expression``
+* Concatenation: expression ``A B`` matches expression ``A``, then ``B``
+* Alternation: expression ``A | B`` matches expression ``A`` or ``B``
+* Repetition: expression ``A...`` matches zero or more occurrences of
+  expression ``A``
+* Repetition: expression ``A, ...`` matches zero or more occurrences of
+  expression ``A`` separated by ``,``
+* Grouping: expression ``( A )`` matches expression ``A``
+* JSON's structural characters are terminals: ``{ } [ ] : ,``
+* JSON's literal names are terminals: ``false true``
+* String literals enclosed in ``'single quotes'`` are terminal, and match
+  this JSON string, with a leading ``*`` stripped off
+* When JSON object member's name starts with ``*``, the member is
   optional.
-* The symbol STRING is a terminal, and matches any JSON string
-* The symbol BOOL is a terminal, and matches JSON false or true
-* ALL-CAPS words other than STRING are non-terminals
+* The symbol ``STRING`` is a terminal, and matches any JSON string
+* The symbol ``BOOL`` is a terminal, and matches JSON ``false`` or ``true``
+* ALL-CAPS words other than ``STRING`` are non-terminals
 
 The order of members within JSON objects does not matter unless
 explicitly noted.
@@ -109,27 +109,30 @@ These are discussed in detail below.
 Built-in Types
 --------------
 
-The following types are predefined, and map to C as follows::
+The following types are predefined, and map to C as follows:
 
-  Schema    C          JSON
-  str       char *     any JSON string, UTF-8
-  number    double     any JSON number
-  int       int64_t    a JSON number without fractional part
-                       that fits into the C integer type
-  int8      int8_t     likewise
-  int16     int16_t    likewise
-  int32     int32_t    likewise
-  int64     int64_t    likewise
-  uint8     uint8_t    likewise
-  uint16    uint16_t   likewise
-  uint32    uint32_t   likewise
-  uint64    uint64_t   likewise
-  size      uint64_t   like uint64_t, except StringInputVisitor
-                       accepts size suffixes
-  bool      bool       JSON true or false
-  null      QNull *    JSON null
-  any       QObject *  any JSON value
-  QType     QType      JSON string matching enum QType values
+  ============= ============== ============================================
+  Schema        C              JSON
+  ============= ============== ============================================
+  ``str``       ``char *``     any JSON string, UTF-8
+  ``number``    ``double``     any JSON number
+  ``int``       ``int64_t``    a JSON number without fractional part
+                               that fits into the C integer type
+  ``int8``      ``int8_t``     likewise
+  ``int16``     ``int16_t``    likewise
+  ``int32``     ``int32_t``    likewise
+  ``int64``     ``int64_t``    likewise
+  ``uint8``     ``uint8_t``    likewise
+  ``uint16``    ``uint16_t``   likewise
+  ``uint32``    ``uint32_t``   likewise
+  ``uint64``    ``uint64_t``   likewise
+  ``size``      ``uint64_t``   like ``uint64_t``, except
+                               ``StringInputVisitor`` accepts size suffixes
+  ``bool``      ``bool``       JSON ``true`` or ``false``
+  ``null``      ``QNull *``    JSON ``null``
+  ``any``       ``QObject *``  any JSON value
+  ``QType``     ``QType``      JSON string matching enum ``QType`` values
+  ============= ============== ============================================
 
 
 Include directives
@@ -174,14 +177,14 @@ Pragma 'doc-required' takes a boolean value.  If true, documentation
 is required.  Default is false.
 
 Pragma 'command-name-exceptions' takes a list of commands whose names
-may contain '_' instead of '-'.  Default is none.
+may contain ``"_"`` instead of ``"-"``.  Default is none.
 
 Pragma 'command-returns-exceptions' takes a list of commands that may
 violate the rules on permitted return types.  Default is none.
 
 Pragma 'member-name-exceptions' takes a list of types whose member
-names may contain uppercase letters, and '_' instead of '-'.  Default
-is none.
+names may contain uppercase letters, and ``"_"`` instead of ``"-"``.
+Default is none.
 
 
 Enumeration types
@@ -200,7 +203,7 @@ Syntax::
 Member 'enum' names the enum type.
 
 Each member of the 'data' array defines a value of the enumeration
-type.  The form STRING is shorthand for { 'name': STRING }.  The
+type.  The form STRING is shorthand for :code:`{ 'name': STRING }`.  The
 'name' values must be be distinct.
 
 Example::
@@ -243,7 +246,7 @@ Syntax::
 A string denotes the type named by the string.
 
 A one-element array containing a string denotes an array of the type
-named by the string.  Example: ['int'] denotes an array of 'int'.
+named by the string.  Example: ``['int']`` denotes an array of ``int``.
 
 
 Struct types
@@ -266,11 +269,11 @@ Member 'struct' names the struct type.
 
 Each MEMBER of the 'data' object defines a member of the struct type.
 
-The MEMBER's STRING name consists of an optional '*' prefix and the
-struct member name.  If '*' is present, the member is optional.
+The MEMBER's STRING name consists of an optional ``*`` prefix and the
+struct member name.  If ``*`` is present, the member is optional.
 
 The MEMBER's value defines its properties, in particular its type.
-The form TYPE-REF is shorthand for { 'type': TYPE-REF }.
+The form TYPE-REF is shorthand for :code:`{ 'type': TYPE-REF }`.
 
 Example::
 
@@ -334,7 +337,7 @@ union must have at least one branch.
 The BRANCH's STRING name is the branch name.
 
 The BRANCH's value defines the branch's properties, in particular its
-type.  The form TYPE-REF is shorthand for { 'type': TYPE-REF }.
+type.  The form TYPE-REF is shorthand for :code:`{ 'type': TYPE-REF }`.
 
 A simple union type defines a mapping from automatic discriminator
 values to data types like in this example::
@@ -381,7 +384,7 @@ struct.
 The following example enhances the above simple union example by
 adding an optional common member 'read-only', renaming the
 discriminator to something more applicable than the simple union's
-default of 'type', and reducing the number of {} required on the wire::
+default of 'type', and reducing the number of ``{}`` required on the wire::
 
  { 'enum': 'BlockdevDriver', 'data': [ 'file', 'qcow2' ] }
  { 'union': 'BlockdevOptions',
@@ -450,7 +453,7 @@ alternate.  An alternate must have at least one branch.
 The ALTERNATIVE's STRING name is the branch name.
 
 The ALTERNATIVE's value defines the branch's properties, in particular
-its type.  The form STRING is shorthand for { 'type': STRING }.
+its type.  The form STRING is shorthand for :code:`{ 'type': STRING }`.
 
 Example::
 
@@ -515,7 +518,7 @@ If 'data' is a MEMBERS object, then MEMBERS defines arguments just
 like a struct type's 'data' defines struct type members.
 
 If 'data' is a STRING, then STRING names a complex type whose members
-are the arguments.  A union type requires 'boxed': true.
+are the arguments.  A union type requires ``'boxed': true``.
 
 Member 'returns' defines the command's return type.  It defaults to an
 empty struct type.  It must normally be a complex type or an array of
@@ -555,7 +558,7 @@ section "Code generated for commands" for examples.
 The function returns the return type.  When member 'boxed' is absent,
 it takes the command arguments as arguments one by one, in QAPI schema
 order.  Else it takes them wrapped in the C struct generated for the
-complex argument type.  It takes an additional Error ** argument in
+complex argument type.  It takes an additional ``Error **`` argument in
 either case.
 
 The generator also emits a marshalling function that extracts
@@ -638,11 +641,11 @@ blocking the guest and other background operations.
 Coroutine safety can be hard to prove, similar to thread safety.  Common
 pitfalls are:
 
-- The global mutex isn't held across qemu_coroutine_yield(), so
+- The global mutex isn't held across ``qemu_coroutine_yield()``, so
   operations that used to assume that they execute atomically may have
   to be more careful to protect against changes in the global state.
 
-- Nested event loops (AIO_WAIT_WHILE() etc.) are problematic in
+- Nested event loops (``AIO_WAIT_WHILE()`` etc.) are problematic in
   coroutine context and can easily lead to deadlocks.  They should be
   replaced by yielding and reentering the coroutine when the condition
   becomes false.
@@ -650,9 +653,9 @@ pitfalls are:
 Since the command handler may assume coroutine context, any callers
 other than the QMP dispatcher must also call it in coroutine context.
 In particular, HMP commands calling such a QMP command handler must be
-marked .coroutine = true in hmp-commands.hx.
+marked ``.coroutine = true`` in hmp-commands.hx.
 
-It is an error to specify both 'coroutine': true and 'allow-oob': true
+It is an error to specify both ``'coroutine': true`` and ``'allow-oob': true``
 for a command.  We don't currently have a use case for both together and
 without a use case, it's not entirely clear what the semantics should
 be.
@@ -689,7 +692,7 @@ If 'data' is a MEMBERS object, then MEMBERS defines event-specific
 data just like a struct type's 'data' defines struct type members.
 
 If 'data' is a STRING, then STRING names a complex type whose members
-are the event-specific data.  A union type requires 'boxed': true.
+are the event-specific data.  A union type requires ``'boxed': true``.
 
 An example event is::
 
@@ -763,16 +766,16 @@ digits, hyphen, and underscore.  There are two exceptions: enum values
 may start with a digit, and names that are downstream extensions (see
 section Downstream extensions) start with underscore.
 
-Names beginning with 'q\_' are reserved for the generator, which uses
+Names beginning with ``q_`` are reserved for the generator, which uses
 them for munging QMP names that resemble C keywords or other
-problematic strings.  For example, a member named "default" in qapi
-becomes "q_default" in the generated C code.
+problematic strings.  For example, a member named ``default`` in qapi
+becomes ``q_default`` in the generated C code.
 
 Types, commands, and events share a common namespace.  Therefore,
 generally speaking, type definitions should always use CamelCase for
 user-defined type names, while built-in types are lowercase.
 
-Type names ending with 'Kind' or 'List' are reserved for the
+Type names ending with ``Kind`` or ``List`` are reserved for the
 generator, which uses them for implicit union enums and array types,
 respectively.
 
@@ -783,15 +786,15 @@ consistency is preferred over blindly avoiding underscore.
 
 Event names should be ALL_CAPS with words separated by underscore.
 
-Member name 'u' and names starting with 'has-' or 'has\_' are reserved
+Member name ``u`` and names starting with ``has-`` or ``has_`` are reserved
 for the generator, which uses them for unions and for tracking
 optional members.
 
 Any name (command, event, type, member, or enum value) beginning with
-"x-" is marked experimental, and may be withdrawn or changed
+``x-`` is marked experimental, and may be withdrawn or changed
 incompatibly in a future release.
 
-Pragmas 'command-name-exceptions' and 'member-name-exceptions' let you
+Pragmas ``command-name-exceptions`` and ``member-name-exceptions`` let you
 violate naming rules.  Use for new code is strongly discouraged.
 
 
@@ -805,7 +808,7 @@ who controls the valid, reverse fully qualified domain name RFQDN.
 RFQDN may only contain ASCII letters, digits, hyphen and period.
 
 Example: Red Hat, Inc. controls redhat.com, and may therefore add a
-downstream command __com.redhat_drive-mirror.
+downstream command ``__com.redhat_drive-mirror``.
 
 
 Configuring the schema
@@ -879,7 +882,7 @@ this particular build.
 Documentation comments
 ----------------------
 
-A multi-line comment that starts and ends with a '##' line is a
+A multi-line comment that starts and ends with a ``##`` line is a
 documentation comment.
 
 If the documentation comment starts like ::
@@ -887,7 +890,7 @@ If the documentation comment starts like ::
     ##
     # @SYMBOL:
 
-it documents the definition if SYMBOL, else it's free-form
+it documents the definition of SYMBOL, else it's free-form
 documentation.
 
 See below for more on definition documentation.
@@ -900,7 +903,7 @@ Headings and subheadings
 ~~~~~~~~~~~~~~~~~~~~~~~~
 
 A free-form documentation comment containing a line which starts with
-some '=' symbols and then a space defines a section heading::
+some ``=`` symbols and then a space defines a section heading::
 
     ##
     # = This is a top level heading
@@ -924,22 +927,22 @@ Documentation markup
 ~~~~~~~~~~~~~~~~~~~~
 
 Documentation comments can use most rST markup.  In particular,
-a '::' literal block can be used for examples::
+a ``::`` literal block can be used for examples::
 
     # ::
     #
     #   Text of the example, may span
     #   multiple lines
 
-'*' starts an itemized list::
+``*`` starts an itemized list::
 
     # * First item, may span
     #   multiple lines
     # * Second item
 
-You can also use '-' instead of '*'.
+You can also use ``-`` instead of ``*``.
 
-A decimal number followed by '.' starts a numbered list::
+A decimal number followed by ``.`` starts a numbered list::
 
     # 1. First item, may span
     #    multiple lines
@@ -952,11 +955,11 @@ If a list item's text spans multiple lines, then the second and
 subsequent lines must be correctly indented to line up with the
 first character of the first line.
 
-The usual '**strong**', '*emphasised*' and '``literal``' markup should
-be used.  If you need a single literal '*' you will need to
+The usual ****strong****, *\*emphasized\** and ````literal```` markup
+should be used.  If you need a single literal ``*``, you will need to
 backslash-escape it.  As an extension beyond the usual rST syntax, you
-can also use '@foo' to reference a name in the schema; this is
-rendered the same way as '``foo``'.
+can also use ``@foo`` to reference a name in the schema; this is rendered
+the same way as ````foo````.
 
 Example::
 
@@ -991,9 +994,9 @@ alternates), or value (for enums), and finally optional tagged
 sections.
 
 Descriptions of arguments can span multiple lines.  The description
-text can start on the line following the '@argname:', in which case it
+text can start on the line following the '\@argname:', in which case it
 must not be indented at all.  It can also start on the same line as
-the '@argname:'.  In this case if it spans multiple lines then second
+the '\@argname:'.  In this case if it spans multiple lines then second
 and subsequent lines must be indented to line up with the first
 character of the first line of the description::
 
@@ -1006,8 +1009,13 @@ character of the first line of the description::
 
 The number of spaces between the ':' and the text is not significant.
 
-FIXME: the parser accepts these things in almost any order.
-FIXME: union branches should be described, too.
+.. admonition:: FIXME
+
+   The parser accepts these things in almost any order.
+
+.. admonition:: FIXME
+
+   union branches should be described, too.
 
 Extensions added after the definition was first released carry a
 '(since x.y.z)' comment.
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] docs/qapi-code-gen: add cross-references
  2021-07-20 23:56 [PATCH 0/3] docs: convert qapi-code-gen.txt to qapi-code-gen.rst John Snow
  2021-07-20 23:56 ` [PATCH 1/3] docs: convert qapi-code-gen.txt to ReST John Snow
  2021-07-20 23:56 ` [PATCH 2/3] docs/qapi-code-gen: Beautify formatting John Snow
@ 2021-07-20 23:56 ` John Snow
  2021-07-27 12:48 ` [PATCH 0/3] docs: convert qapi-code-gen.txt to qapi-code-gen.rst Peter Maydell
  3 siblings, 0 replies; 8+ messages in thread
From: John Snow @ 2021-07-20 23:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael Roth, John Snow, Markus Armbruster

Add clickables to many places.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 docs/devel/qapi-code-gen.rst | 107 +++++++++++++++++++----------------
 1 file changed, 58 insertions(+), 49 deletions(-)

diff --git a/docs/devel/qapi-code-gen.rst b/docs/devel/qapi-code-gen.rst
index 4a28118d951..8c77af2d076 100644
--- a/docs/devel/qapi-code-gen.rst
+++ b/docs/devel/qapi-code-gen.rst
@@ -156,6 +156,7 @@ from making a forward reference to a type that is only introduced by
 an outer file.  The parser may be made stricter in the future to
 prevent incomplete include files.
 
+.. _pragma:
 
 Pragma directives
 -----------------
@@ -186,6 +187,7 @@ Pragma 'member-name-exceptions' takes a list of types whose member
 names may contain uppercase letters, and ``"_"`` instead of ``"-"``.
 Default is none.
 
+.. _ENUM-VALUE:
 
 Enumeration types
 -----------------
@@ -228,13 +230,15 @@ additional enumeration constant PREFIX__MAX with value N.
 Do not use string or an integer type when an enumeration type can do
 the job satisfactorily.
 
-The optional 'if' member specifies a conditional.  See "Configuring
-the schema" below for more on this.
+The optional 'if' member specifies a conditional.  See `Configuring the
+schema`_ below for more on this.
 
-The optional 'features' member specifies features.  See "Features"
+The optional 'features' member specifies features.  See Features_
 below for more on this.
 
 
+.. _TYPE-REF:
+
 Type references and array types
 -------------------------------
 
@@ -269,11 +273,13 @@ Member 'struct' names the struct type.
 
 Each MEMBER of the 'data' object defines a member of the struct type.
 
+.. _MEMBERS:
+
 The MEMBER's STRING name consists of an optional ``*`` prefix and the
 struct member name.  If ``*`` is present, the member is optional.
 
 The MEMBER's value defines its properties, in particular its type.
-The form TYPE-REF is shorthand for :code:`{ 'type': TYPE-REF }`.
+The form TYPE-REF_ is shorthand for :code:`{ 'type': TYPE-REF }`.
 
 Example::
 
@@ -300,10 +306,10 @@ both members like this::
  { "file": "/some/place/my-image",
    "backing": "/some/place/my-backing-file" }
 
-The optional 'if' member specifies a conditional.  See "Configuring
-the schema" below for more on this.
+The optional 'if' member specifies a conditional.  See `Configuring
+the schema`_ below for more on this.
 
-The optional 'features' member specifies features.  See "Features"
+The optional 'features' member specifies features.  See Features_
 below for more on this.
 
 
@@ -337,7 +343,7 @@ union must have at least one branch.
 The BRANCH's STRING name is the branch name.
 
 The BRANCH's value defines the branch's properties, in particular its
-type.  The form TYPE-REF is shorthand for :code:`{ 'type': TYPE-REF }`.
+type.  The form TYPE-REF_ is shorthand for :code:`{ 'type': TYPE-REF }`.
 
 A simple union type defines a mapping from automatic discriminator
 values to data types like in this example::
@@ -368,12 +374,12 @@ Flat unions permit arbitrary common members that occur in all variants
 of the union, not just a discriminator.  Their discriminators need not
 be named 'type'.  They also avoid nesting on the wire.
 
-The 'base' member defines the common members.  If it is a MEMBERS
+The 'base' member defines the common members.  If it is a MEMBERS_
 object, it defines common members just like a struct type's 'data'
 member defines struct type members.  If it is a STRING, it names a
 struct type whose members are the common members.
 
-All flat union branches must be of struct type.
+All flat union branches must be `Struct types`_.
 
 In the Client JSON Protocol, a flat union is represented by an object
 with the common members (from the base type) and the selected branch's
@@ -425,10 +431,10 @@ is identical on the wire to::
  { 'union': 'Flat', 'base': { 'type': 'Enum' }, 'discriminator': 'type',
    'data': { 'one': 'Branch1', 'two': 'Branch2' } }
 
-The optional 'if' member specifies a conditional.  See "Configuring
-the schema" below for more on this.
+The optional 'if' member specifies a conditional.  See `Configuring
+the schema`_ below for more on this.
 
-The optional 'features' member specifies features.  See "Features"
+The optional 'features' member specifies features.  See Features_
 below for more on this.
 
 
@@ -481,10 +487,10 @@ following example objects::
              "read-only": false,
              "filename": "/tmp/mydisk.qcow2" } }
 
-The optional 'if' member specifies a conditional.  See "Configuring
-the schema" below for more on this.
+The optional 'if' member specifies a conditional.  See `Configuring
+the schema`_ below for more on this.
 
-The optional 'features' member specifies features.  See "Features"
+The optional 'features' member specifies features.  See Features_
 below for more on this.
 
 
@@ -511,10 +517,10 @@ Syntax::
 
 Member 'command' names the command.
 
-Member 'data' defines the arguments.  It defaults to an empty MEMBERS
+Member 'data' defines the arguments.  It defaults to an empty MEMBERS_
 object.
 
-If 'data' is a MEMBERS object, then MEMBERS defines arguments just
+If 'data' is a MEMBERS_ object, then MEMBERS defines arguments just
 like a struct type's 'data' defines struct type members.
 
 If 'data' is a STRING, then STRING names a complex type whose members
@@ -553,7 +559,7 @@ which would validate this Client JSON Protocol transaction::
 
 The generator emits a prototype for the C function implementing the
 command.  The function itself needs to be written by hand.  See
-section "Code generated for commands" for examples.
+section `Code generated for commands`_ for examples.
 
 The function returns the return type.  When member 'boxed' is absent,
 it takes the command arguments as arguments one by one, in QAPI schema
@@ -660,10 +666,10 @@ for a command.  We don't currently have a use case for both together and
 without a use case, it's not entirely clear what the semantics should
 be.
 
-The optional 'if' member specifies a conditional.  See "Configuring
-the schema" below for more on this.
+The optional 'if' member specifies a conditional.  See `Configuring
+the schema`_ below for more on this.
 
-The optional 'features' member specifies features.  See "Features"
+The optional 'features' member specifies features.  See Features_
 below for more on this.
 
 
@@ -708,15 +714,17 @@ Resulting in this JSON object::
 The generator emits a function to send the event.  When member 'boxed'
 is absent, it takes event-specific data one by one, in QAPI schema
 order.  Else it takes them wrapped in the C struct generated for the
-complex type.  See section "Code generated for events" for examples.
+complex type.  See section `Code generated for events`_ for examples.
 
-The optional 'if' member specifies a conditional.  See "Configuring
-the schema" below for more on this.
+The optional 'if' member specifies a conditional.  See `Configuring
+the schema`_ below for more on this.
 
-The optional 'features' member specifies features.  See "Features"
+The optional 'features' member specifies features.  See Features_
 below for more on this.
 
 
+.. _FEATURE:
+
 Features
 --------
 
@@ -735,8 +743,8 @@ For this purpose, a list of features can be specified for a command or
 struct type.  Each list member can either be ``{ 'name': STRING, '*if':
 COND }``, or STRING, which is shorthand for ``{ 'name': STRING }``.
 
-The optional 'if' member specifies a conditional.  See "Configuring
-the schema" below for more on this.
+The optional 'if' member specifies a conditional.  See `Configuring
+the schema`_ below for more on this.
 
 Example::
 
@@ -745,7 +753,7 @@ Example::
    'features': [ 'allow-negative-numbers' ] }
 
 The feature strings are exposed to clients in introspection, as
-explained in section "Client JSON Protocol introspection".
+explained in section `Client JSON Protocol introspection`_.
 
 Intended use is to have each feature string signal that this build of
 QEMU shows a certain behaviour.
@@ -764,7 +772,7 @@ Naming rules and reserved names
 All names must begin with a letter, and contain only ASCII letters,
 digits, hyphen, and underscore.  There are two exceptions: enum values
 may start with a digit, and names that are downstream extensions (see
-section Downstream extensions) start with underscore.
+section `Downstream extensions`_) start with underscore.
 
 Names beginning with ``q_`` are reserved for the generator, which uses
 them for munging QMP names that resemble C keywords or other
@@ -794,8 +802,9 @@ Any name (command, event, type, member, or enum value) beginning with
 ``x-`` is marked experimental, and may be withdrawn or changed
 incompatibly in a future release.
 
-Pragmas ``command-name-exceptions`` and ``member-name-exceptions`` let you
-violate naming rules.  Use for new code is strongly discouraged.
+Pragmas ``command-name-exceptions`` and ``member-name-exceptions`` let
+you violate naming rules.  Use for new code is strongly discouraged. See
+`Pragma directives`_ for details.
 
 
 Downstream extensions
@@ -851,7 +860,7 @@ member 'bar' ::
 A union's discriminator may not be conditional.
 
 Likewise, individual enumeration values be conditional.  This requires
-the longhand form of ENUM-VALUE.
+the longhand form of ENUM-VALUE_.
 
 Example: an enum type with unconditional value 'foo' and conditional
 value 'bar' ::
@@ -861,7 +870,7 @@ value 'bar' ::
      { 'name' : 'bar', 'if': 'defined(IFCOND)' } ] }
 
 Likewise, features can be conditional.  This requires the longhand
-form of FEATURE.
+form of FEATURE_.
 
 Example: a struct with conditional feature 'allow-negative-numbers' ::
 
@@ -893,7 +902,7 @@ If the documentation comment starts like ::
 it documents the definition of SYMBOL, else it's free-form
 documentation.
 
-See below for more on definition documentation.
+See below for more on `Definition documentation`_.
 
 Free-form documentation may be used to provide additional text and
 structuring content.
@@ -984,7 +993,7 @@ Definition documentation
 Definition documentation, if present, must immediately precede the
 definition it documents.
 
-When documentation is required (see pragma 'doc-required'), every
+When documentation is required (see pragma_ 'doc-required'), every
 definition must have documentation.
 
 Definition documentation starts with a line naming the definition,
@@ -1181,7 +1190,7 @@ the wire then.
 Each command or event defined with 'data' as MEMBERS object in the
 QAPI schema implicitly defines an object type.
 
-Example: the SchemaInfo for EVENT_C from section Events ::
+Example: the SchemaInfo for EVENT_C from section Events_ ::
 
     { "name": "EVENT_C", "meta-type": "event",
       "arg-type": "q_obj-EVENT_C-arg" }
@@ -1205,7 +1214,7 @@ extensions.  The "members" array is in no particular order; clients
 must search the entire object when learning whether a particular
 member is supported.
 
-Example: the SchemaInfo for MyType from section Struct types ::
+Example: the SchemaInfo for MyType from section `Struct types`_ ::
 
     { "name": "MyType", "meta-type": "object",
       "members": [
@@ -1216,7 +1225,7 @@ Example: the SchemaInfo for MyType from section Struct types ::
 "features" exposes the command's feature strings as a JSON array of
 strings.
 
-Example: the SchemaInfo for TestType from section Features::
+Example: the SchemaInfo for TestType from section Features_::
 
     { "name": "TestType", "meta-type": "object",
       "members": [
@@ -1232,7 +1241,7 @@ that provides the variant members for this type tag value).  The
 list cases in the same order as the corresponding "tag" enum type.
 
 Example: the SchemaInfo for flat union BlockdevOptions from section
-Union types ::
+`Union types`_ ::
 
     { "name": "BlockdevOptions", "meta-type": "object",
       "members": [
@@ -1247,13 +1256,13 @@ Note that base types are "flattened": its members are included in the
 "members" array.
 
 A simple union implicitly defines an enumeration type for its implicit
-discriminator (called "type" on the wire, see section Union types).
+discriminator (called "type" on the wire, see section `Union types`_).
 
 A simple union implicitly defines an object type for each of its
 variants.
 
 Example: the SchemaInfo for simple union BlockdevOptionsSimple from section
-Union types ::
+`Union types`_ ::
 
     { "name": "BlockdevOptionsSimple", "meta-type": "object",
       "members": [
@@ -1273,7 +1282,7 @@ a JSON object with member "type", which names a type.  Values of the
 alternate type conform to exactly one of its member types.  There is
 no guarantee on the order in which "members" will be listed.
 
-Example: the SchemaInfo for BlockdevRef from section Alternate types ::
+Example: the SchemaInfo for BlockdevRef from section `Alternate types`_ ::
 
     { "name": "BlockdevRef", "meta-type": "alternate",
       "members": [
@@ -1297,13 +1306,13 @@ variant member "values".  The values are listed in no particular
 order; clients must search the entire enum when learning whether a
 particular value is supported.
 
-Example: the SchemaInfo for MyEnum from section Enumeration types ::
+Example: the SchemaInfo for MyEnum from section `Enumeration types`_ ::
 
     { "name": "MyEnum", "meta-type": "enum",
       "values": [ "value1", "value2", "value3" ] }
 
 The SchemaInfo for a built-in type has the same name as the type in
-the QAPI schema (see section Built-in Types), with one exception
+the QAPI schema (see section `Built-in Types`_), with one exception
 detailed below.  It has variant member "json-type" that shows how
 values of this type are encoded on the wire.
 
@@ -1505,7 +1514,7 @@ Example::
 
     [Uninteresting stuff omitted...]
 
-For a modular QAPI schema (see section Include directives), code for
+For a modular QAPI schema (see section `Include directives`_), code for
 each sub-module SUBDIR/SUBMODULE.json is actually generated into ::
 
  SUBDIR/$(prefix)qapi-types-SUBMODULE.h
@@ -1636,7 +1645,7 @@ Example::
 
     [Uninteresting stuff omitted...]
 
-For a modular QAPI schema (see section Include directives), code for
+For a modular QAPI schema (see section `Include directives`_), code for
 each sub-module SUBDIR/SUBMODULE.json is actually generated into ::
 
  SUBDIR/$(prefix)qapi-visit-SUBMODULE.h
@@ -1764,7 +1773,7 @@ Example::
     }
     [Uninteresting stuff omitted...]
 
-For a modular QAPI schema (see section Include directives), code for
+For a modular QAPI schema (see section `Include directives`_), code for
 each sub-module SUBDIR/SUBMODULE.json is actually generated into::
 
  SUBDIR/$(prefix)qapi-commands-SUBMODULE.h
@@ -1853,7 +1862,7 @@ Example::
 
     [Uninteresting stuff omitted...]
 
-For a modular QAPI schema (see section Include directives), code for
+For a modular QAPI schema (see section `Include directives`_), code for
 each sub-module SUBDIR/SUBMODULE.json is actually generated into ::
 
  SUBDIR/$(prefix)qapi-events-SUBMODULE.h
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] docs: convert qapi-code-gen.txt to qapi-code-gen.rst
  2021-07-20 23:56 [PATCH 0/3] docs: convert qapi-code-gen.txt to qapi-code-gen.rst John Snow
                   ` (2 preceding siblings ...)
  2021-07-20 23:56 ` [PATCH 3/3] docs/qapi-code-gen: add cross-references John Snow
@ 2021-07-27 12:48 ` Peter Maydell
  2021-08-04  8:48   ` Markus Armbruster
  3 siblings, 1 reply; 8+ messages in thread
From: Peter Maydell @ 2021-07-27 12:48 UTC (permalink / raw)
  To: John Snow; +Cc: Michael Roth, QEMU Developers, Markus Armbruster

On Wed, 21 Jul 2021 at 00:58, John Snow <jsnow@redhat.com> wrote:
>
> Patch 1 does (roughly) the bare minimum, patch 2 adds some formatting,
> and patch 3 adds cross-references.
>
> John Snow (3):
>   docs: convert qapi-code-gen.txt to ReST
>   docs/qapi-code-gen: Beautify formatting
>   docs/qapi-code-gen: add cross-references

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] docs: convert qapi-code-gen.txt to qapi-code-gen.rst
  2021-07-27 12:48 ` [PATCH 0/3] docs: convert qapi-code-gen.txt to qapi-code-gen.rst Peter Maydell
@ 2021-08-04  8:48   ` Markus Armbruster
  2021-08-04 14:49     ` John Snow
  0 siblings, 1 reply; 8+ messages in thread
From: Markus Armbruster @ 2021-08-04  8:48 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Michael Roth, John Snow, QEMU Developers

Peter Maydell <peter.maydell@linaro.org> writes:

> On Wed, 21 Jul 2021 at 00:58, John Snow <jsnow@redhat.com> wrote:
>>
>> Patch 1 does (roughly) the bare minimum, patch 2 adds some formatting,
>> and patch 3 adds cross-references.
>>
>> John Snow (3):
>>   docs: convert qapi-code-gen.txt to ReST
>>   docs/qapi-code-gen: Beautify formatting
>>   docs/qapi-code-gen: add cross-references
>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

Let's queue this after my "[PATCH] docs/devel/qapi-code-gen: Update
examples to match current code".

For 6.1, or "don't rock the boat now"?



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] docs: convert qapi-code-gen.txt to qapi-code-gen.rst
  2021-08-04  8:48   ` Markus Armbruster
@ 2021-08-04 14:49     ` John Snow
  2021-08-04 14:51       ` Peter Maydell
  0 siblings, 1 reply; 8+ messages in thread
From: John Snow @ 2021-08-04 14:49 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: Peter Maydell, QEMU Developers, Michael Roth

[-- Attachment #1: Type: text/plain, Size: 888 bytes --]

On Wed, Aug 4, 2021 at 4:48 AM Markus Armbruster <armbru@redhat.com> wrote:

> Peter Maydell <peter.maydell@linaro.org> writes:
>
> > On Wed, 21 Jul 2021 at 00:58, John Snow <jsnow@redhat.com> wrote:
> >>
> >> Patch 1 does (roughly) the bare minimum, patch 2 adds some formatting,
> >> and patch 3 adds cross-references.
> >>
> >> John Snow (3):
> >>   docs: convert qapi-code-gen.txt to ReST
> >>   docs/qapi-code-gen: Beautify formatting
> >>   docs/qapi-code-gen: add cross-references
> >
> > Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>
> Let's queue this after my "[PATCH] docs/devel/qapi-code-gen: Update
> examples to match current code".
>
>
Sure. Do you need a rebase? (I don't see that patch in origin/master right
now.)


> For 6.1, or "don't rock the boat now"?
>

No preference. In response to the same question on the other doc conversion
patch, "No preference."

[-- Attachment #2: Type: text/html, Size: 1746 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] docs: convert qapi-code-gen.txt to qapi-code-gen.rst
  2021-08-04 14:49     ` John Snow
@ 2021-08-04 14:51       ` Peter Maydell
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Maydell @ 2021-08-04 14:51 UTC (permalink / raw)
  To: John Snow; +Cc: Michael Roth, Markus Armbruster, QEMU Developers

On Wed, 4 Aug 2021 at 15:49, John Snow <jsnow@redhat.com> wrote:
>
>
>
> On Wed, Aug 4, 2021 at 4:48 AM Markus Armbruster <armbru@redhat.com> wrote:
>>
>> For 6.1, or "don't rock the boat now"?
>
>
> No preference. In response to the same question on the other doc conversion patch, "No preference."

I have no strong preference either. Docs changes are about
as safe as it gets so I don't mind them in rc3.

-- PMM


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-08-04 17:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-20 23:56 [PATCH 0/3] docs: convert qapi-code-gen.txt to qapi-code-gen.rst John Snow
2021-07-20 23:56 ` [PATCH 1/3] docs: convert qapi-code-gen.txt to ReST John Snow
2021-07-20 23:56 ` [PATCH 2/3] docs/qapi-code-gen: Beautify formatting John Snow
2021-07-20 23:56 ` [PATCH 3/3] docs/qapi-code-gen: add cross-references John Snow
2021-07-27 12:48 ` [PATCH 0/3] docs: convert qapi-code-gen.txt to qapi-code-gen.rst Peter Maydell
2021-08-04  8:48   ` Markus Armbruster
2021-08-04 14:49     ` John Snow
2021-08-04 14:51       ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).