History

scripts: kernel-doc: reimplement -nofunction argument

Right now, the build system doesn't use -nofunction, as it is pretty much useless, because it doesn't consider the other output modes (extern, internal), working only with all. Also, it is limited to exclude functions. Re-implement it in order to allow excluding any symbols from the document output, no matter what mode is used. The parameter was also renamed to "-nosymbol", as it express better its meaning.

Mauro Carvalho Chehab committed 6 years ago

Commit eab795d1 parent dbe8ba01 file · +21 −23Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/kernel-doc+21−23
@@ -66,9 +66,8 @@ Output selection (mutually exclusive): · 65 unmodified lines
66 -function NAME Only output documentation for the given function(s)66 -function NAME Only output documentation for the given function(s)
67 or DOC: section title(s). All other functions and DOC:67 or DOC: section title(s). All other functions and DOC:
68 sections are ignored. May be specified multiple times.68 sections are ignored. May be specified multiple times.
69 -nofunction NAME Do NOT output documentation for the given function(s);69 -nosymbol NAME Exclude the specified symbols from the output
70 only output documentation for the other functions and70 documentation. May be specified multiple times.
71 DOC: sections. May be specified multiple times.
72 71
73Output selection modifiers:72Output selection modifiers:
74 -no-doc-sections Do not output DOC: sections.73 -no-doc-sections Do not output DOC: sections.
@@ -288,9 +287,8 @@ my $modulename = "Kernel API"; · 213 unmodified lines
288use constant {287use constant {
289 OUTPUT_ALL => 0, # output all symbols and doc sections288 OUTPUT_ALL => 0, # output all symbols and doc sections
290 OUTPUT_INCLUDE => 1, # output only specified symbols289 OUTPUT_INCLUDE => 1, # output only specified symbols
291 OUTPUT_EXCLUDE => 2, # output everything except specified symbols290 OUTPUT_EXPORTED => 2, # output exported symbols
292 OUTPUT_EXPORTED => 3, # output exported symbols291 OUTPUT_INTERNAL => 3, # output non-exported symbols
293 OUTPUT_INTERNAL => 4, # output non-exported symbols
294};292};
295my $output_selection = OUTPUT_ALL;293my $output_selection = OUTPUT_ALL;
296my $show_not_found = 0; # No longer used294my $show_not_found = 0; # No longer used
@@ -315,6 +313,7 @@ my $man_date = ('January', 'February', 'March', 'April', 'May', 'June', · 18 unmodified lines
315# CAVEAT EMPTOR! Some of the others I localised may not want to be, which313# CAVEAT EMPTOR! Some of the others I localised may not want to be, which
316# could cause "use of undefined value" or other bugs.314# could cause "use of undefined value" or other bugs.
317my ($function, %function_table, %parametertypes, $declaration_purpose);315my ($function, %function_table, %parametertypes, $declaration_purpose);
316my %nosymbol_table = ();
318my $declaration_start_line;317my $declaration_start_line;
319my ($type, $declaration_name, $return_type);318my ($type, $declaration_name, $return_type);
320my ($newsection, $newcontents, $prototype, $brcount, %source_map);319my ($newsection, $newcontents, $prototype, $brcount, %source_map);
@@ -434,10 +433,9 @@ while ($ARGV[0] =~ m/^--?(.*)/) { · 113 unmodified lines
434 $output_selection = OUTPUT_INCLUDE;433 $output_selection = OUTPUT_INCLUDE;
435 $function = shift @ARGV;434 $function = shift @ARGV;
436 $function_table{$function} = 1;435 $function_table{$function} = 1;
437 } elsif ($cmd eq "nofunction") { # output all except specific functions436 } elsif ($cmd eq "nosymbol") { # Exclude specific symbols
438 $output_selection = OUTPUT_EXCLUDE;437 my $symbol = shift @ARGV;
439 $function = shift @ARGV;438 $nosymbol_table{$symbol} = 1;
440 $function_table{$function} = 1;
441 } elsif ($cmd eq "export") { # only exported symbols439 } elsif ($cmd eq "export") { # only exported symbols
442 $output_selection = OUTPUT_EXPORTED;440 $output_selection = OUTPUT_EXPORTED;
443 %function_table = ();441 %function_table = ();
@@ -570,11 +568,11 @@ sub dump_doc_section { · 126 unmodified lines
570 return;568 return;
571 }569 }
572 570
571 return if (defined($nosymbol_table{$name}));
572
573 if (($output_selection == OUTPUT_ALL) ||573 if (($output_selection == OUTPUT_ALL) ||
574 ($output_selection == OUTPUT_INCLUDE &&574 (($output_selection == OUTPUT_INCLUDE) &&
575 defined($function_table{$name})) ||575 defined($function_table{$name})))
576 ($output_selection == OUTPUT_EXCLUDE &&
577 !defined($function_table{$name})))
578 {576 {
579 dump_section($file, $name, $contents);577 dump_section($file, $name, $contents);
580 output_blockhead({'sectionlist' => \@sectionlist,578 output_blockhead({'sectionlist' => \@sectionlist,
@@ -800,6 +798,8 @@ sub output_blockhead_rst(%) { · 219 unmodified lines
800 my ($parameter, $section);798 my ($parameter, $section);
801 799
802 foreach $section (@{$args{'sectionlist'}}) {800 foreach $section (@{$args{'sectionlist'}}) {
801 next if (defined($nosymbol_table{$section}));
802
803 if ($output_selection != OUTPUT_INCLUDE) {803 if ($output_selection != OUTPUT_INCLUDE) {
804 print "**$section**\n\n";804 print "**$section**\n\n";
805 }805 }
@@ -1115,12 +1115,14 @@ sub output_declaration { · 309 unmodified lines
1115 my $name = shift;1115 my $name = shift;
1116 my $functype = shift;1116 my $functype = shift;
1117 my $func = "output_${functype}_$output_mode";1117 my $func = "output_${functype}_$output_mode";
1118
1119 return if (defined($nosymbol_table{$name}));
1120
1118 if (($output_selection == OUTPUT_ALL) ||1121 if (($output_selection == OUTPUT_ALL) ||
1119 (($output_selection == OUTPUT_INCLUDE ||1122 (($output_selection == OUTPUT_INCLUDE ||
1120 $output_selection == OUTPUT_EXPORTED) &&1123 $output_selection == OUTPUT_EXPORTED) &&
1121 defined($function_table{$name})) ||1124 defined($function_table{$name})) ||
1122 (($output_selection == OUTPUT_EXCLUDE ||1125 ($output_selection == OUTPUT_INTERNAL &&
1123 $output_selection == OUTPUT_INTERNAL) &&
1124 !($functype eq "function" && defined($function_table{$name}))))1126 !($functype eq "function" && defined($function_table{$name}))))
1125 {1127 {
1126 &$func(@_);1128 &$func(@_);
@@ -1301,6 +1303,8 @@ sub show_warnings($$) { · 174 unmodified lines
1301 my $functype = shift;1303 my $functype = shift;
1302 my $name = shift;1304 my $name = shift;
1303 1305
1306 return 0 if (defined($nosymbol_table{$name}));
1307
1304 return 1 if ($output_selection == OUTPUT_ALL);1308 return 1 if ($output_selection == OUTPUT_ALL);
1305 1309
1306 if ($output_selection == OUTPUT_EXPORTED) {1310 if ($output_selection == OUTPUT_EXPORTED) {
@@ -1324,13 +1328,6 @@ sub show_warnings($$) { · 17 unmodified lines
1324 return 0;1328 return 0;
1325 }1329 }
1326 }1330 }
1327 if ($output_selection == OUTPUT_EXCLUDE) {
1328 if (!defined($function_table{$name})) {
1329 return 1;
1330 } else {
1331 return 0;
1332 }
1333 }
1334 die("Please add the new output type at show_warnings()");1331 die("Please add the new output type at show_warnings()");
1335}1332}
1336 1333
@@ -1952,6 +1949,7 @@ sub process_export_file($) { · 615 unmodified lines
1952 1949
1953 while (<IN>) {1950 while (<IN>) {
1954 if (/$export_symbol/) {1951 if (/$export_symbol/) {
1952 next if (defined($nosymbol_table{$2}));
1955 $function_table{$2} = 1;1953 $function_table{$2} = 1;
1956 }1954 }
1957 }1955 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t