Skip to content

Commit b539310

Browse files
committed
autodoc.pl: Generalize some list creation
This changes to use a loop to populate three lists. This makes it more general and easier to potentially add things later.
1 parent a53664e commit b539310

File tree

1 file changed

+38
-20
lines changed

1 file changed

+38
-20
lines changed

autodoc.pl

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,27 @@
233233
# Kept separate at end
234234
my $undocumented_scn = 'Undocumented elements';
235235

236+
my @has_defs;
237+
my @has_r_defs; # Reentrant symbols
238+
my @include_defs;
239+
my %list_only = (
240+
has_defs => {
241+
list => \@has_defs,
242+
header => "List of capability C<HAS_I<foo>> symbols",
243+
placement => '__HAS_LIST__',
244+
},
245+
has_r_defs => {
246+
list => \@has_r_defs,
247+
header => "List of capability C<HAS_I<foo>> symbols",
248+
placement => '__HAS_R_LIST__',
249+
},
250+
include_defs => {
251+
list => \@include_defs,
252+
header => "List of C<#include> needed symbols",
253+
placement => '__INCLUDE_LIST__',
254+
},
255+
);
256+
236257
my %valid_sections = (
237258
$AV_scn => {},
238259
$callback_scn => {},
@@ -282,7 +303,7 @@
282303

283304
footer => <<~EOT,
284305
285-
=head2 List of capability C<HAS_I<foo>> symbols
306+
=head2 $list_only{has_defs}{header}
286307
287308
This is a list of those symbols that dont appear elsewhere in this
288309
document that indicate if the current platform has a certain
@@ -301,11 +322,11 @@
301322
split so that the ones that indicate there is a reentrant version
302323
of a capability are listed separately
303324
304-
__HAS_LIST__
325+
$list_only{has_defs}{placement}
305326
306327
And, the reentrant capabilities:
307328
308-
__HAS_R_LIST__
329+
$list_only{has_r_defs}{placement}
309330
310331
Example usage:
311332
@@ -319,15 +340,15 @@
319340
320341
=back
321342
322-
=head2 List of C<#include> needed symbols
343+
=head2 $list_only{include_defs}{header}
323344
324345
This list contains symbols that indicate if certain C<#include>
325346
files are present on the platform. If your code accesses the
326347
functionality that one of these is for, you will need to
327348
C<#include> it if the symbol on this list is C<#define>d. For
328349
more detail, see the corresponding entry in F<$config_h>.
329350
330-
__INCLUDE_LIST__
351+
$list_only{include_defs}{placement}
331352
332353
Example usage:
333354
@@ -1070,9 +1091,6 @@ ($fh, $file)
10701091
}
10711092

10721093
my %configs;
1073-
my @has_defs;
1074-
my @has_r_defs; # Reentrant symbols
1075-
my @include_defs;
10761094

10771095
sub parse_config_h {
10781096
use re '/aa'; # Everything is ASCII in this file
@@ -2742,18 +2760,18 @@ ($destpod)
27422760
my $places_other_than_api = join ", ",
27432761
map { "L<$_>" } sort dictionary_order 'perlintern', @other_places;
27442762

2745-
# The S< > makes things less densely packed, hence more readable
2746-
my $has_defs_text .= join ",S< > ", map { "C<$_>" }
2747-
sort dictionary_order @has_defs;
2748-
my $has_r_defs_text .= join ",S< > ", map { "C<$_>" }
2749-
sort dictionary_order @has_r_defs;
2750-
$valid_sections{$genconfig_scn}{footer} =~ s/__HAS_LIST__/$has_defs_text/;
2751-
$valid_sections{$genconfig_scn}{footer} =~ s/__HAS_R_LIST__/$has_r_defs_text/;
2752-
2753-
my $include_defs_text .= join ",S< > ", map { "C<$_>" }
2754-
sort dictionary_order @include_defs;
2755-
$valid_sections{$genconfig_scn}{footer}
2756-
=~ s/__INCLUDE_LIST__/$include_defs_text/;
2763+
2764+
foreach my $name (keys %list_only) {
2765+
my @this_list = $list_only{$name}{list}->@*;
2766+
my $text = "";
2767+
foreach my $entry (sort dictionary_order @this_list) {
2768+
$text .= ",S< > " if $text; # The S< > makes things less densely
2769+
# packed, hence more readable
2770+
$text .= "C<$entry>";
2771+
}
2772+
$valid_sections{$genconfig_scn}{footer}
2773+
=~ s/$list_only{$name}{placement}/$text/;
2774+
}
27572775

27582776
my $section_list = join "\n\n", map { "=item L</$_>" }
27592777
sort(dictionary_order keys %valid_sections),

0 commit comments

Comments
 (0)