aboutsummaryrefslogtreecommitdiffstats
path: root/system/doc/top/bin/otp_man_index
blob: 57a0f12d32b15f594a08e424bbad3f3fa87ffbe8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/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
}