| 1 |
#! /bin/sh |
| 2 |
#ident $Revision: 1.1.1.1 $ |
| 3 |
# @(#)mmdoc 1.21 /doccenter/tmadm/src/shell/s.mmdoc |
| 4 |
# general documentation generator |
| 5 |
# |
| 6 |
# Files begining with a ".TH" macro are treated as manual pages. |
| 7 |
# Files whose first line is |
| 8 |
# '\" x |
| 9 |
# where "x" is a string begining with "c", "e", "t" are also treated as |
| 10 |
# manual pages. |
| 11 |
# Files whose first line is |
| 12 |
# '\"! text |
| 13 |
# are processed by the command line "text" with the file provided |
| 14 |
# as the standard input. |
| 15 |
# Files whose first line is |
| 16 |
# '\"macro name |
| 17 |
# where "name" is the name of a file in TMMACRO will be run off with |
| 18 |
# that macro package. "name"s begining "-" will be flag arguments |
| 19 |
# to nroff. |
| 20 |
# All others are handed to nroff with -cm and mmdoc |
| 21 |
# |
| 22 |
# Assumes manprog will be found by the current search path. |
| 23 |
# |
| 24 |
umask 0 # nroff must be able to write into files it closes |
| 25 |
while [ -n "$1" ] |
| 26 |
do |
| 27 |
case $1 in |
| 28 |
-D ) |
| 29 |
DrafT=-rC3 |
| 30 |
export DrafT |
| 31 |
;; |
| 32 |
-T* ) |
| 33 |
TERM=`expr $1 : '-T\(.*\)'` |
| 34 |
case ${TERM} in |
| 35 |
eps) |
| 36 |
post="|deps" |
| 37 |
flavor=troff |
| 38 |
;; |
| 39 |
aps) |
| 40 |
post="|apsend b=m305" |
| 41 |
flavor=troff |
| 42 |
;; |
| 43 |
Aps) # This is a fake out so that collections |
| 44 |
# can be sent as a unit to APS-5 |
| 45 |
# instead of series of calls. Used only by |
| 46 |
# collection routine 'tcol_final' |
| 47 |
post= |
| 48 |
flavor=troff |
| 49 |
TERM=aps |
| 50 |
;; |
| 51 |
image) |
| 52 |
post="|apsend b=m305 d=i" |
| 53 |
flavor=troff |
| 54 |
TERM=aps |
| 55 |
;; |
| 56 |
i300) |
| 57 |
post="|dimpress" |
| 58 |
flavor=troff |
| 59 |
;; |
| 60 |
8300) |
| 61 |
post="|dimpress" |
| 62 |
flavor=troff |
| 63 |
TERM=aps |
| 64 |
;; |
| 65 |
psc) |
| 66 |
post="|psdit |lp -oh" |
| 67 |
flavor=troff |
| 68 |
export TERM |
| 69 |
;; |
| 70 |
|
| 71 |
PS) |
| 72 |
post="|psdit" |
| 73 |
flavor=troff |
| 74 |
TERM=psc |
| 75 |
export TERM |
| 76 |
;; |
| 77 |
X100) |
| 78 |
post="" |
| 79 |
flavor=troff |
| 80 |
TERM=X100 |
| 81 |
export TERM |
| 82 |
;; |
| 83 |
*) |
| 84 |
post= |
| 85 |
flavor=nroff |
| 86 |
;; |
| 87 |
esac |
| 88 |
export post flavor |
| 89 |
;; |
| 90 |
-r[ymd]* ) |
| 91 |
DocdatE="$DocdatE $1" |
| 92 |
export DocdatE |
| 93 |
dateset=yes |
| 94 |
;; |
| 95 |
-?* ) |
| 96 |
flags="$flags $1" |
| 97 |
export flags |
| 98 |
;; |
| 99 |
- | * ) |
| 100 |
break |
| 101 |
esac |
| 102 |
shift |
| 103 |
done |
| 104 |
if [ $# = 0 ] |
| 105 |
then |
| 106 |
set -- - |
| 107 |
fi |
| 108 |
for i |
| 109 |
{ |
| 110 |
if [ "$i" != "-" -a ! -s "$i" ] |
| 111 |
then |
| 112 |
echo "Cannot input file: $i" |
| 113 |
continue |
| 114 |
fi |
| 115 |
case $i in |
| 116 |
- ) |
| 117 |
;; |
| 118 |
* ) |
| 119 |
Line1=`line <$i` |
| 120 |
if [ ! "${dateset}" ] |
| 121 |
then |
| 122 |
# DocdatE is intentionally capitalized that way |
| 123 |
# to cut the possibility of env name collision. |
| 124 |
DocdatE=`manprog $i` |
| 125 |
export DocdatE |
| 126 |
fi |
| 127 |
esac |
| 128 |
|
| 129 |
MacrO=${TMMACRO} |
| 130 |
|
| 131 |
case "${Line1}" in |
| 132 |
.TH* | "'\\\" "[cet]* ) |
| 133 |
man -T${TERM} -d ${DocdatE} $* |
| 134 |
;; |
| 135 |
"'\\\"!"* ) |
| 136 |
cmd=`echo "${Line1}" | sed 's/^....//'` |
| 137 |
if [ "$flavor" != troff ] |
| 138 |
then |
| 139 |
cmd=`echo " ${cmd} " | sed 's/ eqn / neqn /'` |
| 140 |
fi |
| 141 |
Line1=`sed -n -e 2p -e 2q ${i}` |
| 142 |
export Line1 |
| 143 |
if [ "$flavor" = troff ] |
| 144 |
then |
| 145 |
eval '<$i' $cmd |
| 146 |
#eval `parse "$cmd" ${i}` |
| 147 |
else |
| 148 |
TERM=lp |
| 149 |
eval '<$i' $cmd |
| 150 |
fi |
| 151 |
;; |
| 152 |
"'\\\"macro"* ) |
| 153 |
cmd=`echo "${Line1}" | |
| 154 |
sed ' s/.."macro//'" |
| 155 |
s:[ ]\([^- ]\): ${TMMACRO?}/\1:g"` |
| 156 |
cmd=`echo $cmd|sed "s;[ ]*.*/stdmacro;${MacrO?}/strings.mm ${MacrO?}/stdmacro;"` |
| 157 |
cmd="$cmd $OTHERFILES" |
| 158 |
if [ "$flavor" = troff ] |
| 159 |
then |
| 160 |
case "$cmd" in |
| 161 |
*stdmacro*) |
| 162 |
case "$flags" in |
| 163 |
*-rs[0-9]*) |
| 164 |
;; |
| 165 |
*) |
| 166 |
flags="${flags} -rs1" |
| 167 |
esac |
| 168 |
esac |
| 169 |
eval troff -T${TERM} ${DrafT} ${DocdatE} ${flags} ${cmd} $i ${post} |
| 170 |
else |
| 171 |
eval nroff ${DrafT} ${DocdatE} ${flags} ${cmd} $i |
| 172 |
fi |
| 173 |
;; |
| 174 |
"'\\\"text"* ) |
| 175 |
cmd=`echo "${Line1}" | |
| 176 |
sed ' s/.."text//'" |
| 177 |
s:[ ]\([^- ]\): ${TMMACRO?}/\1:g"` |
| 178 |
cmd=`echo $cmd|sed "s;[ ]*.*/docmacs;${MacrO?}/docmacs;"` |
| 179 |
if [ "$flavor" = troff ] |
| 180 |
then |
| 181 |
eval troff -T${TERM} ${DrafT} ${DocdatE} ${flags} ${cmd} $i ${post} |
| 182 |
else |
| 183 |
eval nroff ${DrafT} ${DocdatE} ${flags} ${cmd} $i |
| 184 |
fi |
| 185 |
;; |
| 186 |
.tH* ) |
| 187 |
# Right now 2/12/85 this stuff not used for DSG work. |
| 188 |
# No enhancements to do troff done yet. |
| 189 |
# Will do as necessary |
| 190 |
if [ -r ${TMMACRO}/mandocvar ] |
| 191 |
then |
| 192 |
. ${TMMACRO}/mandocvar |
| 193 |
fi |
| 194 |
nroff -T${TERM} ${DocdatE} ${flags} \ |
| 195 |
-can ${MacrO?}/mandoc ${i} | |
| 196 |
col |
| 197 |
;; |
| 198 |
.pH* | '' | * ) |
| 199 |
if [ -r ${TMMACRO}/mmdocvar ] |
| 200 |
then |
| 201 |
. ${TMMACRO}/mmdocvar |
| 202 |
fi |
| 203 |
if [ "$flavor" = troff ] |
| 204 |
then |
| 205 |
eval troff -T${TERM} -rW${Width:-5}i \ |
| 206 |
-rL${Length:-8.5}i \ |
| 207 |
${DocdatE} ${DrafT} ${flags} \ |
| 208 |
/usr/bin/mmt $i ${post} |
| 209 |
else |
| 210 |
TERM=lp |
| 211 |
nroff -T${TERM} -u${Overstrike:-1} -rW${Width:-79} \ |
| 212 |
-rO${Offset:-0} -rL${Length:-66} \ |
| 213 |
${DocdatE} ${DrafT} ${flags} \ |
| 214 |
${MacrO?}/newmm \ |
| 215 |
${MacrO?}/mmdoc ${TMMACRO}/custom $i | |
| 216 |
col |
| 217 |
fi |
| 218 |
;; |
| 219 |
esac |
| 220 |
} |