X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=scripts%2Fkernel-doc;h=4d928b859845d02ba63cf128c7165bc4896b0fac;hb=f99c6bb6e2e9c35bd3dc0b1d0faa28bd6970930d;hp=c9ca0c23bd9100f3b583c4a87b7a3e096ce324dc;hpb=2a69bf428e49c229f8b735ba3de0a91ebd5d7f33;p=powerpc.git diff --git a/scripts/kernel-doc b/scripts/kernel-doc index c9ca0c23bd..4d928b8598 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -57,8 +57,8 @@ use strict; # other functions are ignored. # # -nofunction funcname -# If set, then only generate documentation for the other function(s). All -# other functions are ignored. Cannot be used with -function together +# If set, then only generate documentation for the other function(s). +# Cannot be used together with -function # (yes, that's a bug -- perl hackers can fix it 8)) # # c files - list of 'c' files to process @@ -83,7 +83,7 @@ use strict; # * my_function # **/ # -# If the Description: header tag is ommitted, then there must be a blank line +# If the Description: header tag is omitted, then there must be a blank line # after the last parameter specification. # e.g. # /** @@ -265,7 +265,7 @@ my $doc_start = '^/\*\*\s*$'; # Allow whitespace at end of comment start. my $doc_end = '\*/'; my $doc_com = '\s*\*\s*'; my $doc_decl = $doc_com.'(\w+)'; -my $doc_sect = $doc_com.'(['.$doc_special.']?[\w ]+):(.*)'; +my $doc_sect = $doc_com.'(['.$doc_special.']?[\w\s]+):(.*)'; my $doc_content = $doc_com.'(.*)'; my $doc_block = $doc_com.'DOC:\s*(.*)?'; @@ -365,7 +365,7 @@ sub dump_section { # parameterlist => @list of parameters # parameterdescs => %parameter descriptions # sectionlist => @list of sections -# sections => %descriont descriptions +# sections => %section descriptions # sub output_highlight { @@ -583,14 +583,14 @@ sub output_function_xml(%) { $id = "API-".$args{'function'}; $id =~ s/[^A-Za-z0-9]/-/g; - print "\n"; + print "\n"; print "\n"; print " LINUX\n"; print " Kernel Hackers Manual\n"; print " $man_date\n"; print "\n"; print "\n"; - print " ".$args{'function'}."\n"; + print " ".$args{'function'}."\n"; print " 9\n"; print "\n"; print "\n"; @@ -659,14 +659,14 @@ sub output_struct_xml(%) { $id = "API-struct-".$args{'struct'}; $id =~ s/[^A-Za-z0-9]/-/g; - print "\n"; + print "\n"; print "\n"; print " LINUX\n"; print " Kernel Hackers Manual\n"; print " $man_date\n"; print "\n"; print "\n"; - print " ".$args{'type'}." ".$args{'struct'}."\n"; + print " ".$args{'type'}." ".$args{'struct'}."\n"; print " 9\n"; print "\n"; print "\n"; @@ -743,14 +743,14 @@ sub output_enum_xml(%) { $id = "API-enum-".$args{'enum'}; $id =~ s/[^A-Za-z0-9]/-/g; - print "\n"; + print "\n"; print "\n"; print " LINUX\n"; print " Kernel Hackers Manual\n"; print " $man_date\n"; print "\n"; print "\n"; - print " enum ".$args{'enum'}."\n"; + print " enum ".$args{'enum'}."\n"; print " 9\n"; print "\n"; print "\n"; @@ -809,14 +809,14 @@ sub output_typedef_xml(%) { $id = "API-typedef-".$args{'typedef'}; $id =~ s/[^A-Za-z0-9]/-/g; - print "\n"; + print "\n"; print "\n"; print " LINUX\n"; print " Kernel Hackers Manual\n"; print " $man_date\n"; print "\n"; print "\n"; - print " typedef ".$args{'typedef'}."\n"; + print " typedef ".$args{'typedef'}."\n"; print " 9\n"; print "\n"; print "\n"; @@ -953,7 +953,11 @@ sub output_function_man(%) { print $args{'function'}." \\- ".$args{'purpose'}."\n"; print ".SH SYNOPSIS\n"; - print ".B \"".$args{'functiontype'}."\" ".$args{'function'}."\n"; + if ($args{'functiontype'} ne "") { + print ".B \"".$args{'functiontype'}."\" ".$args{'function'}."\n"; + } else { + print ".B \"".$args{'function'}."\n"; + } $count = 0; my $parenth = "("; my $post = ","; @@ -1118,13 +1122,19 @@ sub output_intro_man(%) { sub output_function_text(%) { my %args = %{$_[0]}; my ($parameter, $section); + my $start; print "Name:\n\n"; print $args{'function'}." - ".$args{'purpose'}."\n"; print "\nSynopsis:\n\n"; - my $start=$args{'functiontype'}." ".$args{'function'}." ("; + if ($args{'functiontype'} ne "") { + $start = $args{'functiontype'}." ".$args{'function'}." ("; + } else { + $start = $args{'function'}." ("; + } print $start; + my $count = 0; foreach my $parameter (@{$args{'parameterlist'}}) { $type = $args{'parametertypes'}{$parameter}; @@ -1262,7 +1272,9 @@ sub output_intro_text(%) { } ## -# generic output function for typedefs +# generic output function for all types (function, struct/union, typedef, enum); +# calls the generated, variable output_ function name based on +# functype and output_mode sub output_declaration { no strict 'refs'; my $name = shift; @@ -1278,8 +1290,7 @@ sub output_declaration { } ## -# generic output function - calls the right one based -# on current output mode. +# generic output function - calls the right one based on current output mode. sub output_intro { no strict 'refs'; my $func = "output_intro_".$output_mode; @@ -1429,10 +1440,10 @@ sub create_parameterlist($$$) { # corresponding data structures "correctly". Catch it later in # output_* subs. push_parameter($arg, "", $file); - } elsif ($arg =~ m/\(/) { + } elsif ($arg =~ m/\(.*\*/) { # pointer-to-function $arg =~ tr/#/,/; - $arg =~ m/[^\(]+\(\*([^\)]+)\)/; + $arg =~ m/[^\(]+\(\*\s*([^\)]+)\)/; $param = $1; $type = $arg; $type =~ s/([^\(]+\(\*)$param/$1/; @@ -1468,6 +1479,7 @@ sub push_parameter($$$) { my $param = shift; my $type = shift; my $file = shift; + my $anon = 0; my $param_name = $param; $param_name =~ s/\[.*//; @@ -1483,9 +1495,20 @@ sub push_parameter($$$) { $param="void"; $parameterdescs{void} = "no arguments"; } + elsif ($type eq "" && ($param eq "struct" or $param eq "union")) + # handle unnamed (anonymous) union or struct: + { + $type = $param; + $param = "{unnamed_" . $param. "}"; + $parameterdescs{$param} = "anonymous\n"; + $anon = 1; + } + # warn if parameter has no description - # (but ignore ones starting with # as these are no parameters - # but inline preprocessor statements + # (but ignore ones starting with # as these are not parameters + # but inline preprocessor statements); + # also ignore unnamed structs/unions; + if (!$anon) { if (!defined $parameterdescs{$param_name} && $param_name !~ /^#/) { $parameterdescs{$param_name} = $undescribed; @@ -1499,6 +1522,7 @@ sub push_parameter($$$) { " No description found for parameter '$param'\n"; ++$warnings; } + } push @parameterlist, $param; $parametertypes{$param} = $type; @@ -1518,8 +1542,11 @@ sub dump_function($$) { $prototype =~ s/^asmlinkage +//; $prototype =~ s/^inline +//; $prototype =~ s/^__inline__ +//; + $prototype =~ s/^__inline +//; + $prototype =~ s/^__always_inline +//; + $prototype =~ s/^noinline +//; $prototype =~ s/__devinit +//; - $prototype =~ s/^#define +//; #ak added + $prototype =~ s/^#define\s+//; #ak added $prototype =~ s/__attribute__ \(\([a-z,]*\)\)//; # Yes, this truly is vile. We are looking for: @@ -1553,7 +1580,8 @@ sub dump_function($$) { $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || - $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/) { + $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || + $prototype =~ m/^(\w+\s+\w+\s*\*\s*\w+\s*\*\s*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/) { $return_type = $1; $declaration_name = $2; my $args = $3; @@ -1693,6 +1721,7 @@ sub process_file($) { my $file; my $identifier; my $func; + my $descr; my $initial_section_counter = $section_counter; if (defined($ENV{'SRCTREE'})) { @@ -1736,7 +1765,12 @@ sub process_file($) { $state = 2; if (/-(.*)/) { - $declaration_purpose = xml_escape($1); + # strip leading/trailing/multiple spaces #RDD:T: + $descr= $1; + $descr =~ s/^\s*//; + $descr =~ s/\s*$//; + $descr =~ s/\s+/ /; + $declaration_purpose = xml_escape($descr); } else { $declaration_purpose = ""; } @@ -1778,8 +1812,9 @@ sub process_file($) { $in_doc_sect = 1; $contents = $newcontents; if ($contents ne "") { - if (substr($contents, 0, 1) eq " ") { - $contents = substr($contents, 1); + while ((substr($contents, 0, 1) eq " ") || + substr($contents, 0, 1) eq "\t") { + $contents = substr($contents, 1); } $contents .= "\n"; }