aboutsummaryrefslogblamecommitdiffstats
path: root/system/doc/top/bin/otp_man_index
blob: 57a0f12d32b15f594a08e424bbad3f3fa87ffbe8 (plain) (tree)









































































































                                                                              
#!/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 "  <TR>\n";
    print "    <TD><A HREF=\"../$path\">$module</A></TD>\n";
    print "    <TD><A HREF=\"../$idx\">$application</A></TD>\n";
    print "  </TR>\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 = <FILE>)) {
	if ($line =~ /<!-- refpage -->/) {
	    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 <<EOS;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- This file was generated by the otp_man_index script -->
<HTML>
<HEAD>
  <link rel="stylesheet" href="otp_doc.css" type="text/css"/>
  <TITLE>Erlang/OTP Manual Page Index</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#FF00FF"
      ALINK="#FF0000">
<CENTER>
<!-- A HREF="http://www.erlang.org/">
<img alt="Erlang logo" src="erlang-logo.png"/ >
</A><BR -->
<SMALL>
[<A HREF="index.html">Up</A> |
<A HREF="http://www.erlang.org/">Erlang</A>]
</SMALL><BR>
<P><FONT SIZE="+4">Manual Page Index</FONT><BR>
</CENTER>
<CENTER>
<P>
<TABLE BORDER=1>
<TR>
  <TH>Manual Page</TH><TH>Application</TH>
</TR>
EOS
}

sub footer {
    my $year = (localtime)[5] + 1900;
    print <<EOS;
</TABLE>
</CENTER>
<P>
<CENTER>
<HR>
<SMALL>
Copyright &copy; 1991-$year
<a href="http://www.ericsson.com/technology/opensource/erlang/">
Ericsson AB</a>
</SMALL>
</CENTER>
</BODY>
</HTML>
EOS
}