summaryrefslogtreecommitdiffstats
path: root/Doc/tools/mkdvi.sh
blob: 3269a287ee070ec01d3c67cac4604b7856c82acb (plain)
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
#! /bin/sh
#
#  Build one of the simple documents.  This can be used to create the DVI,
#  PDF, or LaTeX "aux" files.  It can accept one of three optional parameters:
#
#  --aux	Create only the LaTeX .aux file
#  --dvi	Create the DeVice Independent output
#  --pdf	Create Adobe PDF output
#
#  If no parameter is given, DVI output is produced.
#
#  One positional parameter is required:  the "base" of the document to
#  format.  For the standard Python documentation, this will be api, ext,
#  lib, mac, ref, or tut.

WORKDIR=`pwd`
cd `dirname $0`/..
srcdir=`pwd`
cd $WORKDIR

latex=latex
aux=''
pdf=''
if [ "$1" = "--pdf" ] ; then
    pdf=true
    latex=pdflatex
    shift 1
elif [ "$1" = "--aux" ] ; then
    aux=true
    shift 1
elif [ "$1" = "--dvi" ] ; then
    shift 1
fi

part=$1; shift 1

TEXINPUTS=$srcdir/$part:$TEXINPUTS
export TEXINPUTS

echo $srcdir'/tools/newind.py >'$part'.ind'
$srcdir/tools/newind.py >$part.ind || exit $?
echo $srcdir'/tools/newind.py modindex >mod'$part'.ind'
$srcdir/tools/newind.py modindex >mod$part.ind || exit $?
echo "$latex $part"
$latex $part || exit $?
if [ ! -f mod$part.idx ] ; then
    echo "Not using module index; removing mod$part.ind"
    rm mod$part.ind || exit $?
fi
if [ "$aux" ] ; then
    # make sure the .dvi isn't interpreted as useful:
    rm $part.dvi || exit $?
else
    if [ -f $part.idx ] ; then
	# using the index
	echo $srcdir'/tools/fix_hack '$part'.idx'
	$srcdir/tools/fix_hack $part.idx || exit $?
	echo 'makeindex -s '$srcdir'/texinputs/python.ist '$part'.idx'
	makeindex -s $srcdir/texinputs/python.ist $part.idx || exit $?
	echo $srcdir'/tools/indfix.py '$part'.ind'
	$srcdir/tools/indfix.py $part.ind || exit $?
    else
	# skipping the index; clean up the unused file
	rm -f $part.ind
    fi
    if [ -f mod$part.idx ] ; then
	# using the index
	echo 'makeindex -s '$srcdir'/texinputs/python.ist mod'$part'.idx'
	makeindex -s $srcdir/texinputs/python.ist mod$part.idx || exit $?
    fi
    if [ "$pdf" ] ; then
	echo $srcdir'/tools/toc2bkm.py '$part
	$srcdir/tools/toc2bkm.py $part || exit $?
    fi
    echo "$latex $part"
    $latex $part || exit $?
fi