-
Notifications
You must be signed in to change notification settings - Fork 1
/
make.py
executable file
·109 lines (87 loc) · 2.59 KB
/
make.py
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env python
"""
Python script for building documentation.
To build the docs you must have all optional dependencies for statsmodels
installed. See the installation instructions for a list of these.
Note: currently latex builds do not work because of table formats that are not
supported in the latex generation.
Usage
-----
python make.py clean
python make.py html
"""
import glob
import os
import shutil
import sys
import sphinx
os.environ['PYTHONPATH'] = '..'
SPHINX_BUILD = 'sphinxbuild'
def upload():
'push a copy to the site'
os.system('cd build/html; rsync -avz . [email protected]'
':/usr/share/nginx/pandas/pandas-docs/vbench/ -essh')
def uploadpdf():
'push a copy to the sf site'
os.system('cd build/latex; scp pandas.pdf wesmckinn,[email protected]'
':/home/groups/p/pa/pandas/htdocs/')
def clean():
if os.path.exists('build'):
shutil.rmtree('build')
if os.path.exists('source/generated'):
shutil.rmtree('source/generated')
def html():
check_build()
if os.system('sphinx-build -P -b html -d build/doctrees '
'source build/html'):
raise SystemExit("Building HTML failed.")
def latex():
check_build()
if sys.platform != 'win32':
# LaTeX format.
if os.system('sphinx-build -b latex -d build/doctrees '
'source build/latex'):
raise SystemExit("Building LaTeX failed.")
# Produce pdf.
os.chdir('build/latex')
# Call the makefile produced by sphinx...
if os.system('make'):
raise SystemExit("Rendering LaTeX failed.")
os.chdir('../..')
else:
print 'latex build has not been tested on windows'
def check_build():
build_dirs = [
'build', 'build/doctrees', 'build/html',
'build/latex', 'build/plots', 'build/_static',
'build/_templates']
for d in build_dirs:
try:
os.mkdir(d)
except OSError:
pass
def all():
# clean()
html()
funcd = {
'html' : html,
'latex' : latex,
'clean' : clean,
'upload' : upload,
'uploadpdf' : uploadpdf,
'all' : all,
}
small_docs = False
# current_dir = os.getcwd()
# os.chdir(os.path.dirname(os.path.join(current_dir, __file__)))
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 %s'%(
arg, funcd.keys()))
func()
else:
small_docs = False
all()
#os.chdir(current_dir)