forked from qmlbook/qmlbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pavement.py
79 lines (63 loc) · 1.8 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from paver.easy import *
from livereload import Server, shell
@task
@needs('assets_init', 'build_html', 'build_pdf', 'build_epub', 'build_qt', 'build_assets')
def build_all():
pass
@task
def build_html():
sh('make html')
@task
def build_pdf():
sh('make latexpdf')
path('_build/latex/qt5_cadaques.pdf').copy('assets')
@task
def build_epub():
sh('make epub')
path('_build/epub/qt5_cadaques.epub').copy('assets')
@task
def build_qt():
sh('export QTHELP=True; make qthelp')
sh('qcollectiongenerator _build/qthelp/Qt5CadaquesBook.qhcp')
path('_build/qthelp/Qt5CadaquesBook.qch').copy('assets')
@task
def show_qt():
sh('assistant -collectionFile _build/qthelp/Qt5CadaquesBook.qch')
@task
def clean():
sh('make clean')
path('assets').rmtree()
@task
def serve():
with pushd('_build/html'):
sh('python -m SimpleHTTPServer')
@task
def live():
server = Server()
server.watch('*.py', shell('make html', cwd='.'))
server.watch('*.rst', shell('make html', cwd='.'))
server.watch('ch*/', shell('make html', cwd='.'))
server.serve(root='_build/html', liveport=35729, open_url_delay=1, debug=False)
ROOT = path('.').abspath()
ASSETS = path('assets').abspath()
@task
def assets_init():
path('assets').makedirs()
@task
@needs('assets_init')
def build_assets():
for ch in path('.').dirs('ch??'):
name = '%s-assets.tgz'%ch
if ch.joinpath('src').isdir():
sh('tar czvf assets/{0} --exclude=".*" {1}/src/'.format(name, ch))
@task
@needs('build_all')
def publish():
with pushd('../qmlbook.github.io'):
sh('git pull')
sh('git checkout master')
sh('cp -rf ../qmlbook/_build/html/* .')
sh('cp -rf ../qmlbook/assets .')
sh('git add .')
sh('git commit -m "update"')
sh('git push')