77from .animation import Animation
88from .mchoice import MChoice , QuestionNumber
99from .blockly import Blockly
10+ from .quizly import Quizly
11+ from .khanex import Khanex
1012from .codelens import Codelens
1113from .clickableArea import ClickableArea
1214from .datafile import DataFile
@@ -51,11 +53,7 @@ def runestone_static_dirs():
5153 module_static_css .append (os .path .join (basedir , "webgldemo" , "css" ))
5254 module_static_css .append (os .path .join (basedir , "matrixeq" , "css" ))
5355 module_static_css .append (os .path .join (basedir , "lp" , "css" ))
54- return (
55- module_static_js
56- + module_static_css
57- + CodeChat .CodeToRest .html_static_path ()
58- )
56+ return module_static_js + module_static_css + CodeChat .CodeToRest .html_static_path ()
5957
6058
6159# runestone_extensions()
@@ -76,6 +74,7 @@ def runestone_extensions():
7674 modules .insert (0 , modules .pop (modules .index ("runestone.common" )))
7775 return modules
7876
77+
7978# setup_js_defer(app, pagename, templatexname, context, doctree)
8079# -----------------------
8180# Used to inspect js right before it is rendered to page so that
@@ -85,16 +84,20 @@ def js_defer(script_files):
8584 for js in sorted (script_files ):
8685 if app .config .html_defer_js :
8786 # Files added from Runestone should already have defer set - so just add it to sphinx based ones
88- to_defer = ["_static/jquery.js" , "_static/underscore.js" ,"_static/doctools.js" ]
87+ to_defer = [
88+ "_static/jquery.js" ,
89+ "_static/underscore.js" ,
90+ "_static/doctools.js" ,
91+ ]
8992 if isinstance (js , JavaScript ) and js in to_defer :
9093 js .attributes ["defer" ] = ""
9194 else :
92- #config flag not set, prevent all deferrals
95+ # config flag not set, prevent all deferrals
9396 if isinstance (js , JavaScript ):
9497 js .attributes .pop ("defer" , None )
95- return ''
98+ return ""
9699
97- context [' js_defer' ] = js_defer
100+ context [" js_defer" ] = js_defer
98101
99102
100103# setup(app)
@@ -108,7 +111,13 @@ def setup(app):
108111 we wanted to do for all projects.
109112 """
110113 # Include JS and CSS produced by webpack. See `webpack static imports <webpack_static_imports>`_.
111- with open (pkg_resources .resource_filename ("runestone" , "dist/webpack_static_imports.json" ), "r" , encoding = "utf-8" ) as f :
114+ with open (
115+ pkg_resources .resource_filename (
116+ "runestone" , "dist/webpack_static_imports.json"
117+ ),
118+ "r" ,
119+ encoding = "utf-8" ,
120+ ) as f :
112121 wb_imports = json .load (f )
113122 script_files = wb_imports ["js" ]
114123 _css_files = css_files + wb_imports ["css" ]
@@ -124,9 +133,26 @@ def setup(app):
124133 except ExtensionError :
125134 app .add_css_file (cssfile )
126135
136+ # projects can define their own custom css or js files to include
137+ # But since this is imported into their conf.py authors must
138+ # define them as attributes of the setup function
139+ # ``setup.custom_xxx_files``
140+ try :
141+ for c in setup .custom_css_files :
142+ app .add_css_file (c )
143+ print ("Adding custom CSS files" )
144+ except AttributeError :
145+ print ("No custom CSS files" )
146+ try :
147+ for c in setup .custom_js_files :
148+ app .add_js_file (c )
149+ print ("Adding custom Javascript" )
150+ except AttributeError :
151+ print ("No custom js files" )
152+
127153 app .config .html_static_path .append ("dist/" )
128- app .add_config_value ("html_defer_js" , False , ' env' )
129- app .connect (' html-page-context' , setup_js_defer )
154+ app .add_config_value ("html_defer_js" , False , " env" )
155+ app .connect (" html-page-context" , setup_js_defer )
130156
131157
132158def get_master_url ():
@@ -217,6 +243,7 @@ def build(options):
217243 "dragndrop" : DragNDrop ,
218244 "parsonsprob" : ParsonsProblem ,
219245 "poll" : Poll ,
246+ "quizly" : Quizly ,
220247 "reveal" : RevealDirective ,
221248 "selectquestion" : SelectQuestion ,
222249 "shortanswer" : JournalDirective ,
0 commit comments