From: Markus Armbruster <armbru@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org, Michael Roth <mdroth@linux.vnet.ibm.com>,
armbru@redhat.com, "Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v6 13/15] qapi: add 'If:' section to generated documentation
Date: Tue, 03 Jul 2018 16:59:40 +0200 [thread overview]
Message-ID: <87d0w48iw3.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20180627163551.31610-14-marcandre.lureau@redhat.com> ("Marc-André Lureau"'s message of "Wed, 27 Jun 2018 18:35:49 +0200")
Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> The documentation is generated only once, and doesn't know C
> pre-conditions. Add 'If:' sections for top-level entities.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> scripts/qapi/doc.py | 22 ++++++++++++----------
> tests/qapi-schema/doc-good.json | 2 +-
> tests/qapi-schema/doc-good.out | 1 +
> tests/qapi-schema/doc-good.texi | 2 ++
> 4 files changed, 16 insertions(+), 11 deletions(-)
>
> diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py
> index 4db6674dc3..987fd3c943 100755
> --- a/scripts/qapi/doc.py
> +++ b/scripts/qapi/doc.py
> @@ -174,7 +174,7 @@ def texi_members(doc, what, base, variants, member_func):
> return '\n@b{%s:}\n@table @asis\n%s@end table\n' % (what, items)
>
>
> -def texi_sections(doc):
> +def texi_sections(doc, ifcond):
> """Format additional sections following arguments"""
> body = ''
> for section in doc.sections:
> @@ -185,14 +185,16 @@ def texi_sections(doc):
> body += texi_example(section.text)
> else:
> body += texi_format(section.text)
> + if ifcond:
> + body += '\n\n@b{If:} @code{%s}' % ", ".join(ifcond)
> return body
>
>
> -def texi_entity(doc, what, base=None, variants=None,
> +def texi_entity(doc, what, ifcond, base=None, variants=None,
> member_func=texi_member):
> return (texi_body(doc)
> + texi_members(doc, what, base, variants, member_func)
> - + texi_sections(doc))
> + + texi_sections(doc, ifcond))
>
>
> class QAPISchemaGenDocVisitor(qapi.common.QAPISchemaVisitor):
> @@ -208,7 +210,7 @@ class QAPISchemaGenDocVisitor(qapi.common.QAPISchemaVisitor):
> doc = self.cur_doc
> self._gen.add(TYPE_FMT(type='Enum',
> name=doc.symbol,
> - body=texi_entity(doc, 'Values',
> + body=texi_entity(doc, 'Values', ifcond,
> member_func=texi_enum_value)))
>
> def visit_object_type(self, name, info, ifcond, base, members, variants):
> @@ -217,14 +219,14 @@ class QAPISchemaGenDocVisitor(qapi.common.QAPISchemaVisitor):
> base = None
> self._gen.add(TYPE_FMT(type='Object',
> name=doc.symbol,
> - body=texi_entity(doc, 'Members',
> + body=texi_entity(doc, 'Members', ifcond,
> base, variants)))
>
> def visit_alternate_type(self, name, info, ifcond, variants):
> doc = self.cur_doc
> self._gen.add(TYPE_FMT(type='Alternate',
> name=doc.symbol,
> - body=texi_entity(doc, 'Members')))
> + body=texi_entity(doc, 'Members', ifcond)))
>
> def visit_command(self, name, info, ifcond, arg_type, ret_type, gen,
> success_response, boxed, allow_oob, allow_preconfig):
> @@ -233,9 +235,9 @@ class QAPISchemaGenDocVisitor(qapi.common.QAPISchemaVisitor):
> body = texi_body(doc)
> body += ('\n@b{Arguments:} the members of @code{%s}\n'
> % arg_type.name)
> - body += texi_sections(doc)
> + body += texi_sections(doc, ifcond)
> else:
> - body = texi_entity(doc, 'Arguments')
> + body = texi_entity(doc, 'Arguments', ifcond)
> self._gen.add(MSG_FMT(type='Command',
> name=doc.symbol,
> body=body))
> @@ -244,7 +246,7 @@ class QAPISchemaGenDocVisitor(qapi.common.QAPISchemaVisitor):
> doc = self.cur_doc
> self._gen.add(MSG_FMT(type='Event',
> name=doc.symbol,
> - body=texi_entity(doc, 'Arguments')))
> + body=texi_entity(doc, 'Arguments', ifcond)))
>
> def symbol(self, doc, entity):
> if self._gen._body:
> @@ -257,7 +259,7 @@ class QAPISchemaGenDocVisitor(qapi.common.QAPISchemaVisitor):
> assert not doc.args
> if self._gen._body:
> self._gen.add('\n')
> - self._gen.add(texi_body(doc) + texi_sections(doc))
> + self._gen.add(texi_body(doc) + texi_sections(doc, None))
>
>
> def gen_doc(schema, output_dir, prefix):
> diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.json
> index 97ab4625ff..984cd8ed06 100644
> --- a/tests/qapi-schema/doc-good.json
> +++ b/tests/qapi-schema/doc-good.json
> @@ -55,7 +55,7 @@
> #
> # @two is undocumented
> ##
> -{ 'enum': 'Enum', 'data': [ 'one', 'two' ] }
> +{ 'enum': 'Enum', 'data': [ 'one', 'two' ], 'if': 'defined(IFCOND)' }
>
> ##
> # @Base:
> diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
> index 9c8a4838e1..35f3f1164c 100644
> --- a/tests/qapi-schema/doc-good.out
> +++ b/tests/qapi-schema/doc-good.out
> @@ -3,6 +3,7 @@ enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
> prefix QTYPE
> module doc-good.json
> enum Enum ['one', 'two']
> + if ['defined(IFCOND)']
> object Base
> member base1: Enum optional=False
> object Variant1
> diff --git a/tests/qapi-schema/doc-good.texi b/tests/qapi-schema/doc-good.texi
> index 0aed2300a5..e42eace474 100644
> --- a/tests/qapi-schema/doc-good.texi
> +++ b/tests/qapi-schema/doc-good.texi
> @@ -89,6 +89,8 @@ Not documented
> @end table
> @code{two} is undocumented
>
> +
> +@b{If:} @code{defined(IFCOND)}
> @end deftp
One blank line would be better, but that's as pervasive as it is minor.
Reviewed-by: Markus Armbruster <armbru@redhat.com>
For the record, wanted follow-up work, from v5's review:
* The big comment in qapi-schema.json should explain the documentation
format, including the meaning of tags like 'If:', 'Since:' and so
forth
* Better test coverage
next prev parent reply other threads:[~2018-07-03 14:59 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-27 16:35 [Qemu-devel] [PATCH v6 00/15] qapi: add #if pre-processor conditions to generated code (part 1) Marc-André Lureau
2018-06-27 16:35 ` [Qemu-devel] [PATCH v6 01/15] qapi: add 'if' to top-level expressions Marc-André Lureau
2018-06-28 14:57 ` Markus Armbruster
2018-06-28 15:34 ` Marc-André Lureau
2018-06-27 16:35 ` [Qemu-devel] [PATCH v6 02/15] tests Marc-André Lureau
2018-06-27 16:39 ` Marc-André Lureau
2018-06-28 15:35 ` Markus Armbruster
2018-06-27 16:35 ` [Qemu-devel] [PATCH v6 03/15] qapi: pass 'if' condition into QAPISchemaEntity objects Marc-André Lureau
2018-06-27 16:35 ` [Qemu-devel] [PATCH v6 04/15] qapi: leave the ifcond attribute undefined until check() Marc-André Lureau
2018-06-28 17:45 ` Markus Armbruster
2018-06-27 16:35 ` [Qemu-devel] [PATCH v6 05/15] qapi: add 'ifcond' to visitor methods Marc-André Lureau
2018-06-28 17:48 ` Markus Armbruster
2018-06-27 16:35 ` [Qemu-devel] [PATCH v6 06/15] qapi: mcgen() shouldn't indent # lines Marc-André Lureau
2018-06-27 16:35 ` [Qemu-devel] [PATCH v6 07/15] qapi: add #if/#endif helpers Marc-André Lureau
2018-07-03 11:53 ` Markus Armbruster
2018-07-03 12:35 ` Marc-André Lureau
2018-07-03 13:37 ` Markus Armbruster
2018-07-03 15:08 ` Marc-André Lureau
2018-07-03 15:34 ` Markus Armbruster
2018-07-03 15:43 ` Marc-André Lureau
2018-06-27 16:35 ` [Qemu-devel] [PATCH v6 08/15] qapi-introspect: modify to_qlit() to append ', ' on level > 0 Marc-André Lureau
2018-06-27 16:35 ` [Qemu-devel] [PATCH v6 09/15] qapi-introspect: add preprocessor conditions to generated QLit Marc-André Lureau
2018-07-03 12:09 ` Markus Armbruster
2018-07-03 13:11 ` Marc-André Lureau
2018-07-03 13:47 ` Markus Armbruster
2018-07-03 15:08 ` Markus Armbruster
2018-06-27 16:35 ` [Qemu-devel] [PATCH v6 10/15] qapi/commands: add #if conditions to commands Marc-André Lureau
2018-07-03 14:43 ` Markus Armbruster
2018-07-03 15:09 ` Markus Armbruster
2018-06-27 16:35 ` [Qemu-devel] [PATCH v6 11/15] qapi/events: add #if conditions to events Marc-André Lureau
2018-07-03 14:47 ` Markus Armbruster
2018-06-27 16:35 ` [Qemu-devel] [PATCH v6 12/15] qapi-types: add #if conditions to types & visitors Marc-André Lureau
2018-07-03 14:50 ` Markus Armbruster
2018-06-27 16:35 ` [Qemu-devel] [PATCH v6 13/15] qapi: add 'If:' section to generated documentation Marc-André Lureau
2018-07-03 14:59 ` Markus Armbruster [this message]
2018-06-27 16:35 ` [Qemu-devel] [PATCH v6 14/15] qapi: add conditions to VNC type/commands/events on the schema Marc-André Lureau
2018-07-03 15:04 ` Markus Armbruster
2018-06-27 16:35 ` [Qemu-devel] [PATCH v6 15/15] qapi: add conditions to SPICE " Marc-André Lureau
2018-07-03 15:05 ` Markus Armbruster
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=87d0w48iw3.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=pbonzini@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 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.