comparison garcon/documentation.py @ 1066:bd6cc78666b7

cm: Update `garcon`'s documentation script to work with latest toolchain.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 13 Feb 2018 21:52:51 -0800
parents 22cf13b86cc3
children
comparison
equal deleted inserted replaced
1065:e00ff3dcb5ec 1066:bd6cc78666b7
1 import os 1 import os
2 import os.path 2 import os.path
3 import re 3 import re
4 import sys
5 from invoke import task, run 4 from invoke import task, run
6 5
7 6
8 pyver_re = re.compile('^Python (?P<maj>\d)\.(?P<min>\d)\.(?P<pat>\d)$') 7 pyver_re = re.compile('^Python (?P<maj>\d)\.(?P<min>\d)\.(?P<pat>\d)$')
9 8
12 'tmp_dir': "The directory in which to bake the docs temporarily.", 11 '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 " 12 'out_dir': "If the bake is successful, the directory in which to deploy "
14 "the files at the end.", 13 "the files at the end.",
15 'root_url': "Set the docs site root URL to this if needed.", 14 '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 " 15 'venv_dir': "The directory of the virtual environment to use to run "
17 "PieCrust." 16 "PieCrust. If none, will create a new one under `venv`."
18 }) 17 })
19 def gendocs(ctx, tmp_dir=None, out_dir=None, root_url=None, venv_dir=None): 18 def gendocs(ctx, tmp_dir=None, out_dir=None, root_url=None, venv_dir=None):
20 base_dir = os.path.abspath( 19 base_dir = os.path.abspath(
21 os.path.join(os.path.dirname(__file__), '..')) 20 os.path.join(os.path.dirname(__file__), '..'))
22 os.chdir(base_dir) 21 os.chdir(base_dir)
23 22
24 if not tmp_dir: 23 if not tmp_dir:
25 tmp_dir = os.path.join(base_dir, '_docs-counter') 24 tmp_dir = os.path.join(base_dir, '_docs-counter')
26 25
44 print("Using: %s" % pipver_out.stdout.strip()) 43 print("Using: %s" % pipver_out.stdout.strip())
45 44
46 npmver_out = run('npm --version', hide=True) 45 npmver_out = run('npm --version', hide=True)
47 print("Using: npm %s" % npmver_out.stdout.strip()) 46 print("Using: npm %s" % npmver_out.stdout.strip())
48 47
49 bowerver_out = run('bower --version', hide=True)
50 print("Using: bower %s" % bowerver_out.stdout.strip())
51
52 print("Updating virtual environment.") 48 print("Updating virtual environment.")
53 run("%s install pip -U" % pipexe) 49 run("%s install pip -U" % pipexe)
54 run("%s install -r requirements.txt" % pipexe) 50 run("%s install -r requirements.txt" % pipexe)
55 run("%s install -r dev-requirements.txt" % pipexe)
56 51
57 print("Update node modules") 52 print("Update node modules")
58 run("npm install") 53 run("npm install")
59 54
60 print("Update Bower packages") 55 this_pwd = os.path.dirname(os.path.dirname(__file__))
61 run("bower update") 56 node_bin = os.path.join(this_pwd, 'node_modules', '.bin')
57 print("Adding '%s' to the PATH" % node_bin)
58 os.environ['PATH'] = (node_bin + os.pathsep + os.environ['PATH'])
62 59
63 print("Generate PieCrust version") 60 print("Generate PieCrust version")
64 run(pyexe + ' setup.py version') 61 run(pyexe + ' setup.py version')
65 from piecrust.__version__ import APP_VERSION 62 from piecrust.__version__ import APP_VERSION
66 version = APP_VERSION 63 version = APP_VERSION
67 64
68 print("Baking documentation for version: %s" % version) 65 print("Baking documentation for version: %s" % version)
69 if root_url: 66 if root_url:
70 print("Using root URL: %s" % root_url) 67 print("Using root URL: %s" % root_url)
71 args = [ 68 args = [
72 pyexe, 'chef.py', 69 pyexe, 'chef.py',
73 '--root', 'docs', 70 '--root', 'docs',
74 '--config', 'dist'] 71 '--config', 'dist']
75 if root_url: 72 if root_url:
76 args += ['--config-set', 'site/root', root_url] 73 args += ['--config-set', 'site/root', root_url]
77 args += [ 74 args += [
78 'bake', 75 'bake',
79 '-o', tmp_dir 76 '-o', tmp_dir
80 ] 77 ]
81 run(' '.join(args)) 78 run(' '.join(args))
82 79
83 if out_dir: 80 if out_dir:
84 print("Synchronizing %s" % out_dir) 81 print("Synchronizing %s" % out_dir)
85 if not os.path.isdir(out_dir): 82 if not os.path.isdir(out_dir):