Menu

[r6030]: / trunk / py4science / examples / sphinx_template / make.py  Maximize  Restore  History

Download this file

65 lines (52 with data), 1.5 kB

 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
#!/usr/bin/env python
import fileinput
import glob
import os
import shutil
import sys
def check_build():
build_dirs = ['build', 'build/doctrees', 'build/html', 'build/latex',
'_static', '_templates']
for d in build_dirs:
try:
os.mkdir(d)
except OSError:
pass
def html():
check_build()
os.system('sphinx-build -b html -d build/doctrees . build/html')
def latex():
check_build()
if sys.platform != 'win32':
# LaTeX format.
os.system('sphinx-build -b latex -d build/doctrees . build/latex')
# Produce pdf.
os.chdir('build/latex')
# Copying the makefile produced by sphinx...
os.system('pdflatex sampledoc.tex')
os.system('pdflatex sampledoc.tex')
os.system('makeindex -s python.ist sampledoc.idx')
os.system('makeindex -s python.ist modsampledoc.idx')
os.system('pdflatex sampledoc.tex')
os.chdir('../..')
else:
print 'latex build has not been tested on windows'
def clean():
shutil.rmtree('build')
def all():
html()
latex()
funcd = {'html':html,
'latex':latex,
'clean':clean,
'all':all,
}
if len(sys.argv)>1:
for arg in sys.argv[1:]:
func = funcd.get(arg)
if func is None:
raise SystemExit('Do not know how to handle %s; valid args are'%(
arg, funcd.keys()))
func()
else:
all()
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.