#!/opt/local/bin/perl
use File::Find;
use strict;
#########################################
# Usage:
# $ cd $ERLANG_RELEASE
# otp_man_index > doc/man_index.html
#########################################
my (@list,$info);
find(\&wanted,'.');
header();
foreach $info (sort {lc($a->[0]) cmp lc($b->[0])} @list) {
my ($module,$application,$dir,$path) = @$info;
my $idx = -f "$dir/index.html" ? "$dir/index.html" : "$dir/../index.html";
# Remove .html extension from module name, if there is one
if ($module =~ /(\w+).html$/) {
$module = "$1";
}
print "
\n";
print " $module | \n";
print " $application | \n";
print "
\n";
}
footer();
###########################################################################
sub wanted {
return unless /\.html$/ and -f $_;
open(FILE,$_) or die "ERROR: Can't open $File::Find::name: $!\n";
my $line;
while (defined ($line = )) {
if ($line =~ //) {
close FILE;
my $path = $File::Find::name;
$path =~ s/\.\///; # Remove './' prefix
my $dir = $File::Find::dir;
$dir =~ s/\.\///; # Remove './' prefix
$dir =~ m&([^/]+)/doc/html$&;
my $application = $1;
push(@list, [$_,$application,$dir,$path]);
return;
}
}
close FILE;
}
sub header {
print <
Erlang/OTP Manual Page Index
[Up |
Erlang]
Manual Page Index
Manual Page | Application |
EOS
}
sub footer {
my $year = (localtime)[5] + 1900;
print <
Copyright © 1991-$year
Ericsson AB
EOS
}