Improve handling of module index, to deal with platform annotations a little

better.
This commit is contained in:
Fred Drake 1999-03-02 16:00:37 +00:00
parent 01bc01c82e
commit 2383f6dbbc
1 changed files with 43 additions and 7 deletions

View File

@ -39,7 +39,7 @@ $VERBOSITY = 0;
# default # of columns for the indexes # default # of columns for the indexes
$INDEX_COLUMNS = 2; $INDEX_COLUMNS = 2;
$MODULE_INDEX_COLUMNS = 5; $MODULE_INDEX_COLUMNS = 4;
# A little painful, but lets us clean up the top level directory a little, # A little painful, but lets us clean up the top level directory a little,
@ -247,7 +247,7 @@ sub make_index_entry {
sub insert_index{ sub insert_index{
my($mark,$datafile,$columns,$letters) = @_; my($mark,$datafile,$columns,$letters,$prefix) = @_;
my $prog = "$myrootdir/tools/buildindex.py"; my $prog = "$myrootdir/tools/buildindex.py";
my $index; my $index;
if ($letters) { if ($letters) {
@ -256,13 +256,13 @@ sub insert_index{
else { else {
$index = `$prog --columns $columns $datafile`; $index = `$prog --columns $columns $datafile`;
} }
s/$mark/$index/; s/$mark/$prefix$index/;
} }
sub add_idx{ sub add_idx{
print "\nBuilding HTML for the index ..."; print "\nBuilding HTML for the index ...";
close(IDXFILE); close(IDXFILE);
insert_index($idx_mark, 'index.dat', $INDEX_COLUMNS, 1); insert_index($idx_mark, 'index.dat', $INDEX_COLUMNS, 1, '');
} }
@ -272,20 +272,56 @@ $idx_module_title = 'Module Index';
sub add_module_idx{ sub add_module_idx{
print "\nBuilding HTML for the module index ..."; print "\nBuilding HTML for the module index ...";
my $key; my $key;
my $first = 1;
my $prevplat = '';
my $allthesame = 1;
my $prefix = '';
foreach $key (keys %Modules) {
$key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/\1/;
my $plat = "$ModulePlatforms{$key}";
$plat = ''
if $IGNORE_PLATFORM_ANNOTATION;
if (!$first) {
$allthesame = 0
if ($prevplat ne $plat);
}
else { $first = 0; }
$prevplat = $plat;
}
open(MODIDXFILE, '>modindex.dat') || die "\n$!\n"; open(MODIDXFILE, '>modindex.dat') || die "\n$!\n";
foreach $key (keys %Modules) { foreach $key (keys %Modules) {
# dump the line in the data file; just use a dummy seqno field # dump the line in the data file; just use a dummy seqno field
print MODIDXFILE "$Modules{$key}" . $IDXFILE_FIELD_SEP . "$key###\n"; my $nkey = $1;
my $moditem = "$Modules{$key}";
my $plat = '';
$key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/\1/;
if ($ModulePlatforms{$key} && !$allthesame) {
$plat = " <em>($ModulePlatforms{$key})</em>";
}
print MODIDXFILE
$moditem
. $IDXFILE_FIELD_SEP
. "<tt class=module>$key</tt>$plat###\n";
} }
close(MODIDXFILE); close(MODIDXFILE);
insert_index($idx_module_mark, 'modindex.dat', $MODULE_INDEX_COLUMNS, 0); if (!$allthesame) {
$prefix = <<PLAT_DISCUSS;
<p> Some module names are followed by an annotation indicating what
platform they are available on.</p>
PLAT_DISCUSS
}
insert_index($idx_module_mark, 'modindex.dat', $MODULE_INDEX_COLUMNS, 0,
$prefix);
} }
# replace both indexes as needed: # replace both indexes as needed:
sub add_idx_hook{ sub add_idx_hook{
add_idx() if (/$idx_mark/); add_idx() if (/$idx_mark/);
add_module_idx() if (/$idx_module_mark/); add_module_idx() if (/$idx_module_mark/);
process_all_localmoduletables(); process_python_state();
} }