From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>,
QEMU Developers <qemu-devel@nongnu.org>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] Sphinx for QEMU docs? (and a doc-comment format question)
Date: Thu, 5 Jan 2017 17:47:30 +0100 [thread overview]
Message-ID: <ab13f4a8-a2de-ac4f-5b01-c9948b027e36@redhat.com> (raw)
In-Reply-To: <CAFEAcA9q5PDj8CHp6naCbJN926nbHk_mt0E5uVmPGkkkCEWv3w@mail.gmail.com>
On 07/11/2016 16:03, Peter Maydell wrote:
> 2) some of the doc-comment format differences are irritating:
> . "function - short description" not "function: short description"
> . "&struct.fieldname" not ".@fieldname"
> . "&typename" not "#typename"
> 3) the most awkward part of kernel-doc syntax is that it bakes
> in the kernel's style choice of always using "struct foo"
> for types -- I don't think there's any way to document
> 'MemoryRegion' and 'AddressSpace' without the 'struct'
> coming out in the documentation output.
>
> We could fix (2) by loosening the kernel-doc script's
> parsing if we were happy to carry around a forked version
> of it. Fixing (3) requires more serious surgery on kernel-doc
> I suspect.
I've sent some changes to kernel-doc to simplify the implementation of
these changes (http://www.spinics.net/lists/linux-doc/msg42354.html) and
they were accepted. So with 4.10 + those patches, the local changes to
kernel-doc for QEMU would be limited to the following:
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 4c9ada36fe6b..c43ac038398d 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -215,18 +215,18 @@ my $type_func = '(\w+)\(\)';
my $type_param = '\@(\w+(\.\.\.)?)';
my $type_fp_param = '\@(\w+)\(\)'; # Special RST handling for func ptr params
my $type_env = '(\$\w+)';
-my $type_enum = '\&(enum\s*([_\w]+))';
-my $type_struct = '\&(struct\s*([_\w]+))';
-my $type_typedef = '\&(typedef\s*([_\w]+))';
-my $type_union = '\&(union\s*([_\w]+))';
-my $type_member = '\&([_\w]+)(\.|->)([_\w]+)';
-my $type_fallback = '\&([_\w]+)';
-my $type_enum_xml = '\&(enum\s*([_\w]+))';
-my $type_struct_xml = '\&(struct\s*([_\w]+))';
-my $type_typedef_xml = '\&(typedef\s*([_\w]+))';
-my $type_union_xml = '\&(union\s*([_\w]+))';
-my $type_member_xml = '\&([_\w]+)(\.|-\>)([_\w]+)';
-my $type_fallback_xml = '\&([_\w]+)';
+my $type_enum = '#(enum\s*([_\w]+))';
+my $type_struct = '#(struct\s*([_\w]+))';
+my $type_typedef = '#(([A-Z][_\w]*))';
+my $type_union = '#(union\s*([_\w]+))';
+my $type_member = '#([_\w]+)(\.|->)([_\w]+)';
+my $type_fallback = '(?!)'; # this never matches
+my $type_enum_xml = $type_enum;
+my $type_struct_xml = $type_struct;
+my $type_typedef_xml = $type_typedef;
+my $type_union_xml = $type_union;
+my $type_member_xml = $type_member;
+my $type_fallback_xml = $type_fallback;
my $type_member_func = $type_member . '\(\)';
# Output conversion substitutions.
@@ -2143,6 +2143,14 @@ sub output_blockhead {
sub dump_declaration($$) {
no strict 'refs';
my ($prototype, $file) = @_;
+ if ($decl_type eq 'type name') {
+ if ($prototype =~ /^(enum|struct|union)\s+/) {
+ $decl_type = $1;
+ } else {
+ return;
+ }
+ }
+
my $func = "dump_" . $decl_type;
&$func(@_);
}
@@ -2893,7 +2901,7 @@ sub process_file($) {
}
elsif (/$doc_decl/o) {
$identifier = $1;
- if (/\s*([\w\s]+?)\s*-/) {
+ if (/\s*([\w\s]+?)(\s*-|:)/) {
$identifier = $1;
}
@@ -2903,7 +2911,7 @@ sub process_file($) {
$contents = "";
$section = $section_default;
$new_start_line = $. + 1;
- if (/-(.*)/) {
+ if (/[-:](.*)/) {
# strip leading/trailing/multiple spaces
$descr= $1;
$descr =~ s/^\s*//;
@@ -2921,7 +2929,9 @@ sub process_file($) {
++$warnings;
}
- if ($identifier =~ m/^struct/) {
+ if ($identifier =~ m/^[A-Z]/) {
+ $decl_type = 'type name';
+ } elsif ($identifier =~ m/^struct/) {
$decl_type = 'struct';
} elsif ($identifier =~ m/^union/) {
$decl_type = 'union';
which should be maintainable as a fork of Linux's kernel-doc.
I also worked a bit on support for Texinfo manuals in Sphinx. My
current attempt is at http://people.redhat.com/pbonzini/qemu-test-doc/_build/.
Because this uses a Texinfo->Docbook->Sphinx pipeline, I also tried some
tools with native Docbook support (Publican), but despite Sphinx's quirks
the output was less usable, and the tools were slower and harder to use.
http://wiki.qemu-project.org/Features/Documentation is another place to
brainstorm ideas on this.
Paolo
prev parent reply other threads:[~2017-01-05 16:47 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-05 18:42 [Qemu-devel] Sphinx for QEMU docs? (and a doc-comment format question) Peter Maydell
2016-11-07 9:35 ` Daniel P. Berrange
2016-11-07 13:30 ` Stefan Hajnoczi
2016-11-07 13:41 ` Daniel P. Berrange
2016-11-07 13:49 ` Peter Maydell
2016-11-07 22:52 ` John Snow
2016-11-08 16:20 ` Stefan Hajnoczi
2016-11-08 16:24 ` John Snow
2016-11-09 11:32 ` Stefan Hajnoczi
2016-11-10 3:39 ` Fam Zheng
2016-11-10 9:55 ` Stefan Hajnoczi
2016-11-10 10:08 ` Paolo Bonzini
2016-11-10 10:55 ` Daniel P. Berrange
2016-11-08 23:56 ` Paolo Bonzini
2016-11-07 15:03 ` Peter Maydell
2016-11-07 17:04 ` Paolo Bonzini
2016-11-07 17:20 ` Peter Maydell
2016-11-07 17:50 ` Paolo Bonzini
2016-11-07 18:23 ` Peter Maydell
2016-11-07 19:43 ` Paolo Bonzini
2016-11-07 20:36 ` Peter Maydell
2016-11-08 5:02 ` Emilio G. Cota
2017-01-05 16:47 ` Paolo Bonzini [this message]
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=ab13f4a8-a2de-ac4f-5b01-c9948b027e36@redhat.com \
--to=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).