-
Notifications
You must be signed in to change notification settings - Fork 1
/
pavement.py
60 lines (50 loc) · 1.31 KB
/
pavement.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
# Copyright (c) 2017 Adi Roiban.
# See LICENSE for details.
"""
Build script for Python binary distribution.
"""
import os
import sys
from paver.easy import path, task
@task
def deps():
"""
Copy external dependencies.
"""
print('Installing dependencies to ...')
from pip import main
main(args=['install', '-r', 'docs/requirements.txt'])
def _run_sphinx(args):
"""
Run sphinx build with `args`.
"""
from sphinx.cmd.build import main
main(args)
@task
def build():
"""
Generate the site as local static files.
"""
build_html = os.path.join(os.getcwd(), 'build', 'html')
# Works: sphinx-build -b html -j 2 -n -W docs/ build/html/
_run_sphinx(['-b', 'html', '-j', '2', '-n', '-W', 'docs/', build_html])
print("Open the result in a browser: file://%s/index.html" % build_html)
@task
def test():
"""
Run a few tests.
"""
build_errors = os.path.join(os.getcwd(), 'build', 'errors')
path(build_errors).remove()
build_html = os.path.join(os.getcwd(), 'build', 'html')
_run_sphinx([
'-b', 'html',
'-j', '2',
'-Ean', '-w', build_errors,
'docs/', build_html,
])
errors = open(build_errors, 'r').read()
if errors:
print('Errors summary:\n\n')
print(errors)
sys.exit(1)