From: Eric Blake <eblake@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>, qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@gmail.com>,
armbru@redhat.com, mdroth@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH 3/5] qapi: add qapi2texi script
Date: Mon, 27 Jul 2015 16:31:57 -0600 [thread overview]
Message-ID: <55B6B15D.2080709@redhat.com> (raw)
In-Reply-To: <1435917064-17827-4-git-send-email-marcandre.lureau@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3566 bytes --]
On 07/03/2015 03:51 AM, Marc-André Lureau wrote:
> From: Marc-André Lureau <marcandre.lureau@gmail.com>
>
> As the name suggests, the qapi2texi script converts JSON QAPI
> description into a standalone texi file suitable for different target
> formats.
>
> As the documentation format doesn't seem to be specified, it parses the
> following blocks before each declaration with some variations:
docs/qapi-code-gen.txt tried to give a sample documentation. Feel free
to formalize that, and to fix non-conforming uses, if you desire. It'll
be a big one-time audit of the .json files, but getting things
consistent, _and keeping them that way by automatic conformance checks
in your conversion tool_, is fine by me.
>
> ##
> # @symbol
> #
> # body
> #
> # @arg: foo
> # @arg: #optional foo
> #
> # Returns: returns
> # Since: version
> # Notes: notes
> ##
>
> Using the json declaration, it's able to give extra information about
> the type of arguments and return value expected.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> scripts/qapi.py | 78 ++++++++++++++++++-
> scripts/qapi2texi.py | 212 +++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 286 insertions(+), 4 deletions(-)
> create mode 100644 scripts/qapi2texi.py
Are you intending to apply this after Markus' big work on QMP Introspection?
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 06d7fc2..70208e8 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -103,6 +103,53 @@ class QAPIExprError(Exception):
> return error_path(self.info['parent']) + \
> "%s:%d: %s" % (self.info['file'], self.info['line'], self.msg)
>
> +class QAPIDoc:
In particular, this should probably be QAPIDoc(object) (new style class
declaration).
> @@ -762,6 +823,15 @@ def parse_schema(fname):
> print >>sys.stderr, e
> exit(1)
>
> +def parse_schema_full(fname):
> + try:
> + schema = QAPISchema(open(fname, "r"))
> + check_exprs(schema.exprs)
> + return schema.exprs
> + except (QAPISchemaError, QAPIExprError), e:
> + print >>sys.stderr, e
> + exit(1)
and this may need to be reworked on top of Markus' new parser class.
> +++ b/scripts/qapi2texi.py
> @@ -0,0 +1,212 @@
> +# QAPI texi generator
> +#
> +# This work is licensed under the terms of the GNU GPL, version 2.
> +# See the COPYING file in the top-level directory.
Although I'm not a lawyer, my understanding is that for GPL to apply,
there has to be an explicit mention of Copyright.
> +exprs = parse_schema_full(sys.argv[4])
And you'll probably want to rewrite this in terms of the visitor interface.
> +for cmd in exprs:
> + expr = cmd['expr']
> + docs = cmd['info']['doc']
> + (kind, name) = expr.items()[0]
> +
> + for d in docs[0:-1]:
> + print d.comment
> +
> + texi = {"command": texi_command,
> + "struct": texi_struct,
> + "enum": texi_enum,
> + "union": texi_union,
> + "alternate": texi_alternate,
> + "event": texi_event}
> + try:
> + texi[kind](expr, docs[-1])
> + except KeyError:
> + raise ValueError("Unknown expression kind '%s'" % kind)
although this is a rather cute way to polymorphically invoke the correct
helper function.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2015-07-27 22:32 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-03 9:50 [Qemu-devel] [PATCH 0/5] RFC: generate QAPI doc from json Marc-André Lureau
2015-07-03 9:51 ` [Qemu-devel] [PATCH 1/5] qapi: add comment block before ChardevDummy Marc-André Lureau
2015-07-27 22:11 ` Eric Blake
2015-07-03 9:51 ` [Qemu-devel] [PATCH 2/5] qapi: add missing @ Marc-André Lureau
2015-07-03 10:09 ` [Qemu-trivial] " Markus Armbruster
2015-07-03 10:09 ` Markus Armbruster
2015-07-27 19:36 ` [Qemu-trivial] " Michael Tokarev
2015-07-27 19:36 ` [Qemu-devel] " Michael Tokarev
2015-07-03 9:51 ` [Qemu-devel] [PATCH 3/5] qapi: add qapi2texi script Marc-André Lureau
2015-07-27 22:31 ` Eric Blake [this message]
2015-07-27 23:39 ` Marc-André Lureau
2015-07-03 9:51 ` [Qemu-devel] [PATCH 4/5] texi2pod: learn quotation, deftp and deftypefn Marc-André Lureau
2015-09-08 11:45 ` Markus Armbruster
2015-09-08 12:08 ` Peter Maydell
2015-09-08 12:51 ` Markus Armbruster
2015-07-03 9:51 ` [Qemu-devel] [PATCH 5/5] build-sys: generate QAPI doc based on json Marc-André Lureau
2015-07-27 22:38 ` 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=55B6B15D.2080709@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=marcandre.lureau@gmail.com \
--cc=marcandre.lureau@redhat.com \
--cc=mdroth@linux.vnet.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.