Skip to content

Commit f1e3b6b

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 9800625 commit f1e3b6b

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
@@ -232,6 +232,27 @@
232232
# Kept separate at end
233233
my $undocumented_scn = 'Undocumented elements';
234234

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

282303
footer => <<~EOT,
283304
284-
=head2 List of capability C<HAS_I<foo>> symbols
305+
=head2 $list_only{has_defs}{header}
285306
286307
This is a list of those symbols that dont appear elsewhere in this
287308
document that indicate if the current platform has a certain
@@ -300,11 +321,11 @@
300321
split so that the ones that indicate there is a reentrant version
301322
of a capability are listed separately
302323
303-
__HAS_LIST__
324+
$list_only{has_defs}{placement}
304325
305326
And, the reentrant capabilities:
306327
307-
__HAS_R_LIST__
328+
$list_only{has_r_defs}{placement}
308329
309330
Example usage:
310331
@@ -318,15 +339,15 @@
318339
319340
=back
320341
321-
=head2 List of C<#include> needed symbols
342+
=head2 $list_only{include_defs}{header}
322343
323344
This list contains symbols that indicate if certain C<#include>
324345
files are present on the platform. If your code accesses the
325346
functionality that one of these is for, you will need to
326347
C<#include> it if the symbol on this list is C<#define>d. For
327348
more detail, see the corresponding entry in F<$config_h>.
328349
329-
__INCLUDE_LIST__
350+
$list_only{include_defs}{placement}
330351
331352
Example usage:
332353
@@ -1069,9 +1090,6 @@ ($fh, $file)
10691090
}
10701091

10711092
my %configs;
1072-
my @has_defs;
1073-
my @has_r_defs; # Reentrant symbols
1074-
my @include_defs;
10751093

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

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

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

0 commit comments

Comments
 (0)