summaryrefslogtreecommitdiff
path: root/mkhtmlindex.sh
blob: d5ba1cd8efba77f03e359ab5a399fcd76587a95f (plain)
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
#!/bin/sh
#
# $XFree86: xc/config/util/mkhtmlindex.sh,v 1.5 2003/08/11 17:41:28 eich Exp $
#
# Copyright © 2000 by Precision Insight, Inc.
#
# Generate index files for the HTML man pages
#
# Author:	David Dawes <dawes@xfree86.org>
#

VOLLIST="1 2 3 4 5 6 7 8 9 o l n p"
INDEX="manindex"

if [ $# != 1 ]; then
	echo Usage: $0 htmlmandir
	exit 1
fi

if [ ! -d $1 ]; then
	echo $1 is not a directory
	exit 1
fi

cd $1

for s in $VOLLIST; do
	list="`ls *.$s.html 2> /dev/null`" || : # ignore failed glob expansion
	if [ X"$list" != X ]; then
		file=$INDEX$s.html
		rm -f $file
		cat <<EOF > $file
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>XFree86[tm] Manual pages: Section $s</TITLE>
</HEAD>
<BODY BGCOLOR="#efefef" TEXT="black" LINK="blue" VLINK="#551A8B" ALINK="red">

<H1>XFree86[tm] Manual pages: Section $s</H1>
<P>
<UL>
EOF
		for i in $list; do
			title="`sed -e '/^[^0-9A-Za-z]/d' -e '/^$/' -e '/^Name/d' -e q $i`"
			name="`echo \"$title\" | sed -e 's/ - .*//'`"
			desc="`echo \"$title\" | sed -e 's/[^-]* - //' -e 's/<P>//'`"
			echo "<LI><A href=\"$i\">$name</A> - $desc</LI>" >> $file
		done
		cat <<EOF >> $file
</UL>
<P>
</BODY>
</HTML>
EOF
	fi
done

exit 0