Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 15f742d

Browse files
author
Skip Montanaro
committed
first cut at a shell script to view a single section from the library
reference manual
1 parent eab7db3 commit 15f742d

1 file changed

Lines changed: 129 additions & 0 deletions

File tree

Doc/tools/makesec.sh

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#!/bin/bash
2+
3+
# Simple little checker for individual libref manual sections
4+
#
5+
# usage: makesec.sh section
6+
#
7+
8+
# This script builds the minimal file necessary to run a single section
9+
# through latex, does so, then converts the resulting dvi file to ps or pdf
10+
# and feeds the result into a viewer. It's by no means foolproof, but seems
11+
# to work okay for me (knock wood). It sure beats manually commenting out
12+
# most of the man lib.tex file and running everything manually.
13+
14+
# It attempts to locate an appropriate dvi converter and viewer for the
15+
# selected output format. It understands the following environment
16+
# variables:
17+
#
18+
# PYSRC - refers to the root of your build tree (dir containing Doc)
19+
# DVICVT - refers to a dvi converter like dvips or dvipdf
20+
# VIEWER - refers to an appropriate viewer for the ps/pdf file
21+
#
22+
# Of the three, only PYSRC is currently required. The other two can be set
23+
# to specify unusual tools which perform those tasks.
24+
25+
# Known issues:
26+
# - It would be nice if the script could determine PYSRC on its own.
27+
# - Something about \seealso{}s blows the latex stack, so they need
28+
# to be commented out for now.
29+
30+
if [ x$PYSRC = x ] ; then
31+
echo "PYSRC must refer to the Python source tree" 1>&2
32+
exit 1
33+
fi
34+
35+
if [ ! -d $PYSRC/Doc ] ; then
36+
echo "Can't find a Doc subdirectory in $PYSRC" 1>&2
37+
exit 1
38+
fi
39+
40+
if [ "$#" -ne 1 ] ; then
41+
echo "Must specify a single libref manual section on cmd line" 1>&2
42+
exit 1
43+
fi
44+
45+
# settle on a dvi converter
46+
if [ x$DVICVT != x ] ; then
47+
converter=$DVICVT
48+
ext=`echo $DVICVT | sed -e 's/^dvi//'`
49+
result=lib.$ext
50+
elif [ x`which dvipdf` != x ] ; then
51+
converter=`which dvipdf`
52+
ext=.pdf
53+
elif [ x`which dvips` != x ] ; then
54+
converter=`which dvips`
55+
ext=.ps
56+
else
57+
echo "Can't find a reasonable dvi converter" 1>&2
58+
echo "Set DVICVT to refer to one" 1>&2
59+
exit 1
60+
fi
61+
62+
# how about a viewer?
63+
if [ x$VIEWER != x ] ; then
64+
viewer=$VIEWER
65+
elif [ $ext = ".ps" -a x`which gv` != x ] ; then
66+
viewer=gv
67+
elif [ $ext = ".ps" -a x`which gs` != x ] ; then
68+
viewer=gs
69+
elif [ $ext = ".pdf" -a x`which acroread` != x ] ; then
70+
viewer=acroread
71+
elif [ $ext = ".pdf" -a "`uname`" = "Darwin" -a x`which open` != x ] ; then
72+
viewer=open
73+
elif [ $ext = ".pdf" -a x`which acroread` != x ] ; then
74+
viewer=acroread
75+
else
76+
echo "Can't find a reasonable viewer" 1>&2
77+
echo "Set VIEWER to refer to one" 1>&2
78+
exit 1
79+
fi
80+
81+
# make sure necessary links are in place
82+
for f in howto.cls pypaper.sty ; do
83+
rm -f $f
84+
ln -s $PYSRC/Doc/$f
85+
done
86+
87+
export TEXINPUTS=.:$PYSRC/Doc/texinputs:
88+
89+
# strip extension in case they gave full filename
90+
inp=`basename $1 .tex`
91+
92+
# create the minimal framework necessary to run section through latex
93+
tmpf=lib.tex
94+
cat > $tmpf <<EOF
95+
\documentclass{manual}
96+
97+
% NOTE: this file controls which chapters/sections of the library
98+
% manual are actually printed. It is easy to customize your manual
99+
% by commenting out sections that you are not interested in.
100+
101+
\title{Python Library Reference}
102+
103+
\input{boilerplate}
104+
105+
\makeindex % tell \index to actually write the
106+
% .idx file
107+
\makemodindex % ... and the module index as well.
108+
109+
110+
\begin{document}
111+
112+
\maketitle
113+
114+
\ifhtml
115+
\chapter*{Front Matter\label{front}}
116+
\fi
117+
118+
\input{$inp}
119+
\end{document}
120+
EOF
121+
122+
latex $tmpf
123+
124+
$converter lib
125+
126+
$viewer lib.pdf
127+
128+
rm -f $tmpf howto.cls pypaper.sty *.idx *.syn
129+
rm -f lib.{aux,log}

0 commit comments

Comments
 (0)