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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
#!/bin/ksh
# Take a man tree and make an html tree out of it
DOMAIN=$(domainname)
ARCH=$(arch)
case ${DOMAIN} in
acf) localeo=reo1 ;;
bwfid) localeo=reo1 ;;
chfid) localeo=neo1 ;;
hkfid) localeo=teo1 ;;
lnfid) localeo=leo1 ;;
nyfid) localeo=neo1 ;;
psfid) localeo=leo1 ;;
sffid) localeo=neo1 ;;
tkfid) localeo=teo1 ;;
esac
sections="{1,2,3,4,5,6,7,8}"
#from=/usr/man
#to=/u/eo/repository/system/unix/man
from=`pwd`
to=/tmp/man
function disambiguate
{
newbase=${1}
newname="${newbase}.1"
dis=2
while [ -a "${newname}" ]
do
newname=$newbase"."$dis
dis=$(expr $dis + 1)
done
}
while getopts f:t:l:is:v c
do
case $c in
f) from=$OPTARG ;;
t) to=$OPTARG ;;
l) localeo=$OPTARG ;;
i) indexonly=1 ;;
s) sections=$OPTARG ;;
v) verbose=1 ;;
esac
done
shift OPTIND-1
if [ "${verbose}" ]
then
print "from: $from"
print "to: $to"
print "localeo: $localeo"
print "sections: $sections"
if [ "${indexonly}" ]
then
print "indexonly: 1"
fi
fi
cd $from
if [ ! "${indexonly}" ]
then
print "Processing the man pages ..."
for i in man${sections}/*.man
do
if [ "$verbose" ]
then
print $i
fi
# n=${i%.*}
bn="$(basename $i .man)"
name=${to}/${bn}.html
if [ -a "${name}" ]
then
oldname=$name
disambiguate $name
name=$newname
print "Collision - ${oldname} will be stored as ${name}"
fi
eqn $i | tbl | nroff -man | rman -f HTML | sed -e "s/MS_LOCAL_HOST/${localeo}/g" > ${name}
done
fi
print "Building the index.html files ..."
cd $to
for i in man${sections}
do
if [ "$verbose" ]
then
print $i
fi
if [ ! -d $i ]
then
continue
fi
cd $i
pwd
rm -f index.html
echo '<ul>' > ../new.html
for j in *.html
do
bn="$(basename $j .html)"
if [ "$verbose" ]
then
print -n "$j "
fi
# get more interesting name for the link labels
synl="$(egrep -A 1 '<B>.*</B> - .*' $j |sed -e 's/<B>//g' -e 's/<\/B>//g')"
# echo "### synl = $synl"
synname="$(echo $synl |cut -d' ' -f1)"
synopse="$(echo $synl |cut -d' ' -f3-100)"
print
print "<li> <a href=$j>$synname</a> - $synopse" >> ../new.html
done
echo '</ul>' >> ../new.html
mv ../new.html index.html
cd ..
done
|