kernel-doc: update kernel-doc related files to Linux v3.13

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Acked-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Masahiro Yamada 2014-02-05 10:52:51 +09:00 committed by Tom Rini
parent 8fac9c7b7d
commit ced032989a
4 changed files with 100 additions and 46 deletions

View file

@ -1,4 +1,3 @@
*/
*.xml *.xml
*.ps *.ps
*.pdf *.pdf

View file

@ -7,5 +7,4 @@
<!-- <param name="paper.type">A4</param> --> <!-- <param name="paper.type">A4</param> -->
<param name="generate.section.toc.level">2</param> <param name="generate.section.toc.level">2</param>
<param name="use.id.as.filename">1</param> <param name="use.id.as.filename">1</param>
<param name="html.stylesheet">../docbook.css</param>
</stylesheet> </stylesheet>

View file

@ -72,6 +72,7 @@ FILELINE * docsection;
#define FUNCTION "-function" #define FUNCTION "-function"
#define NOFUNCTION "-nofunction" #define NOFUNCTION "-nofunction"
#define NODOCSECTIONS "-no-doc-sections" #define NODOCSECTIONS "-no-doc-sections"
#define SHOWNOTFOUND "-show-not-found"
static char *srctree, *kernsrctree; static char *srctree, *kernsrctree;
@ -153,7 +154,7 @@ int symfilecnt = 0;
static void add_new_symbol(struct symfile *sym, char * symname) static void add_new_symbol(struct symfile *sym, char * symname)
{ {
sym->symbollist = sym->symbollist =
realloc(sym->symbollist, (sym->symbolcnt + 1) * sizeof(char *)); realloc(sym->symbollist, (sym->symbolcnt + 1) * sizeof(char *));
sym->symbollist[sym->symbolcnt++].name = strdup(symname); sym->symbollist[sym->symbolcnt++].name = strdup(symname);
} }
@ -214,7 +215,7 @@ static void find_export_symbols(char * filename)
char *p; char *p;
char *e; char *e;
if (((p = strstr(line, "EXPORT_SYMBOL_GPL")) != NULL) || if (((p = strstr(line, "EXPORT_SYMBOL_GPL")) != NULL) ||
((p = strstr(line, "EXPORT_SYMBOL")) != NULL)) { ((p = strstr(line, "EXPORT_SYMBOL")) != NULL)) {
/* Skip EXPORT_SYMBOL{_GPL} */ /* Skip EXPORT_SYMBOL{_GPL} */
while (isalnum(*p) || *p == '_') while (isalnum(*p) || *p == '_')
p++; p++;
@ -290,27 +291,28 @@ static void extfunc(char * filename) { docfunctions(filename, FUNCTION); }
static void singfunc(char * filename, char * line) static void singfunc(char * filename, char * line)
{ {
char *vec[200]; /* Enough for specific functions */ char *vec[200]; /* Enough for specific functions */
int i, idx = 0; int i, idx = 0;
int startofsym = 1; int startofsym = 1;
vec[idx++] = KERNELDOC; vec[idx++] = KERNELDOC;
vec[idx++] = DOCBOOK; vec[idx++] = DOCBOOK;
vec[idx++] = SHOWNOTFOUND;
/* Split line up in individual parameters preceded by FUNCTION */ /* Split line up in individual parameters preceded by FUNCTION */
for (i=0; line[i]; i++) { for (i=0; line[i]; i++) {
if (isspace(line[i])) { if (isspace(line[i])) {
line[i] = '\0'; line[i] = '\0';
startofsym = 1; startofsym = 1;
continue; continue;
} }
if (startofsym) { if (startofsym) {
startofsym = 0; startofsym = 0;
vec[idx++] = FUNCTION; vec[idx++] = FUNCTION;
vec[idx++] = &line[i]; vec[idx++] = &line[i];
} }
} }
for (i = 0; i < idx; i++) { for (i = 0; i < idx; i++) {
if (strcmp(vec[i], FUNCTION)) if (strcmp(vec[i], FUNCTION))
continue; continue;
consume_symbol(vec[i + 1]); consume_symbol(vec[i + 1]);
} }
vec[idx++] = filename; vec[idx++] = filename;
@ -325,7 +327,8 @@ static void singfunc(char * filename, char * line)
*/ */
static void docsect(char *filename, char *line) static void docsect(char *filename, char *line)
{ {
char *vec[6]; /* kerneldoc -docbook -function "section" file NULL */ /* kerneldoc -docbook -show-not-found -function "section" file NULL */
char *vec[7];
char *s; char *s;
for (s = line; *s; s++) for (s = line; *s; s++)
@ -341,10 +344,11 @@ static void docsect(char *filename, char *line)
vec[0] = KERNELDOC; vec[0] = KERNELDOC;
vec[1] = DOCBOOK; vec[1] = DOCBOOK;
vec[2] = FUNCTION; vec[2] = SHOWNOTFOUND;
vec[3] = line; vec[3] = FUNCTION;
vec[4] = filename; vec[4] = line;
vec[5] = NULL; vec[5] = filename;
vec[6] = NULL;
exec_kernel_doc(vec); exec_kernel_doc(vec);
} }
@ -456,14 +460,14 @@ static void parse_file(FILE *infile)
break; break;
case 'D': case 'D':
while (*s && !isspace(*s)) s++; while (*s && !isspace(*s)) s++;
*s = '\0'; *s = '\0';
symbolsonly(line+2); symbolsonly(line+2);
break; break;
case 'F': case 'F':
/* filename */ /* filename */
while (*s && !isspace(*s)) s++; while (*s && !isspace(*s)) s++;
*s++ = '\0'; *s++ = '\0';
/* function names */ /* function names */
while (isspace(*s)) while (isspace(*s))
s++; s++;
singlefunctions(line +2, s); singlefunctions(line +2, s);
@ -511,11 +515,11 @@ int main(int argc, char *argv[])
} }
/* Open file, exit on error */ /* Open file, exit on error */
infile = fopen(argv[2], "r"); infile = fopen(argv[2], "r");
if (infile == NULL) { if (infile == NULL) {
fprintf(stderr, "docproc: "); fprintf(stderr, "docproc: ");
perror(argv[2]); perror(argv[2]);
exit(2); exit(2);
} }
if (strcmp("doc", argv[1]) == 0) { if (strcmp("doc", argv[1]) == 0) {
/* Need to do this in two passes. /* Need to do this in two passes.

View file

@ -137,6 +137,8 @@ use strict;
# should document the "Context:" of the function, e.g. whether the functions # should document the "Context:" of the function, e.g. whether the functions
# can be called form interrupts. Unlike other sections you can end it with an # can be called form interrupts. Unlike other sections you can end it with an
# empty line. # empty line.
# A non-void function should have a "Return:" section describing the return
# value(s).
# Example-sections should contain the string EXAMPLE so that they are marked # Example-sections should contain the string EXAMPLE so that they are marked
# appropriately in DocBook. # appropriately in DocBook.
# #
@ -245,6 +247,7 @@ my $dohighlight = "";
my $verbose = 0; my $verbose = 0;
my $output_mode = "man"; my $output_mode = "man";
my $output_preformatted = 0;
my $no_doc_sections = 0; my $no_doc_sections = 0;
my %highlights = %highlights_man; my %highlights = %highlights_man;
my $blankline = $blankline_man; my $blankline = $blankline_man;
@ -254,6 +257,7 @@ my $man_date = ('January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'July', 'August', 'September', 'October',
'November', 'December')[(localtime)[4]] . 'November', 'December')[(localtime)[4]] .
" " . ((localtime)[5]+1900); " " . ((localtime)[5]+1900);
my $show_not_found = 0;
# Essentially these are globals. # Essentially these are globals.
# They probably want to be tidied up, made more localised or something. # They probably want to be tidied up, made more localised or something.
@ -295,9 +299,10 @@ my $doc_special = "\@\%\$\&";
my $doc_start = '^/\*\*\s*$'; # Allow whitespace at end of comment start. my $doc_start = '^/\*\*\s*$'; # Allow whitespace at end of comment start.
my $doc_end = '\*/'; my $doc_end = '\*/';
my $doc_com = '\s*\*\s*'; my $doc_com = '\s*\*\s*';
my $doc_com_body = '\s*\* ?';
my $doc_decl = $doc_com . '(\w+)'; my $doc_decl = $doc_com . '(\w+)';
my $doc_sect = $doc_com . '([' . $doc_special . ']?[\w\s]+):(.*)'; my $doc_sect = $doc_com . '([' . $doc_special . ']?[\w\s]+):(.*)';
my $doc_content = $doc_com . '(.*)'; my $doc_content = $doc_com_body . '(.*)';
my $doc_block = $doc_com . 'DOC:\s*(.*)?'; my $doc_block = $doc_com . 'DOC:\s*(.*)?';
my %constants; my %constants;
@ -313,6 +318,7 @@ my $section_default = "Description"; # default section
my $section_intro = "Introduction"; my $section_intro = "Introduction";
my $section = $section_default; my $section = $section_default;
my $section_context = "Context"; my $section_context = "Context";
my $section_return = "Return";
my $undescribed = "-- undescribed --"; my $undescribed = "-- undescribed --";
@ -364,6 +370,8 @@ while ($ARGV[0] =~ m/^-(.*)/) {
usage(); usage();
} elsif ($cmd eq '-no-doc-sections') { } elsif ($cmd eq '-no-doc-sections') {
$no_doc_sections = 1; $no_doc_sections = 1;
} elsif ($cmd eq '-show-not-found') {
$show_not_found = 1;
} }
} }
@ -432,7 +440,7 @@ sub dump_doc_section {
my $contents = join "\n", @_; my $contents = join "\n", @_;
if ($no_doc_sections) { if ($no_doc_sections) {
return; return;
} }
if (($function_only == 0) || if (($function_only == 0) ||
@ -485,8 +493,13 @@ sub output_highlight {
$contents =~ s/\s+$//; $contents =~ s/\s+$//;
} }
foreach $line (split "\n", $contents) { foreach $line (split "\n", $contents) {
if (! $output_preformatted) {
$line =~ s/^\s*//;
}
if ($line eq ""){ if ($line eq ""){
print $lineprefix, local_unescape($blankline); if (! $output_preformatted) {
print $lineprefix, local_unescape($blankline);
}
} else { } else {
$line =~ s/\\\\\\/\&/g; $line =~ s/\\\\\\/\&/g;
if ($output_mode eq "man" && substr($line, 0, 1) eq ".") { if ($output_mode eq "man" && substr($line, 0, 1) eq ".") {
@ -902,10 +915,12 @@ sub output_section_xml(%) {
print "<title>$section</title>\n"; print "<title>$section</title>\n";
if ($section =~ m/EXAMPLE/i) { if ($section =~ m/EXAMPLE/i) {
print "<informalexample><programlisting>\n"; print "<informalexample><programlisting>\n";
$output_preformatted = 1;
} else { } else {
print "<para>\n"; print "<para>\n";
} }
output_highlight($args{'sections'}{$section}); output_highlight($args{'sections'}{$section});
$output_preformatted = 0;
if ($section =~ m/EXAMPLE/i) { if ($section =~ m/EXAMPLE/i) {
print "</programlisting></informalexample>\n"; print "</programlisting></informalexample>\n";
} else { } else {
@ -1208,10 +1223,12 @@ sub output_blockhead_xml(%) {
} }
if ($section =~ m/EXAMPLE/i) { if ($section =~ m/EXAMPLE/i) {
print "<example><para>\n"; print "<example><para>\n";
$output_preformatted = 1;
} else { } else {
print "<para>\n"; print "<para>\n";
} }
output_highlight($args{'sections'}{$section}); output_highlight($args{'sections'}{$section});
$output_preformatted = 0;
if ($section =~ m/EXAMPLE/i) { if ($section =~ m/EXAMPLE/i) {
print "</para></example>\n"; print "</para></example>\n";
} else { } else {
@ -1287,10 +1304,12 @@ sub output_function_gnome {
print "<simplesect>\n <title>$section</title>\n"; print "<simplesect>\n <title>$section</title>\n";
if ($section =~ m/EXAMPLE/i) { if ($section =~ m/EXAMPLE/i) {
print "<example><programlisting>\n"; print "<example><programlisting>\n";
$output_preformatted = 1;
} else { } else {
} }
print "<para>\n"; print "<para>\n";
output_highlight($args{'sections'}{$section}); output_highlight($args{'sections'}{$section});
$output_preformatted = 0;
print "</para>\n"; print "</para>\n";
if ($section =~ m/EXAMPLE/i) { if ($section =~ m/EXAMPLE/i) {
print "</programlisting></example>\n"; print "</programlisting></example>\n";
@ -1734,7 +1753,7 @@ sub dump_struct($$) {
# strip kmemcheck_bitfield_{begin,end}.*; # strip kmemcheck_bitfield_{begin,end}.*;
$members =~ s/kmemcheck_bitfield_.*?;//gos; $members =~ s/kmemcheck_bitfield_.*?;//gos;
# strip attributes # strip attributes
$members =~ s/__aligned\s*\(\d+\)//gos; $members =~ s/__aligned\s*\(.+\)//gos;
create_parameterlist($members, ';', $file); create_parameterlist($members, ';', $file);
check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested); check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested);
@ -2025,6 +2044,28 @@ sub check_sections($$$$$$) {
} }
} }
##
# Checks the section describing the return value of a function.
sub check_return_section {
my $file = shift;
my $declaration_name = shift;
my $return_type = shift;
# Ignore an empty return type (It's a macro)
# Ignore functions with a "void" return type. (But don't ignore "void *")
if (($return_type eq "") || ($return_type =~ /void\s*\w*\s*$/)) {
return;
}
if (!defined($sections{$section_return}) ||
$sections{$section_return} eq "") {
print STDERR "Warning(${file}:$.): " .
"No description found for return value of " .
"'$declaration_name'\n";
++$warnings;
}
}
## ##
# takes a function prototype and the name of the current file being # takes a function prototype and the name of the current file being
# processed and spits out all the details stored in the global # processed and spits out all the details stored in the global
@ -2041,7 +2082,6 @@ sub dump_function($$) {
$prototype =~ s/^__inline +//; $prototype =~ s/^__inline +//;
$prototype =~ s/^__always_inline +//; $prototype =~ s/^__always_inline +//;
$prototype =~ s/^noinline +//; $prototype =~ s/^noinline +//;
$prototype =~ s/__devinit +//;
$prototype =~ s/__init +//; $prototype =~ s/__init +//;
$prototype =~ s/__init_or_module +//; $prototype =~ s/__init_or_module +//;
$prototype =~ s/__must_check +//; $prototype =~ s/__must_check +//;
@ -2088,14 +2128,22 @@ sub dump_function($$) {
create_parameterlist($args, ',', $file); create_parameterlist($args, ',', $file);
} else { } else {
print STDERR "Error(${file}:$.): cannot understand prototype: '$prototype'\n"; print STDERR "Warning(${file}:$.): cannot understand function prototype: '$prototype'\n";
++$errors;
return; return;
} }
my $prms = join " ", @parameterlist; my $prms = join " ", @parameterlist;
check_sections($file, $declaration_name, "function", $sectcheck, $prms, ""); check_sections($file, $declaration_name, "function", $sectcheck, $prms, "");
# This check emits a lot of warnings at the moment, because many
# functions don't have a 'Return' doc section. So until the number
# of warnings goes sufficiently down, the check is only performed in
# verbose mode.
# TODO: always perform the check.
if ($verbose) {
check_return_section($file, $declaration_name, $return_type);
}
output_declaration($declaration_name, output_declaration($declaration_name,
'function', 'function',
{'function' => $declaration_name, {'function' => $declaration_name,
@ -2305,6 +2353,9 @@ sub process_file($) {
$section_counter = 0; $section_counter = 0;
while (<IN>) { while (<IN>) {
while (s/\\\s*$//) {
$_ .= <IN>;
}
if ($state == 0) { if ($state == 0) {
if (/$doc_start/o) { if (/$doc_start/o) {
$state = 1; # next line is always the function name $state = 1; # next line is always the function name
@ -2332,7 +2383,7 @@ sub process_file($) {
$descr= $1; $descr= $1;
$descr =~ s/^\s*//; $descr =~ s/^\s*//;
$descr =~ s/\s*$//; $descr =~ s/\s*$//;
$descr =~ s/\s+/ /; $descr =~ s/\s+/ /g;
$declaration_purpose = xml_escape($descr); $declaration_purpose = xml_escape($descr);
$in_purpose = 1; $in_purpose = 1;
} else { } else {
@ -2424,9 +2475,7 @@ sub process_file($) {
# Continued declaration purpose # Continued declaration purpose
chomp($declaration_purpose); chomp($declaration_purpose);
$declaration_purpose .= " " . xml_escape($1); $declaration_purpose .= " " . xml_escape($1);
} elsif ($section =~ m/^Example/) { $declaration_purpose =~ s/\s+/ /g;
$_ =~ s/^\s*\*//;
$contents .= $_;
} else { } else {
$contents .= $1 . "\n"; $contents .= $1 . "\n";
} }
@ -2489,6 +2538,9 @@ sub process_file($) {
} }
if ($initial_section_counter == $section_counter) { if ($initial_section_counter == $section_counter) {
print STDERR "Warning(${file}): no structured comments found\n"; print STDERR "Warning(${file}): no structured comments found\n";
if (($function_only == 1) && ($show_not_found == 1)) {
print STDERR " Was looking for '$_'.\n" for keys %function_table;
}
if ($output_mode eq "xml") { if ($output_mode eq "xml") {
# The template wants at least one RefEntry here; make one. # The template wants at least one RefEntry here; make one.
print "<refentry>\n"; print "<refentry>\n";