Skip to content

Commit 6532840

Browse files
committed
autodoc: Use $variable instead of literal strings
Consolidate these slightly different strings into one. This makes the maze of twisty little passages all the same.
1 parent 2d764b4 commit 6532840

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

autodoc.pl

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
#
77
# pod/perlintern.pod
88
# pod/perlapi.pod
9+
10+
my $api = "pod/perlapi.pod";
11+
my $intern = "pod/perlintern.pod";
912
#
1013
# from information stored in
1114
#
@@ -805,8 +808,8 @@ ($)
805808
# are $1
806809
my $flags = shift;
807810
return "unknown" if $flags eq "";
808-
return "api" if $flags =~ /A/;
809-
return "intern";
811+
return $api if $flags =~ /A/;
812+
return $intern;
810813
}
811814

812815
sub autodoc ($$) { # parse a file and extract documentation info
@@ -1344,20 +1347,20 @@ sub parse_config_h {
13441347
# Check if any section already has an entry for this element.
13451348
# If so, it better be a placeholder, in which case we replace it
13461349
# with this entry.
1347-
foreach my $section (keys $docs{'api'}->%*) {
1348-
if (exists $docs{'api'}{$section}{$name}) {
1349-
my $was = $docs{'api'}{$section}{$name}->{pod};
1350+
foreach my $section (keys $docs{$api}->%*) {
1351+
if (exists $docs{$api}{$section}{$name}) {
1352+
my $was = $docs{$api}{$section}{$name}->{pod};
13501353
$was = "" unless $was;
13511354
chomp $was;
13521355
if ($was ne "" && $was !~ m/$described_in/) {
13531356
die "Multiple descriptions for $name\n"
13541357
. "The '$section' section contained\n'$was'";
13551358
}
1356-
$docs{'api'}{$section}{$name}->{pod} = $configs{$name}{pod};
1359+
$docs{$api}{$section}{$name}->{pod} = $configs{$name}{pod};
13571360
$configs{$name}{section} = $section;
13581361
last;
13591362
}
1360-
elsif (exists $docs{'intern'}{$section}{$name}) {
1363+
elsif (exists $docs{$intern}{$section}{$name}) {
13611364
die "'$name' is in '$config_h' meaning it is part of the API,\n"
13621365
. " but it is also in 'perlintern', meaning it isn't API\n";
13631366
}
@@ -1571,9 +1574,9 @@ sub parse_config_h {
15711574
);
15721575

15731576
# All the information has been gathered; save it
1574-
push $docs{'api'}{$section}{$name}{items}->@*, $data;
1575-
$docs{'api'}{$section}{$name}{pod} = $configs{$name}{pod};
1576-
$docs{'api'}{$section}{$name}{usage}
1577+
push $docs{$api}{$section}{$name}{items}->@*, $data;
1578+
$docs{$api}{$section}{$name}{pod} = $configs{$name}{pod};
1579+
$docs{$api}{$section}{$name}{usage}
15771580
= $configs{$name}{usage} if defined $configs{$name}{usage};
15781581
}
15791582
}
@@ -2249,7 +2252,7 @@ ($)
22492252
# pod checkers.
22502253
s/^\|//gm for $destpod->{hdr}, $destpod->{footer};
22512254

2252-
my $fh = open_new("pod/$podname.pod", undef,
2255+
my $fh = open_new($podname, undef,
22532256
{by => "$0 extracting documentation",
22542257
from => 'the C source files'}, 1);
22552258

@@ -2259,7 +2262,7 @@ ($)
22592262
my $section_info = $dochash->{$section_name};
22602263

22612264
# We allow empty sections in perlintern.
2262-
if (! $section_info && $podname eq 'perlapi') {
2265+
if (! $section_info && $podname eq $api) {
22632266
warn "Empty section '$section_name' for $podname; skipped";
22642267
next;
22652268
}
@@ -2272,7 +2275,7 @@ ($)
22722275
delete $section_info->{X_tags};
22732276
}
22742277

2275-
if ($podname eq 'perlapi') {
2278+
if ($podname eq $api) {
22762279
print $fh "\n", $valid_sections{$section_name}{header}, "\n"
22772280
if defined $valid_sections{$section_name}{header};
22782281

@@ -2311,13 +2314,13 @@ ($)
23112314
}
23122315
}
23132316
else {
2314-
my $pod_type = ($podname eq 'api') ? "public" : "internal";
2317+
my $pod_type = ($podname eq $api) ? "public" : "internal";
23152318
print $fh "\nThere are currently no $pod_type API items in ",
23162319
$section_name, "\n";
23172320
}
23182321

23192322
print $fh "\n", $valid_sections{$section_name}{footer}, "\n"
2320-
if $podname eq 'perlapi'
2323+
if $podname eq $api
23212324
&& defined $valid_sections{$section_name}{footer};
23222325
}
23232326

@@ -2534,8 +2537,8 @@ ($)
25342537

25352538
# Here %docs is populated; and we're ready to output
25362539

2537-
my %api = ( podname => 'perlapi', docs => $docs{'api'} );
2538-
my %intern = ( podname => 'perlintern', docs => $docs{'intern'} );
2540+
my %api = ( podname => $api, docs => $docs{$api} );
2541+
my %intern = ( podname => $intern, docs => $docs{$intern} );
25392542

25402543
# But first, look for inconsistencies and populate the lists of elements whose
25412544
# documentation is missing

0 commit comments

Comments
 (0)