Mercurial > piecrust2
annotate garcon/documentation.py @ 651:cc2d212c3ba1 2.0.0b5
cm: Regenerate the CHANGELOG.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 16 Feb 2016 22:32:58 -0800 |
parents | be67fb6add5f |
children | a409a7bb3948 |
rev | line source |
---|---|
642
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
1 import os |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
2 import os.path |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
3 from invoke import task, run |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
4 |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
5 |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
6 @task |
647
be67fb6add5f
cm: Fixes and tweaks to the documentation generation task.
Ludovic Chabant <ludovic@chabant.com>
parents:
645
diff
changeset
|
7 def gendocs(tmp_dir=None, out_dir=None, root_url=None): |
642
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
8 if not tmp_dir: |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
9 tmp_dir = '_docs-counter' |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
10 |
647
be67fb6add5f
cm: Fixes and tweaks to the documentation generation task.
Ludovic Chabant <ludovic@chabant.com>
parents:
645
diff
changeset
|
11 if not os.path.isdir('venv'): |
be67fb6add5f
cm: Fixes and tweaks to the documentation generation task.
Ludovic Chabant <ludovic@chabant.com>
parents:
645
diff
changeset
|
12 raise Exception( |
be67fb6add5f
cm: Fixes and tweaks to the documentation generation task.
Ludovic Chabant <ludovic@chabant.com>
parents:
645
diff
changeset
|
13 "You need a virtual environment in the PieCrust repo.") |
be67fb6add5f
cm: Fixes and tweaks to the documentation generation task.
Ludovic Chabant <ludovic@chabant.com>
parents:
645
diff
changeset
|
14 pyexe = os.path.join('venv', 'bin', 'python') |
642
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
15 |
645
3060a6f26330
cm: Update the node modules before building the documentation.
Ludovic Chabant <ludovic@chabant.com>
parents:
642
diff
changeset
|
16 print("Update node modules") |
3060a6f26330
cm: Update the node modules before building the documentation.
Ludovic Chabant <ludovic@chabant.com>
parents:
642
diff
changeset
|
17 run("npm install") |
3060a6f26330
cm: Update the node modules before building the documentation.
Ludovic Chabant <ludovic@chabant.com>
parents:
642
diff
changeset
|
18 |
642
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
19 print("Update Bower packages") |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
20 run("bower update") |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
21 |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
22 print("Generate PieCrust version") |
647
be67fb6add5f
cm: Fixes and tweaks to the documentation generation task.
Ludovic Chabant <ludovic@chabant.com>
parents:
645
diff
changeset
|
23 run(pyexe + ' setup.py version') |
642
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
24 from piecrust.__version__ import APP_VERSION |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
25 version = APP_VERSION |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
26 |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
27 print("Baking documentation for version: %s" % version) |
647
be67fb6add5f
cm: Fixes and tweaks to the documentation generation task.
Ludovic Chabant <ludovic@chabant.com>
parents:
645
diff
changeset
|
28 if root_url: |
be67fb6add5f
cm: Fixes and tweaks to the documentation generation task.
Ludovic Chabant <ludovic@chabant.com>
parents:
645
diff
changeset
|
29 print("Using root URL: %s" % root_url) |
642
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
30 args = [ |
647
be67fb6add5f
cm: Fixes and tweaks to the documentation generation task.
Ludovic Chabant <ludovic@chabant.com>
parents:
645
diff
changeset
|
31 pyexe, 'chef.py', |
642
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
32 '--root', 'docs', |
647
be67fb6add5f
cm: Fixes and tweaks to the documentation generation task.
Ludovic Chabant <ludovic@chabant.com>
parents:
645
diff
changeset
|
33 '--config', 'dist'] |
be67fb6add5f
cm: Fixes and tweaks to the documentation generation task.
Ludovic Chabant <ludovic@chabant.com>
parents:
645
diff
changeset
|
34 if root_url: |
be67fb6add5f
cm: Fixes and tweaks to the documentation generation task.
Ludovic Chabant <ludovic@chabant.com>
parents:
645
diff
changeset
|
35 args += ['--config-set', 'site/root', root_url] |
be67fb6add5f
cm: Fixes and tweaks to the documentation generation task.
Ludovic Chabant <ludovic@chabant.com>
parents:
645
diff
changeset
|
36 args += [ |
642
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
37 'bake', |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
38 '-o', tmp_dir |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
39 ] |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
40 run(' '.join(args)) |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
41 |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
42 if out_dir: |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
43 print("Synchronizing %s" % out_dir) |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
44 if not os.path.isdir(out_dir): |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
45 os.makedirs(out_dir) |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
46 |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
47 tmp_dir = tmp_dir.rstrip('/') + '/' |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
48 out_dir = out_dir.rstrip('/') + '/' |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
49 run('rsync -av --delete %s %s' % (tmp_dir, out_dir)) |
79aefe82c6b6
cm: Move all scripts into a `garcon` package with `invoke` support.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
50 |