qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com
Subject: [Qemu-devel] [PATCH 3/5] qapi: Make placeholders more obvious in doc usage statements
Date: Wed, 25 Mar 2015 18:13:55 -0600	[thread overview]
Message-ID: <1427328837-4406-4-git-send-email-eblake@redhat.com> (raw)
In-Reply-To: <1427328837-4406-1-git-send-email-eblake@redhat.com>

Using QAPI syntax to describe QAPI syntax is a bit meta; using
different typographic conventions makes it a bit easier to see
which strings are literal vs. placeholders.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 docs/qapi-code-gen.txt | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/docs/qapi-code-gen.txt b/docs/qapi-code-gen.txt
index 7fb0db7..c155f95 100644
--- a/docs/qapi-code-gen.txt
+++ b/docs/qapi-code-gen.txt
@@ -119,10 +119,12 @@ generator will rename a field named "default" in the QAPI to
 "q_default" in the generated C code.

 In the rest of this document, usage lines are given for each
-expression type, written in the style of the QAPI syntax.  For
-example, a usage statement that includes '*base':'complex-type-name'
-means that an expression has an optional key 'base', which if present
-must have a value that forms a 'complex-type-name'.
+expression type, with literal strings written in lower case and
+placeholders written in capitals.  If a literal string includes a
+prefix of '*', it can be omitted from that expression.  For example, a
+usage statement that includes '*base':COMPLEX-TYPE-NAME means that an
+expression has an optional key 'base', which if present must have a
+value that forms a complex type name.


 === Built-in Types ===
@@ -141,7 +143,7 @@ The following types are built-in to the parser:

 === Includes ===

-Usage: { 'include': 'str' }
+Usage: { 'include': STRING }

 The QAPI schema definitions can be modularized using the 'include' directive:

@@ -161,7 +163,7 @@ prevent incomplete include files.

 === Complex types ===

-Usage: { 'type': 'str', 'data': 'dict', '*base': 'complex-type-name' }
+Usage: { 'type': STRING, 'data': DICT, '*base': COMPLEX-TYPE-NAME }

 A complex type is a dictionary containing a single 'data' key whose
 value is a dictionary.  This corresponds to a struct in C or an Object
@@ -221,7 +223,7 @@ both fields like this:

 === Enumeration types ===

-Usage: { 'enum': 'str', 'data': [ 'str' ] }
+Usage: { 'enum': STRING, 'data': ARRAY-OF-STRING }

 An enumeration type is a dictionary containing a single 'data' key
 whose value is a list of strings.  An example enumeration is:
@@ -250,9 +252,9 @@ open-coding the field to be type 'str'.

 === Union types ===

-Usage: { 'union': 'str', 'data': 'dict' }
-or:    { 'union': 'str', 'data': 'dict', 'base': 'complex-type-name',
-         'discriminator': 'enum-member-of-base' }
+Usage: { 'union': STRING, 'data': DICT }
+or:    { 'union': STRING, 'data': DICT, 'base': COMPLEX-TYPE-NAME,
+         'discriminator': ENUM-MEMBER-OF-BASE }

 Union types are used to let the user choose between several different
 data types.  There are two flavors: simple (no discriminator or base),
@@ -329,7 +331,7 @@ Resulting in this JSON object:

 === Alternate types ===

-Usage: { 'alternate: 'str', 'data': 'dict' }
+Usage: { 'alternate: STRING, 'data': DICT }

 An alternate type is one that allows a choice between two or more JSON
 data types on the wire.  The definition is similar to a simple union
@@ -361,8 +363,8 @@ This example allows using both of the following example objects:

 === Commands ===

-Usage: { 'command': 'str', '*data': 'dict-or-complex-type-name',
-         '*returns': 'dict-or-type-name',
+Usage: { 'command': STRING, '*data': COMPLEX-TYPE-NAME-OR-DICT,
+         '*returns': TYPE-NAME-OR-DICT,
          '*gen': false, '*success-response': false }

 Commands are defined by using a dictionary containing several members,
@@ -439,7 +441,7 @@ qemu-guest-agent makes use of this field.

 === Events ===

-Usage: { 'event': 'str', '*data': 'dict-or-complex-type-name' }
+Usage: { 'event': STRING, '*data': COMPLEX-TYPE-NAME-OR-DICT }

 Events are defined with the keyword 'event'.  It is not allowed to
 name an event 'MAX', since the generator also produces a C enumeration
-- 
2.1.0

  parent reply	other threads:[~2015-03-26  0:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-26  0:13 [Qemu-devel] [PATCH 0/5] qapi doc cleanups Eric Blake
2015-03-26  0:13 ` [Qemu-devel] [PATCH 1/5] qapi: Minor tweaks to qapi-code-gen.txt Eric Blake
2015-03-26  0:13 ` [Qemu-devel] [PATCH 2/5] qapi: Clean up documentation of alternate mappings Eric Blake
2015-03-27 11:02   ` Markus Armbruster
2015-03-30 15:54     ` Eric Blake
2015-03-26  0:13 ` Eric Blake [this message]
2015-03-26  0:13 ` [Qemu-devel] [PATCH 4/5] qapi: Tweak doc references to QMP when QGA is also meant Eric Blake
2015-03-26  0:13 ` [Qemu-devel] [PATCH 5/5] qapi: Fix QMP spec references to JSON Eric Blake
2015-03-27 11:05 ` [Qemu-devel] [PATCH 0/5] qapi doc cleanups Markus Armbruster
2015-05-08 14:29 ` Markus Armbruster
2015-05-08 14:41   ` Eric Blake

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=1427328837-4406-4-git-send-email-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is 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).