Skip to content

Commit eab795d

Browse files
committed
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. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
1 parent dbe8ba0 commit eab795d

1 file changed

Lines changed: 21 additions & 23 deletions

File tree

‎scripts/kernel-doc‎

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ Output selection (mutually exclusive):
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";
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',
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/^--?(.*)/) {
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 {
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(%) {
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 {
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($$) {
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($$) {
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($) {
19521949

19531950
while (<IN>) {
19541951
if (/$export_symbol/) {
1952+
next if (defined($nosymbol_table{$2}));
19551953
$function_table{$2} = 1;
19561954
}
19571955
}

0 commit comments

Comments
 (0)