forked from RunestoneInteractive/RunestoneComponents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
123 lines (104 loc) · 4.3 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
from .activecode import *
from .animation import *
from .assess import *
from .blockly import *
from .codelens import *
from .clickableArea import *
from .datafile import *
from .disqus import *
from .dragndrop import *
from .fitb import *
from .livecode import *
from .meta import *
from .parsons import *
from .poll import *
from .reveal import *
from .shortanswer import *
from .tabbedStuff import *
from .usageAssignment import *
from .video import *
from .server.chapternames import populateChapterInfo
import os, sys
def runestone_static_dirs():
basedir = os.path.dirname(__file__)
module_paths = [ x for x in os.listdir(basedir) if os.path.isdir(os.path.join(basedir,x))]
module_static_js = ['%s/js' % os.path.join(basedir,x) for x in module_paths if os.path.exists('%s/js' % os.path.join(basedir,x))]
module_static_css = ['%s/css' % os.path.join(basedir,x) for x in module_paths if os.path.exists('%s/css' % os.path.join(basedir,x))]
module_static_image = ['%s/images' % os.path.join(basedir,x) for x in module_paths if os.path.exists('%s/images' % os.path.join(basedir,x))]
module_static_bootstrap = ['%s/bootstrap' % os.path.join(basedir,x) for x in module_paths if os.path.exists('%s/bootstrap' % os.path.join(basedir,x))]
return module_static_js + module_static_css + module_static_image + module_static_bootstrap
def runestone_extensions():
basedir = os.path.dirname(__file__)
module_paths = [ x for x in os.listdir(basedir) if os.path.isdir(os.path.join(basedir,x))]
modules = [ 'runestone.{}'.format(x) for x in module_paths if os.path.exists('{}/__init__.py'.format(os.path.join(basedir,x)))]
modules.remove('runestone.server')
modules.remove('runestone.common')
return modules
from paver.easy import task, cmdopts, sh
from sphinxcontrib import paverutils
@task
@cmdopts([
('all','a','rebuild everything'),
('outputdir=', 'o', 'output static files here'),
('masterurl=', 'u', 'override the default master url'),
('masterapp=', 'p', 'override the default master app')
])
def build(options):
if 'all' in options.build:
options['force_all'] = True
options['freshenv'] = True
try:
bi = sh('git describe --long',capture=True)[:-1]
bnum = bi.split('-')[0]
options.build.template_args["build_info"] = bnum
except:
bi = "unknown-0-0"
options.build.template_args["build_info"] = 'unknown'
with open('build_info','w') as bif:
bif.write(bi)
bif.write("\n")
if 'outputdir' in options.build:
options.build.outdir = options.build.outputdir
if 'masterurl' in options.build:
options.build.template_args['course_url'] = options.build.masterurl
if 'masterapp' in options.build:
options.build.template_args['appname'] = options.build.masterapp
print('Building into ', options.build.outdir)
rc = paverutils.run_sphinx(options,'build')
try:
if os.path.exists(os.path.join(options.build.sourcedir,'toc.rst')):
idxfile = os.path.join(options.build.sourcedir,'toc.rst')
else:
idxfile = os.path.join(options.build.sourcedir,'index.rst')
populateChapterInfo(options.build.project_name, idxfile)
print('Creating Chapter Information')
except ImportError as e:
print('Chapter information database population skipped, This is OK for a standalone build.',e)
except Exception as e:
print('Chapter Information Creation Failed with', e)
if rc == 0:
print("Done, {} build successful".format(options.build.project_name))
else:
print("Error in building {}".format(options.build.project_name) )
cmap = {'activecode': ActiveCode,
'mchoice': MChoice,
'fillintheblank': FillInTheBlank,
'blank': Blank,
'timed': TimedDirective,
'qnum': QuestionNumber,
'codelens': Codelens,
'clickablearea': ClickableArea,
'datafile': DataFile,
'disqus': DisqusDirective,
'dragndrop': DragNDrop,
'parsonsprob': ParsonsProblem,
'poll': Poll,
'reveal': RevealDirective,
'shortanswer': JournalDirective,
'tabbed': TabbedStuffDirective,
'tab': TabDirective,
'video': Video,
'youtube': Youtube,
'vimeo': Vimeo,
'usageassignment': usageAssignment
}