-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.py
executable file
·39 lines (34 loc) · 1.16 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
#!/usr/bin/env python
from __future__ import print_function
import os
import os.path as op
import sys
import shutil
import inspect
import webbrowser
from subprocess import call, check_output
THIS_DIR = op.dirname(op.abspath(__file__))
DOC_DIR = op.join(THIS_DIR, 'doc')
def clean():
dirs = [op.join(DOC_DIR, '_build')]
for d in dirs:
print(' Removing:', d)
shutil.rmtree(d, ignore_errors=True)
def docs():
make_bin = 'make.exe' if sys.platform=='win32' else 'make'
call([make_bin, 'html'], cwd=DOC_DIR)
if '--no-open' not in sys.argv:
webbrowser.open('file://'+op.abspath(DOC_DIR)+'/_build/html/index.html')
if __name__=='__main__':
avail_cmds = dict(filter(lambda kv: not kv[0].startswith('_')
and inspect.isfunction(kv[1])
and kv[1].__module__ == '__main__',
locals().items()))
try:
cmd = avail_cmds[sys.argv[1]]
except Exception as exc:
print(type(exc).__name__, ':', exc)
print('Usage:', op.basename(sys.argv[0]), '<command>')
print(' where commands are:', ', '.join(avail_cmds))
else:
cmd()