aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kernel-doc
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kernel-doc')
-rwxr-xr-xscripts/kernel-doc77
1 files changed, 75 insertions, 2 deletions
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 0ac1a07874cc..3a4d895b9237 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -133,6 +133,30 @@ use strict;
133# 133#
134# All descriptions can be multiline, except the short function description. 134# All descriptions can be multiline, except the short function description.
135# 135#
136# For really longs structs, you can also describe arguments inside the
137# body of the struct.
138# eg.
139# /**
140# * struct my_struct - short description
141# * @a: first member
142# * @b: second member
143# *
144# * Longer description
145# */
146# struct my_struct {
147# int a;
148# int b;
149# /**
150# * @c: This is longer description of C
151# *
152# * You can use paragraphs to describe arguments
153# * using this method.
154# */
155# int c;
156# };
157#
158# This should be use only for struct/enum members.
159#
136# You can also add additional sections. When documenting kernel functions you 160# You can also add additional sections. When documenting kernel functions you
137# should document the "Context:" of the function, e.g. whether the functions 161# should document the "Context:" of the function, e.g. whether the functions
138# can be called form interrupts. Unlike other sections you can end it with an 162# can be called form interrupts. Unlike other sections you can end it with an
@@ -296,9 +320,19 @@ my $lineprefix="";
296# 2 - scanning field start. 320# 2 - scanning field start.
297# 3 - scanning prototype. 321# 3 - scanning prototype.
298# 4 - documentation block 322# 4 - documentation block
323# 5 - gathering documentation outside main block
299my $state; 324my $state;
300my $in_doc_sect; 325my $in_doc_sect;
301 326
327# Split Doc State
328# 0 - Invalid (Before start or after finish)
329# 1 - Is started (the /** was found inside a struct)
330# 2 - The @parameter header was found, start accepting multi paragraph text.
331# 3 - Finished (the */ was found)
332# 4 - Error - Comment without header was found. Spit a warning as it's not
333# proper kernel-doc and ignore the rest.
334my $split_doc_state;
335
302#declaration types: can be 336#declaration types: can be
303# 'function', 'struct', 'union', 'enum', 'typedef' 337# 'function', 'struct', 'union', 'enum', 'typedef'
304my $decl_type; 338my $decl_type;
@@ -313,6 +347,9 @@ my $doc_decl = $doc_com . '(\w+)';
313my $doc_sect = $doc_com . '([' . $doc_special . ']?[\w\s]+):(.*)'; 347my $doc_sect = $doc_com . '([' . $doc_special . ']?[\w\s]+):(.*)';
314my $doc_content = $doc_com_body . '(.*)'; 348my $doc_content = $doc_com_body . '(.*)';
315my $doc_block = $doc_com . 'DOC:\s*(.*)?'; 349my $doc_block = $doc_com . 'DOC:\s*(.*)?';
350my $doc_split_start = '^\s*/\*\*\s*$';
351my $doc_split_sect = '\s*\*\s*(@[\w\s]+):(.*)';
352my $doc_split_end = '^\s*\*/\s*$';
316 353
317my %constants; 354my %constants;
318my %parameterdescs; 355my %parameterdescs;
@@ -2190,6 +2227,7 @@ sub reset_state {
2190 $prototype = ""; 2227 $prototype = "";
2191 2228
2192 $state = 0; 2229 $state = 0;
2230 $split_doc_state = 0;
2193} 2231}
2194 2232
2195sub tracepoint_munge($) { 2233sub tracepoint_munge($) {
@@ -2462,7 +2500,6 @@ sub process_file($) {
2462 } 2500 }
2463 $section = $newsection; 2501 $section = $newsection;
2464 } elsif (/$doc_end/) { 2502 } elsif (/$doc_end/) {
2465
2466 if (($contents ne "") && ($contents ne "\n")) { 2503 if (($contents ne "") && ($contents ne "\n")) {
2467 dump_section($file, $section, xml_escape($contents)); 2504 dump_section($file, $section, xml_escape($contents));
2468 $section = $section_default; 2505 $section = $section_default;
@@ -2503,8 +2540,44 @@ sub process_file($) {
2503 print STDERR "Warning(${file}:$.): bad line: $_"; 2540 print STDERR "Warning(${file}:$.): bad line: $_";
2504 ++$warnings; 2541 ++$warnings;
2505 } 2542 }
2543 } elsif ($state == 5) { # scanning for split parameters
2544 # First line (state 1) needs to be a @parameter
2545 if ($split_doc_state == 1 && /$doc_split_sect/o) {
2546 $section = $1;
2547 $contents = $2;
2548 if ($contents ne "") {
2549 while ((substr($contents, 0, 1) eq " ") ||
2550 substr($contents, 0, 1) eq "\t") {
2551 $contents = substr($contents, 1);
2552 }
2553 $contents .= "\n";
2554 }
2555 $split_doc_state = 2;
2556 # Documentation block end */
2557 } elsif (/$doc_split_end/) {
2558 if (($contents ne "") && ($contents ne "\n")) {
2559 dump_section($file, $section, xml_escape($contents));
2560 $section = $section_default;
2561 $contents = "";
2562 }
2563 $state = 3;
2564 $split_doc_state = 0;
2565 # Regular text
2566 } elsif (/$doc_content/) {
2567 if ($split_doc_state == 2) {
2568 $contents .= $1 . "\n";
2569 } elsif ($split_doc_state == 1) {
2570 $split_doc_state = 4;
2571 print STDERR "Warning(${file}:$.): ";
2572 print STDERR "Incorrect use of kernel-doc format: $_";
2573 ++$warnings;
2574 }
2575 }
2506 } elsif ($state == 3) { # scanning for function '{' (end of prototype) 2576 } elsif ($state == 3) { # scanning for function '{' (end of prototype)
2507 if ($decl_type eq 'function') { 2577 if (/$doc_split_start/) {
2578 $state = 5;
2579 $split_doc_state = 1;
2580 } elsif ($decl_type eq 'function') {
2508 process_state3_function($_, $file); 2581 process_state3_function($_, $file);
2509 } else { 2582 } else {
2510 process_state3_type($_, $file); 2583 process_state3_type($_, $file);