2 # gendocs.sh -- generate a GNU manual in many formats. This script is
3 # mentioned in maintain.texi. See the help message below for usage details.
5 scriptversion
=2006-07-15.08
7 # Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2, or (at your option)
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, you can either send email to this
21 # program's maintainer or write to: The Free Software Foundation,
22 # Inc.; 51 Franklin Street, Fifth Floor; Boston, MA 02110-1301, USA.
24 # Original author: Mohit Agarwal.
25 # Send bug reports and any other correspondence to bug-texinfo@gnu.org.
30 scripturl
="http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/texinfo/texinfo/util/gendocs.sh"
31 templateurl
="http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/texinfo/texinfo/util/gendocs_template"
33 : ${MAKEINFO="makeinfo"}
34 : ${TEXI2DVI="texi2dvi -t @finalout"}
36 : ${DOCBOOK2TXT="docbook2txt"}
37 : ${DOCBOOK2HTML="docbook2html"}
38 : ${DOCBOOK2PDF="docbook2pdf"}
39 : ${DOCBOOK2PS="docbook2ps"}
40 : ${GENDOCS_TEMPLATE_DIR="."}
43 version
="gendocs.sh $scriptversion
45 Copyright (C) 2006 Free Software Foundation, Inc.
46 There is NO warranty. You may redistribute this software
47 under the terms of the GNU General Public License.
48 For more information about these matters, see the files named COPYING."
50 usage
="Usage: $prog [OPTION]... PACKAGE MANUAL-TITLE
52 Generate various output formats from PACKAGE.texinfo (or .texi or .txi) source.
53 See the GNU Maintainers document for a more extensive discussion:
54 http://www.gnu.org/prep/maintain_toc.html
57 -o OUTDIR write files into OUTDIR, instead of manual/.
58 --docbook convert to DocBook too (xml, txt, html, pdf and ps).
59 --html ARG pass indicated ARG to makeinfo for HTML targets.
60 --help display this help and exit successfully.
61 --version display version information and exit successfully.
63 Simple example: $prog emacs \"GNU Emacs Manual\"
66 cd YOURPACKAGESOURCE/doc
69 $prog YOURMANUAL \"GNU YOURMANUAL - One-line description\"
71 Output will be in a new subdirectory \"manual\" (by default, use -o OUTDIR
72 to override). Move all the new files into your web CVS tree, as
73 explained in the Web Pages node of maintain.texi.
75 MANUAL-TITLE is included as part of the HTML <title> of the overall
76 manual/index.html file. It should include the name of the package being
77 documented. manual/index.html is created by substitution from the file
78 $GENDOCS_TEMPLATE_DIR/gendocs_template. (Feel free to modify the
79 generic template for your own purposes.)
81 If you have several manuals, you'll need to run this script several
82 times with different YOURMANUAL values, specifying a different output
83 directory with -o each time. Then write (by hand) an overall index.html
84 with links to them all.
86 You can set the environment variables MAKEINFO, TEXI2DVI, and DVIPS to
87 control the programs that get executed, and GENDOCS_TEMPLATE_DIR to
88 control where the gendocs_template file is looked for.
90 Email bug reports or enhancement requests to bug-texinfo@gnu.org.
95 size
=`ls -ksl $1 | awk '{print $1}'`
104 while test $# -gt 0; do
106 --help) echo "$usage"; exit 0;;
107 --version) echo "$version"; exit 0;;
108 -o) shift; outdir
=$1;;
109 --docbook) docbook
=yes;;
110 --html) shift; html
=$1;;
112 echo "$0: Unknown or ambiguous option \`$1'." >&2
113 echo "$0: Try \`--help' for more information." >&2
116 if test -z "$PACKAGE"; then
118 elif test -z "$MANUAL_TITLE"; then
121 echo "$0: extra non-option argument \`$1'." >&2
128 if test -s "$srcdir/$PACKAGE.texinfo"; then
129 srcfile
=$srcdir/$PACKAGE.texinfo
130 elif test -s "$srcdir/$PACKAGE.texi"; then
131 srcfile
=$srcdir/$PACKAGE.texi
132 elif test -s "$srcdir/$PACKAGE.txi"; then
133 srcfile
=$srcdir/$PACKAGE.txi
135 echo "$0: cannot find .texinfo or .texi or .txi for $PACKAGE in $srcdir." >&2
139 if test ! -r $GENDOCS_TEMPLATE_DIR/gendocs_template
; then
140 echo "$0: cannot read $GENDOCS_TEMPLATE_DIR/gendocs_template." >&2
141 echo "$0: it is available from $templateurl." >&2
145 echo Generating output formats
for $srcfile
147 cmd
="${MAKEINFO} -o $PACKAGE.info \"$srcfile\""
148 echo "Generating info files... ($cmd)"
151 tar czf
$outdir/$PACKAGE.info.
tar.gz
$PACKAGE.info
*
152 info_tgz_size
=`calcsize $outdir/$PACKAGE.info.tar.gz`
153 # do not mv the info files, there's no point in having them available
154 # separately on the web.
156 cmd
="${TEXI2DVI} \"$srcfile\""
157 echo "Generating dvi ... ($cmd)"
160 # now, before we compress dvi:
161 echo Generating postscript...
163 gzip -f -9 $PACKAGE.ps
164 ps_gz_size
=`calcsize $PACKAGE.ps.gz`
165 mv $PACKAGE.ps.gz
$outdir/
167 # compress/finish dvi:
168 gzip -f -9 $PACKAGE.dvi
169 dvi_gz_size
=`calcsize $PACKAGE.dvi.gz`
170 mv $PACKAGE.dvi.gz
$outdir/
172 cmd
="${TEXI2DVI} --pdf \"$srcfile\""
173 echo "Generating pdf ... ($cmd)"
175 pdf_size
=`calcsize $PACKAGE.pdf`
176 mv $PACKAGE.pdf
$outdir/
178 cmd
="${MAKEINFO} -o $PACKAGE.txt --no-split --no-headers \"$srcfile\""
179 echo "Generating ASCII... ($cmd)"
181 ascii_size
=`calcsize $PACKAGE.txt`
182 gzip -f -9 -c $PACKAGE.txt
>$outdir/$PACKAGE.txt.gz
183 ascii_gz_size
=`calcsize $outdir/$PACKAGE.txt.gz`
184 mv $PACKAGE.txt
$outdir/
186 cmd
="${MAKEINFO} --no-split --html -o $PACKAGE.html $html \"$srcfile\""
187 echo "Generating monolithic html... ($cmd)"
188 rm -rf $PACKAGE.html
# in case a directory is left over
190 html_mono_size
=`calcsize $PACKAGE.html`
191 gzip -f -9 -c $PACKAGE.html
>$outdir/$PACKAGE.html.gz
192 html_mono_gz_size
=`calcsize $outdir/$PACKAGE.html.gz`
193 mv $PACKAGE.html
$outdir/
195 cmd
="${MAKEINFO} --html -o $PACKAGE.html $html \"$srcfile\""
196 echo "Generating html by node... ($cmd)"
198 split_html_dir
=$PACKAGE.html
200 cd ${split_html_dir} ||
exit 1
201 tar -czf ..
/$outdir/${PACKAGE}.html_node.
tar.gz
-- *.html
203 html_node_tgz_size
=`calcsize $outdir/${PACKAGE}.html_node.tar.gz`
204 rm -f $outdir/html_node
/*.html
205 mkdir
-p $outdir/html_node
/
206 mv ${split_html_dir}/*.html
$outdir/html_node
/
207 rmdir ${split_html_dir}
209 echo Making .
tar.gz
for sources...
210 srcfiles
=`ls *.texinfo *.texi *.txi *.eps 2>/dev/null`
211 tar cvzfh
$outdir/$PACKAGE.texi.
tar.gz
$srcfiles
212 texi_tgz_size
=`calcsize $outdir/$PACKAGE.texi.tar.gz`
214 if test -n "$docbook"; then
215 cmd
="${MAKEINFO} -o - --docbook \"$srcfile\" > ${srcdir}/$PACKAGE-db.xml"
216 echo "Generating docbook XML... $(cmd)"
218 docbook_xml_size
=`calcsize $PACKAGE-db.xml`
219 gzip -f -9 -c $PACKAGE-db.xml
>$outdir/$PACKAGE-db.xml.gz
220 docbook_xml_gz_size
=`calcsize $outdir/$PACKAGE-db.xml.gz`
221 mv $PACKAGE-db.xml
$outdir/
223 cmd
="${DOCBOOK2HTML} -o $split_html_db_dir ${outdir}/$PACKAGE-db.xml"
224 echo "Generating docbook HTML... ($cmd)"
226 split_html_db_dir
=html_node_db
228 cd ${split_html_db_dir} ||
exit 1
229 tar -czf ..
/$outdir/${PACKAGE}.html_node_db.
tar.gz
-- *.html
231 html_node_db_tgz_size
=`calcsize $outdir/${PACKAGE}.html_node_db.tar.gz`
232 rm -f $outdir/html_node_db
/*.html
233 mkdir
-p $outdir/html_node_db
234 mv ${split_html_db_dir}/*.html
$outdir/html_node_db
/
235 rmdir ${split_html_db_dir}
237 cmd
="${DOCBOOK2TXT} ${outdir}/$PACKAGE-db.xml"
238 echo "Generating docbook ASCII... ($cmd)"
240 docbook_ascii_size
=`calcsize $PACKAGE-db.txt`
241 mv $PACKAGE-db.txt
$outdir/
243 cmd
="${DOCBOOK2PS} ${outdir}/$PACKAGE-db.xml"
244 echo "Generating docbook PS... $(cmd)"
246 gzip -f -9 -c $PACKAGE-db.ps
>$outdir/$PACKAGE-db.ps.gz
247 docbook_ps_gz_size
=`calcsize $outdir/$PACKAGE-db.ps.gz`
248 mv $PACKAGE-db.ps
$outdir/
250 cmd
="${DOCBOOK2PDF} ${outdir}/$PACKAGE-db.xml"
251 echo "Generating docbook PDF... ($cmd)"
253 docbook_pdf_size
=`calcsize $PACKAGE-db.pdf`
254 mv $PACKAGE-db.pdf
$outdir/
257 echo Writing index
file...
258 curdate
=`date '+%B %d, %Y'`
260 -e "s!%%TITLE%%!$MANUAL_TITLE!g" \
261 -e "s!%%DATE%%!$curdate!g" \
262 -e "s!%%PACKAGE%%!$PACKAGE!g" \
263 -e "s!%%HTML_MONO_SIZE%%!$html_mono_size!g" \
264 -e "s!%%HTML_MONO_GZ_SIZE%%!$html_mono_gz_size!g" \
265 -e "s!%%HTML_NODE_TGZ_SIZE%%!$html_node_tgz_size!g" \
266 -e "s!%%INFO_TGZ_SIZE%%!$info_tgz_size!g" \
267 -e "s!%%DVI_GZ_SIZE%%!$dvi_gz_size!g" \
268 -e "s!%%PDF_SIZE%%!$pdf_size!g" \
269 -e "s!%%PS_GZ_SIZE%%!$ps_gz_size!g" \
270 -e "s!%%ASCII_SIZE%%!$ascii_size!g" \
271 -e "s!%%ASCII_GZ_SIZE%%!$ascii_gz_size!g" \
272 -e "s!%%TEXI_TGZ_SIZE%%!$texi_tgz_size!g" \
273 -e "s!%%DOCBOOK_HTML_NODE_TGZ_SIZE%%!$html_node_db_tgz_size!g" \
274 -e "s!%%DOCBOOK_ASCII_SIZE%%!$docbook_ascii_size!g" \
275 -e "s!%%DOCBOOK_PS_GZ_SIZE%%!$docbook_ps_gz_size!g" \
276 -e "s!%%DOCBOOK_PDF_SIZE%%!$docbook_pdf_size!g" \
277 -e "s!%%DOCBOOK_XML_SIZE%%!$docbook_xml_size!g" \
278 -e "s!%%DOCBOOK_XML_GZ_SIZE%%!$docbook_xml_gz_size!g" \
279 -e "s,%%SCRIPTURL%%,$scripturl,g" \
280 -e "s!%%SCRIPTNAME%%!$prog!g" \
281 $GENDOCS_TEMPLATE_DIR/gendocs_template
>$outdir/index.html
283 echo "Done! See $outdir/ subdirectory for new files."
286 # eval: (add-hook 'write-file-hooks 'time-stamp)
287 # time-stamp-start: "scriptversion="
288 # time-stamp-format: "%:y-%02m-%02d.%02H"
289 # time-stamp-end: "$"