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

Commit cc579af

Browse files
Make setup.custom_css/js_files add autoversioned files. Add example in conf template.
1 parent f70cc21 commit cc579af

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

runestone/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,12 @@ def setup(app):
145145
print("No custom CSS files")
146146
try:
147147
for c in setup.custom_js_files:
148-
app.add_js_file(c)
148+
if isinstance(c, dict):
149+
#peel off filename, pass rest of key/values on as kwargs
150+
filename = c.pop("file")
151+
app.add_autoversioned_javascript(filename, **c)
152+
else:
153+
app.add_autoversioned_javascript(c)
149154
print("Adding custom Javascript")
150155
except AttributeError:
151156
print("No custom js files")

runestone/common/project_template/conf.tmpl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,16 @@ html_theme_options = {
208208
# creating your own folder and modifying this path.
209209
# Add any paths that contain custom themes here, relative to this directory.
210210
html_theme_path = [pkg_resources.resource_filename('runestone', 'common/project_template/_templates/plugin_layouts')]
211-
211+
# List of extra stylesheets that should be added to all html pages
212+
# Files must be on a path contained in html_static_path
213+
#setup.custom_css_files = ["sample.css", "sample2.css"]
214+
215+
# List of extra js files that should be added to all html pages
216+
# Items may be a file name or a dict with properties {"file":FILENAME, "key1", "value1", "key2, "value2"...}
217+
# in which case file should have the file name and other key/value pairs are used as attrs
218+
# on the script tag. The sample below will set sample2.js's script tag to have the defer attr
219+
# Files must be on a path contained in html_static_path
220+
#setup.custom_js_files = ["sample.css", {"file": "sample2.js", "defer": ""}]
212221
213222
# The name for this set of Sphinx documents. If None, it defaults to
214223
# "<project> v<release> documentation".

0 commit comments

Comments
 (0)