Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit eda5b64

Browse files
committed
Move build task definition into the runestone package
1 parent a6f2093 commit eda5b64

File tree

2 files changed

+50
-29
lines changed

2 files changed

+50
-29
lines changed

runestone/__init__.py

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,52 @@ def runestone_extensions():
2929
basedir = os.path.dirname(__file__)
3030
module_paths = [ x for x in os.listdir(basedir) if os.path.isdir(os.path.join(basedir,x))]
3131
modules = [ 'runestone.{}'.format(x) for x in module_paths if os.path.exists('{}/__init__.py'.format(os.path.join(basedir,x)))]
32-
print("MODULES = ", modules)
3332
return modules
33+
34+
from paver.easy import task, cmdopts, sh
35+
from sphinxcontrib import paverutils
36+
37+
@task
38+
@cmdopts([
39+
('all','a','rebuild everything'),
40+
('outputdir=', 'o', 'output static files here'),
41+
('masterurl=', 'u', 'override the default master url'),
42+
('masterapp=', 'p', 'override the default master app')
43+
])
44+
def build(options):
45+
if 'all' in options.build:
46+
options['force_all'] = True
47+
options['freshenv'] = True
48+
49+
try:
50+
bi = sh('git describe --long',capture=True)[:-1]
51+
bi = bi.split('-')[0]
52+
options.build.template_args["build_info"] = bi
53+
except:
54+
options.build.template_args["build_info"] = 'unknown'
55+
56+
if 'outputdir' in options.build:
57+
options.build.outdir = options.build.outputdir
58+
59+
if 'masterurl' in options.build:
60+
options.build.template_args['course_url'] = options.build.masterurl
61+
62+
if 'masterapp' in options.build:
63+
options.build.template_args['appname'] = options.build.masterapp
64+
65+
print('Building into ', options.build.outdir)
66+
rc = paverutils.run_sphinx(options,'build')
67+
68+
69+
try:
70+
from chapternames import populateChapterInfo
71+
populateChapterInfo(options.build.project_name, "%s/index.rst" % options.build.sourcedir)
72+
print('Creating Chapter Information')
73+
except ImportError:
74+
print('Chapter information database population skipped, This is OK for a standalone build.')
75+
76+
if rc == 0:
77+
print("Done, {} build successful".format(options.build.project_name))
78+
else:
79+
print("Error in building {}".format(options.build.project_name) )
80+

runestone/common/project_template/pavement.tmpl

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ options(
2121
sourcedir="_sources",
2222
outdir="%(build_dir)s/%(project_name)s",
2323
confdir=".",
24+
project_name = "%(project_name)s",
2425
template_args={'course_id': '%(project_name)s',
2526
'login_required':'%(login_req)s',
2627
'appname':master_app,
@@ -32,32 +33,5 @@ options(
3233
)
3334
)
3435

35-
36-
@task
37-
@cmdopts([
38-
('all','a','rebuild everything'),
39-
('outputdir=', 'o', 'output static files here'),
40-
('masterurl=', 'u', 'override the default master url'),
41-
('masterapp=', 'p', 'override the default master app'),
42-
])
43-
def build(options):
44-
if 'all' in options.build:
45-
options['force_all'] = True
46-
options['freshenv'] = True
47-
48-
# bi = sh('git describe --long',capture=True)[:-1]
49-
# bi = bi.split('-')[0]
50-
# options.build.template_args["build_info"] = bi
51-
52-
if 'outputdir' in options.build:
53-
options.build.outdir = options.build.outputdir
54-
55-
if 'masterurl' in options.build:
56-
options.build.template_args['course_url'] = options.build.masterurl
57-
58-
if 'masterapp' in options.build:
59-
options.build.template_args['appname'] = options.build.masterapp
60-
61-
print('Building into ', options.build.outdir)
62-
paverutils.run_sphinx(options,'build')
36+
from runestone import build # build is called implicitly by the paver driver.
6337

0 commit comments

Comments
 (0)