xref: /plan9/sys/lib/man/mkhtmlindex (revision 7dd7cddf99dd7472612f1413b4da293630e6b1bc)
1#!/bin/rc
2builtin cd $1
3echo '<HEAD>'
4echo '<TITLE>plan 9 man section '$1'</TITLE>'
5echo '</HEAD>'
6echo '<BODY>'
7echo '<B>[<A HREF="/sys/man/index.html">manual index</A>]</B>'
8echo -n '<H2>Plan 9 from Bell Labs - Section '$1' - '
9switch($1){
10case 1
11	echo -n Commands
12case 2
13	echo -n System and Library Calls
14case 3
15	echo -n Devices
16case 4
17	echo -n File Servers
18case 5
19	echo -n Plan 9 File Protocol, 9P
20case 6
21	echo -n File Formats, Misc
22case 7
23	echo -n Databases
24case 8
25	echo -n System Administration
26}
27echo '</H2>'
28echo '<HR>'
29echo '<DL>'
30for (i in [a-z0-9:]*) {
31	switch($1/$i){
32	case 1/ap 1/aviation 1/distill 1/dup 1/games 1/lml 1/noweb 1/pac
33	case 2/button 2/fmenu 2/ftree
34	case 6/noweb
35	case 7/audio 7/chdb 7/music 7/road
36		;
37 	case *
38		echo '<DT><A HREF="/magic/man2html/'$1/$i'">'$i'</A>'
39		awk '
40		BEGIN { syms = ""; indesc = 0; desc = ""; }
41		/.SH *NAME/,/.SH *(DES|SYN)/ {
42			if($1 != "\.SH"){
43				if($1 ~ /^\..*/)
44					i = 2;
45				else
46					i = 1;
47				for(; i <= NF; i++){
48					if(indesc){
49						desc = desc " " $i;
50					} else if($i ~ /^\\?-.*/) {
51						indesc = 1;
52					} else {
53						syms = syms " " $i;
54					}
55				}
56			}
57		}
58		END { print "- " desc; print "<DD><TT>" syms "</TT>"}
59		' $i
60		echo '</DT>'
61	}
62}
63echo '</DL>'
64