Mercurial > piecrust2
comparison garcon/documentation.py @ 670:a409a7bb3948
cm: Improve documentation generation script.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 03 Mar 2016 22:38:55 -0800 |
parents | be67fb6add5f |
children | d4b9d86d3d6f |
comparison
equal
deleted
inserted
replaced
669:65706804e1de | 670:a409a7bb3948 |
---|---|
1 import os | 1 import os |
2 import os.path | 2 import os.path |
3 import re | |
4 import sys | |
3 from invoke import task, run | 5 from invoke import task, run |
4 | 6 |
5 | 7 |
6 @task | 8 pyver_re = re.compile('^Python (?P<maj>\d)\.(?P<min>\d)\.(?P<pat>\d)$') |
7 def gendocs(tmp_dir=None, out_dir=None, root_url=None): | 9 |
10 | |
11 @task(help={ | |
12 'tmp_dir': "The directory in which to bake the docs temporarily.", | |
13 'out_dir': "If the bake is successful, the directory in which to deploy " | |
14 "the files at the end.", | |
15 'root_url': "Set the docs site root URL to this if needed.", | |
16 'venv_dir': "The directory of the virtual environment to use to run " | |
17 "PieCrust." | |
18 }) | |
19 def gendocs(tmp_dir=None, out_dir=None, root_url=None, venv_dir=None): | |
20 base_dir = os.path.abspath( | |
21 os.path.join(os.path.dirname(__file__), '..')) | |
22 os.chdir(base_dir) | |
23 | |
8 if not tmp_dir: | 24 if not tmp_dir: |
9 tmp_dir = '_docs-counter' | 25 tmp_dir = os.path.join(base_dir, '_docs-counter') |
10 | 26 |
11 if not os.path.isdir('venv'): | 27 if not venv_dir: |
28 venv_dir = os.path.join(base_dir, 'venv') | |
29 | |
30 if sys.prefix == venv_dir: | |
12 raise Exception( | 31 raise Exception( |
13 "You need a virtual environment in the PieCrust repo.") | 32 "Don't run this script in the PieCrust virtual environment.") |
14 pyexe = os.path.join('venv', 'bin', 'python') | 33 |
34 if not os.path.isdir(venv_dir): | |
35 print("Creating virtual environment in: %s" % venv_dir) | |
36 run('virtualenv -p python3 "%s"' % venv_dir) | |
37 | |
38 pyexe = os.path.join(venv_dir, 'bin', 'python') | |
39 pyver_out = run('%s --version' % pyexe, hide=True) | |
40 if pyver_out.failed or not pyver_out.stdout.startswith('Python 3.'): | |
41 raise Exception("Can't run Python3 from: %s" % pyexe) | |
42 print("Using: %s" % pyver_out.stdout.strip()) | |
43 | |
44 pipexe = os.path.join(venv_dir, 'bin', 'pip') | |
45 pipver_out = run('%s --version' % pipexe, hide=True) | |
46 if pipver_out.failed or '(python 3.' not in pipver_out.stdout: | |
47 raise Exception("Can't run pip3 from: %s" % pipexe) | |
48 print("Using: %s" % pipver_out.stdout.strip()) | |
49 | |
50 npmver_out = run('npm --version', hide=True) | |
51 print("Using: npm %s" % npmver_out.stdout.strip()) | |
52 | |
53 bowerver_out = run('bower --version', hide=True) | |
54 print("Using: bower %s" % bowerver_out.stdout.strip()) | |
55 | |
56 print("Updating virtual environment.") | |
57 run("%s install pip -U" % pipexe) | |
58 run("%s install -r requirements.txt" % pipexe) | |
59 run("%s install -r dev-requirements.txt" % pipexe) | |
15 | 60 |
16 print("Update node modules") | 61 print("Update node modules") |
17 run("npm install") | 62 run("npm install") |
18 | 63 |
19 print("Update Bower packages") | 64 print("Update Bower packages") |