@@ -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+
0 commit comments