Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2383f6d

Browse files
committed
Improve handling of module index, to deal with platform annotations a little
better.
1 parent 01bc01c commit 2383f6d

1 file changed

Lines changed: 43 additions & 7 deletions

File tree

Doc/perl/l2hinit.perl

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ package main;
3939

4040
# default # of columns for the indexes
4141
$INDEX_COLUMNS = 2;
42-
$MODULE_INDEX_COLUMNS = 5;
42+
$MODULE_INDEX_COLUMNS = 4;
4343

4444

4545
# A little painful, but lets us clean up the top level directory a little,
@@ -247,7 +247,7 @@ sub make_index_entry {
247247

248248

249249
sub insert_index{
250-
my($mark,$datafile,$columns,$letters) = @_;
250+
my($mark,$datafile,$columns,$letters,$prefix) = @_;
251251
my $prog = "$myrootdir/tools/buildindex.py";
252252
my $index;
253253
if ($letters) {
@@ -256,13 +256,13 @@ sub insert_index{
256256
else {
257257
$index = `$prog --columns $columns $datafile`;
258258
}
259-
s/$mark/$index/;
259+
s/$mark/$prefix$index/;
260260
}
261261

262262
sub add_idx{
263263
print "\nBuilding HTML for the index ...";
264264
close(IDXFILE);
265-
insert_index($idx_mark, 'index.dat', $INDEX_COLUMNS, 1);
265+
insert_index($idx_mark, 'index.dat', $INDEX_COLUMNS, 1, '');
266266
}
267267

268268

@@ -272,20 +272,56 @@ sub add_idx{
272272
sub add_module_idx{
273273
print "\nBuilding HTML for the module index ...";
274274
my $key;
275+
my $first = 1;
276+
my $prevplat = '';
277+
my $allthesame = 1;
278+
my $prefix = '';
279+
foreach $key (keys %Modules) {
280+
$key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/\1/;
281+
my $plat = "$ModulePlatforms{$key}";
282+
$plat = ''
283+
if $IGNORE_PLATFORM_ANNOTATION;
284+
if (!$first) {
285+
$allthesame = 0
286+
if ($prevplat ne $plat);
287+
}
288+
else { $first = 0; }
289+
$prevplat = $plat;
290+
}
275291
open(MODIDXFILE, '>modindex.dat') || die "\n$!\n";
276292
foreach $key (keys %Modules) {
277293
# dump the line in the data file; just use a dummy seqno field
278-
print MODIDXFILE "$Modules{$key}" . $IDXFILE_FIELD_SEP . "$key###\n";
294+
my $nkey = $1;
295+
my $moditem = "$Modules{$key}";
296+
my $plat = '';
297+
$key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/\1/;
298+
if ($ModulePlatforms{$key} && !$allthesame) {
299+
$plat = " <em>($ModulePlatforms{$key})</em>";
300+
}
301+
print MODIDXFILE
302+
$moditem
303+
. $IDXFILE_FIELD_SEP
304+
. "<tt class=module>$key</tt>$plat###\n";
279305
}
280306
close(MODIDXFILE);
281-
insert_index($idx_module_mark, 'modindex.dat', $MODULE_INDEX_COLUMNS, 0);
307+
if (!$allthesame) {
308+
$prefix = <<PLAT_DISCUSS;
309+
310+
311+
<p> Some module names are followed by an annotation indicating what
312+
platform they are available on.</p>
313+
314+
PLAT_DISCUSS
315+
}
316+
insert_index($idx_module_mark, 'modindex.dat', $MODULE_INDEX_COLUMNS, 0,
317+
$prefix);
282318
}
283319

284320
# replace both indexes as needed:
285321
sub add_idx_hook{
286322
add_idx() if (/$idx_mark/);
287323
add_module_idx() if (/$idx_module_mark/);
288-
process_all_localmoduletables();
324+
process_python_state();
289325
}
290326

291327

0 commit comments

Comments
 (0)