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
6666 -function NAME Only output documentation for the given function(s)
6767 or DOC: section title(s). All other functions and DOC:
6868 sections are ignored. May be specified multiple times.
69− -nofunction NAME Do NOT output documentation for the given function(s);
70− only output documentation for the other functions and
71− DOC: sections. May be specified multiple times.
69+ -nosymbol NAME Exclude the specified symbols from the output
70+ documentation. May be specified multiple times.
7271
7372 Output selection modifiers:
7473 -no-doc-sections Do not output DOC: sections.
@@ -288,9 +287,8 @@ my $modulename = "Kernel API"; · 213 unmodified lines
288287 use constant {
289288 OUTPUT_ALL => 0, # output all symbols and doc sections
290289 OUTPUT_INCLUDE => 1, # output only specified symbols
291− OUTPUT_EXCLUDE => 2, # output everything except specified symbols
292− OUTPUT_EXPORTED => 3, # output exported symbols
293− OUTPUT_INTERNAL => 4, # output non-exported symbols
290+ OUTPUT_EXPORTED => 2, # output exported symbols
291+ OUTPUT_INTERNAL => 3, # output non-exported symbols
294292 };
295293 my $output_selection = OUTPUT_ALL;
296294 my $show_not_found = 0; # No longer used
@@ -315,6 +313,7 @@ my $man_date = ('January', 'February', 'March', 'April', 'May', 'June', · 18 unmodified lines
315313 # CAVEAT EMPTOR! Some of the others I localised may not want to be, which
316314 # could cause "use of undefined value" or other bugs.
317315 my ($function, %function_table, %parametertypes, $declaration_purpose);
316+my %nosymbol_table = ();
318317 my $declaration_start_line;
319318 my ($type, $declaration_name, $return_type);
320319 my ($newsection, $newcontents, $prototype, $brcount, %source_map);
@@ -434,10 +433,9 @@ while ($ARGV[0] =~ m/^--?(.*)/) { · 113 unmodified lines
434433 $output_selection = OUTPUT_INCLUDE;
435434 $function = shift @ARGV;
436435 $function_table{$function} = 1;
437− } elsif ($cmd eq "nofunction") { # output all except specific functions
438− $output_selection = OUTPUT_EXCLUDE;
439− $function = shift @ARGV;
440− $function_table{$function} = 1;
436+ } elsif ($cmd eq "nosymbol") { # Exclude specific symbols
437+ my $symbol = shift @ARGV;
438+ $nosymbol_table{$symbol} = 1;
441439 } elsif ($cmd eq "export") { # only exported symbols
442440 $output_selection = OUTPUT_EXPORTED;
443441 %function_table = ();
@@ -570,11 +568,11 @@ sub dump_doc_section { · 126 unmodified lines
570568 return;
571569 }
572570
571+ return if (defined($nosymbol_table{$name}));
572+
573573 if (($output_selection == OUTPUT_ALL) ||
574− ($output_selection == OUTPUT_INCLUDE &&
575− defined($function_table{$name})) ||
576− ($output_selection == OUTPUT_EXCLUDE &&
577− !defined($function_table{$name})))
574+ (($output_selection == OUTPUT_INCLUDE) &&
575+ defined($function_table{$name})))
578576 {
579577 dump_section($file, $name, $contents);
580578 output_blockhead({'sectionlist' => \@sectionlist,
@@ -800,6 +798,8 @@ sub output_blockhead_rst(%) { · 219 unmodified lines
800798 my ($parameter, $section);
801799
802800 foreach $section (@{$args{'sectionlist'}}) {
801+ next if (defined($nosymbol_table{$section}));
802+
803803 if ($output_selection != OUTPUT_INCLUDE) {
804804 print "**$section**\n\n";
805805 }
@@ -1115,12 +1115,14 @@ sub output_declaration { · 309 unmodified lines
11151115 my $name = shift;
11161116 my $functype = shift;
11171117 my $func = "output_${functype}_$output_mode";
1118+
1119+ return if (defined($nosymbol_table{$name}));
1120+
11181121 if (($output_selection == OUTPUT_ALL) ||
11191122 (($output_selection == OUTPUT_INCLUDE ||
11201123 $output_selection == OUTPUT_EXPORTED) &&
11211124 defined($function_table{$name})) ||
1122− (($output_selection == OUTPUT_EXCLUDE ||
1123− $output_selection == OUTPUT_INTERNAL) &&
1125+ ($output_selection == OUTPUT_INTERNAL &&
11241126 !($functype eq "function" && defined($function_table{$name}))))
11251127 {
11261128 &$func(@_);
@@ -1301,6 +1303,8 @@ sub show_warnings($$) { · 174 unmodified lines
13011303 my $functype = shift;
13021304 my $name = shift;
13031305
1306+ return 0 if (defined($nosymbol_table{$name}));
1307+
13041308 return 1 if ($output_selection == OUTPUT_ALL);
13051309
13061310 if ($output_selection == OUTPUT_EXPORTED) {
@@ -1324,13 +1328,6 @@ sub show_warnings($$) { · 17 unmodified lines
13241328 return 0;
13251329 }
13261330 }
1327− if ($output_selection == OUTPUT_EXCLUDE) {
1328− if (!defined($function_table{$name})) {
1329− return 1;
1330− } else {
1331− return 0;
1332− }
1333− }
13341331 die("Please add the new output type at show_warnings()");
13351332 }
13361333
@@ -1952,6 +1949,7 @@ sub process_export_file($) { · 615 unmodified lines
19521949
19531950 while (<IN>) {
19541951 if (/$export_symbol/) {
1952+ next if (defined($nosymbol_table{$2}));
19551953 $function_table{$2} = 1;
19561954 }
19571955 }

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