Converted mkpdf, mkman and mkhtml to Python.
[gtk-doc.git] / db2man / docbook-to-man
blobfd85da6b82313aa59405273e20edbafde45ac671
1 #!/bin/sh
2 #############################################################################
4 # docbook-to-man.sh
6 #############################################################################
7 #
8 # Copyright (c) 1996 X Consortium
9 # Copyright (c) 1996 Dalrymple Consulting
11 # Permission is hereby granted, free of charge, to any person obtaining a copy
12 # of this software and associated documentation files (the "Software"), to deal
13 # in the Software without restriction, including without limitation the rights
14 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 # copies of the Software, and to permit persons to whom the Software is
16 # furnished to do so, subject to the following conditions:
18 # The above copyright notice and this permission notice shall be included in
19 # all copies or substantial portions of the Software.
21 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 # X CONSORTIUM OR DALRYMPLE CONSULTING BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 # OTHER DEALINGS IN THE SOFTWARE.
29 # Except as contained in this notice, the names of the X Consortium and
30 # Dalrymple Consulting shall not be used in advertising or otherwise to
31 # promote the sale, use or other dealings in this Software without prior
32 # written authorization.
34 #############################################################################
36 # Written 5/29/96 by Fred Dalrymple
38 #############################################################################
40 # ***** change the following paths if your installation of nsgmls and / or
41 # ***** DocBook isn't into the default places.
43 ROOT=/usr
44 SGMLS=$ROOT/lib/sgml
45 DOCBOOK=$SGMLS/davenport
48 # ***** modify the following line (to "=false") if you're not using the
49 # ***** Elan Documentor's Workbench
51 doElanPSInclude=false
55 # Everything below this line should be pretty standard and not require
56 # modification.
58 #ulimit -c unlimited
60 PARSER=nsgmls
61 INSTANT=instant
62 INSTANT_OPT=-d
64 #CATALOG=$DOCBOOK/docbook.cat
65 CATALOG=/etc/sgml.catalog
66 DECL=$DOCBOOK/docbook.dcl
68 error=false
70 if [ $# -eq 1 ]
71 then INSTANCE=$1
72 else error=true
75 if `$error`
76 then echo "usage: docbook-to-man docbook-instance"
77 exit 1
80 if `$doElanPSInclude`
81 then cat > /tmp/dtm.$$.psinc <<\!
82 ...\" $Header$
83 ...\"
84 ...\" transcript compatibility for postscript use.
85 ...\"
86 ...\" synopsis: .P! <file.ps>
87 ...\"
88 .de P!
89 \\&.
90 .fl \" force out current output buffer
91 \\!%PB
92 \\!/showpage{}def
93 ...\" the following is from Ken Flowers -- it prevents dictionary overflows
94 \\!/tempdict 200 dict def tempdict begin
95 .fl \" prolog
96 .sy cat \\$1\" bring in postscript file
97 ...\" the following line matches the tempdict above
98 \\!end % tempdict %
99 \\!PE
100 \\!.
101 .sp \\$2u \" move below the image
104 else cat > /tmp/dtm.$$.psinc <<\!
105 ...\" $Header$
106 ...\"
107 ...\" transcript compatibility for postscript use.
108 ...\"
109 ...\" synopsis: .P! <file.ps>
110 ...\"
111 .de P!
113 \!!1 setgray
115 \\&.\"
117 \!!0 setgray
118 .fl \" force out current output buffer
119 \!!save /psv exch def currentpoint translate 0 0 moveto
120 \!!/showpage{}def
121 .fl \" prolog
122 .sy sed -e 's/^/!/' \\$1\" bring in postscript file
123 \!!psv restore
128 cat >> /tmp/dtm.$$.psinc <<\!
129 .de pF
130 .ie \a\\*(f1\a\a .ds f1 \\n(.f
131 .el .ie \a\\*(f2\a\a .ds f2 \\n(.f
132 .el .ie \a\\*(f3\a\a .ds f3 \\n(.f
133 .el .ie \a\\*(f4\a\a .ds f4 \\n(.f
134 .el .tm ? font overflow
135 .ft \\$1
137 .de fP
138 .ie !\a\\*(f4\a\a \{\
139 . ft \\*(f4
140 . ds f4\"
141 ' br \}
142 .el .ie !\a\\*(f3\a\a \{\
143 . ft \\*(f3
144 . ds f3\"
145 ' br \}
146 .el .ie !\a\\*(f2\a\a \{\
147 . ft \\*(f2
148 . ds f2\"
149 ' br \}
150 .el .ie !\a\\*(f1\a\a \{\
151 . ft \\*(f1
152 . ds f1\"
153 ' br \}
154 .el .tm ? font underflow
156 .ds f1\"
157 .ds f2\"
158 .ds f3\"
159 .ds f4\"
163 cat > /tmp/dtm.$$.prolog <<!
164 <!DOCTYPE RefEntry PUBLIC "-//Davenport//DTD DocBook V3.0//EN" [
165 <!ENTITY npzwc "">
169 (cat /tmp/dtm.$$.psinc;
170 $PARSER -gl -wno-idref -m$CATALOG $DECL /tmp/dtm.$$.prolog $INSTANCE |
171 $INSTANT $INSTANT_OPT -croff.cmap -sroff.sdata -tdocbook-to-man.ts)
173 #(cat /tmp/dtm.$$.psinc;
174 # $PARSER -gl -wno-idref -m$CATALOG $DECL $INSTANCE |
175 # $INSTANT $INSTANT_OPT -croff.cmap -sroff.sdata -tdocbook-to-man.ts)
177 rm -f /tmp/dtm.$$.psinc
178 rm -f /tmp/dtm.$$.prolog