diff garcon/documentation.py @ 647:be67fb6add5f

cm: Fixes and tweaks to the documentation generation task.
author Ludovic Chabant <ludovic@chabant.com>
date Mon, 15 Feb 2016 22:09:55 -0800
parents 3060a6f26330
children a409a7bb3948
line wrap: on
line diff
--- a/garcon/documentation.py	Sun Feb 14 23:58:35 2016 -0800
+++ b/garcon/documentation.py	Mon Feb 15 22:09:55 2016 -0800
@@ -4,12 +4,14 @@
 
 
 @task
-def gendocs(tmp_dir=None, out_dir=None):
+def gendocs(tmp_dir=None, out_dir=None, root_url=None):
     if not tmp_dir:
         tmp_dir = '_docs-counter'
 
-    print("Updating virtual environment")
-    run("pip install -r requirements.txt --upgrade")
+    if not os.path.isdir('venv'):
+        raise Exception(
+                "You need a virtual environment in the PieCrust repo.")
+    pyexe = os.path.join('venv', 'bin', 'python')
 
     print("Update node modules")
     run("npm install")
@@ -18,16 +20,20 @@
     run("bower update")
 
     print("Generate PieCrust version")
-    run('python setup.py version')
+    run(pyexe + ' setup.py version')
     from piecrust.__version__ import APP_VERSION
     version = APP_VERSION
 
     print("Baking documentation for version: %s" % version)
+    if root_url:
+        print("Using root URL: %s" % root_url)
     args = [
-            'python', 'chef.py',
+            pyexe, 'chef.py',
             '--root', 'docs',
-            '--config', 'dist',
-            '--config-set', 'site/root', '/piecrust/en/%s' % version,
+            '--config', 'dist']
+    if root_url:
+        args += ['--config-set', 'site/root', root_url]
+    args += [
             'bake',
             '-o', tmp_dir
             ]