#!/bin/rc
builtin cd $1
echo '
'
echo 'plan 9 man section '$1''
echo ''
echo ''
echo '[manual index]'
echo -n 'Plan 9 from Bell Labs - Section '$1' - '
switch($1){
case 1
echo -n Commands
case 2
echo -n System and Library Calls
case 3
echo -n Devices
case 4
echo -n File Servers
case 5
echo -n Plan 9 File Protocol, 9P
case 6
echo -n File Formats, Misc
case 7
echo -n Databases
case 8
echo -n System Administration
case 9
echo -n Kernel Functions
}
echo '
'
echo '
'
echo ''
for (i in [a-z0-9:]*) {
switch($1/$i){
case 1/ap 1/aviation 1/distill 1/dup 1/games 1/lml 1/noweb 1/pac
case 2/button 2/fmenu 2/ftree
case 6/noweb
case 7/audio 7/chdb 7/music 7/road
;
case *
echo '- '$i''
awk '
BEGIN { syms = ""; indesc = 0; desc = ""; }
/.SH *NAME/,/.SH *(DES|SYN)/ {
if($1 != "\.SH"){
if($1 ~ /^\..*/)
i = 2;
else
i = 1;
for(; i <= NF; i++){
if(indesc){
desc = desc " " $i;
} else if($i ~ /^\\?-.*/) {
indesc = 1;
} else {
syms = syms " " $i;
}
}
}
}
END { print "- " desc; print "
- " syms ""}
' $i
echo ''
}
}
echo '
'