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

Commit 065d8f5

Browse files
authored
Merge pull request #1233 from ascholerChemeketa/theme_override_cleanup
Theme override cleanup
2 parents 945f583 + 8b1bcda commit 065d8f5

7 files changed

Lines changed: 48 additions & 49 deletions

File tree

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ Our goal is to have unit tests which rely on Selenium (a library that helps simu
162162

163163
**To run tests:**
164164

165-
* Make sure the directory containing the PhantomJS executable is in your ``PATH`` environment variable. e.g. ``PATH=$PATH:path/to/virtualenv/directory/where/it/is/here`` at your command line (or edit your ``.bash_profile``). It should live in the site-packages/selenium/webdriver/ directory of your virtualenv.
165+
* Make sure the directory containing the ChromeDriver executable is in your ``PATH`` environment variable. e.g. ``PATH=$PATH:path/to/chromedriver`` at your command line (or edit your ``.bash_profile``).
166166

167167
* Check out the existing tests, e.g. the ``test_question.py`` file that tests the Question directive, which you can find at the path ``/runestone/question/test/test_question.py``, for an example.
168168

runestone/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def runestone_static_dirs():
4848
module_static_js.append(os.path.join(basedir, "codelens", "js"))
4949
module_static_js.append(os.path.join(basedir, "webgldemo", "js"))
5050
module_static_js.append(os.path.join(basedir, "matrixeq", "js"))
51-
module_static_css = [os.path.join(basedir, "common", "css", "sphinx")]
51+
module_static_css = []
5252
module_static_css.append(os.path.join(basedir, "accessibility", "css"))
5353
module_static_css.append(os.path.join(basedir, "webgldemo", "css"))
5454
module_static_css.append(os.path.join(basedir, "matrixeq", "css"))
@@ -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")
@@ -225,8 +230,6 @@ def build(options):
225230
css_files = [
226231
# Generated from a template, so it can't be directly included in the webpack.
227232
"bootstrap-sphinx.css",
228-
# Deliberately excluded, so it can be overridden by a user-supplied CSs file.
229-
"theme-overrides.css",
230233
]
231234

232235

runestone/common/css/sphinx/theme-overrides.css

Lines changed: 0 additions & 5 deletions
This file was deleted.

runestone/common/project_template/_sources/index.rst

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,14 @@ Now feel free to modify this file to start creating your own interactive page.
8484
Section 4: Theme
8585
:::::::::::::::::::
8686

87-
You can override the style rules in the default theme by adding css rules to a file named **theme-overrides.css** (the filename is important - this will replace an existing file). Make sure the file's directory is part of the ``html_static_path``. You can do so by placing it in a folder **_static**, then modifying ``html_static_path`` in conf.py to include that folder:
88-
89-
.. code::
90-
91-
html_static_path = runestone_static_dirs() + ['_static']
87+
You can add your own CSS or JS files to every page of a book by modifying ``setup.custom_css_files`` or ``setup.custom_js_files`` in conf.py.
9288

89+
If you want to do more significant changes to the theme, you should copy the files you wish to modify from
90+
the runestone/common/project/template/sphinx_bootstrap to a directory like ``_templates/``. Then make sure
91+
the ``templates_path`` points to them in your conf.py.
9392

94-
If you want to do more significant changes to the theme, you should copy the files in the runestone/common/project/template/sphinx_bootstrap to a directory like ``_templates/my_theme``. Then make sure these values are set in conf.py:
93+
conf.py:
9594

9695
.. code::
9796
98-
html_theme_path = ["_templates"]
99-
html_theme = 'my_theme'
97+
templates_path = ["_templates"]

runestone/common/project_template/_templates/plugin_layouts/sphinx_bootstrap/layout.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,9 @@
334334
<p>
335335
{%- if show_copyright %}
336336
{%- if hasdoc('copyright') %}
337-
{% trans path=pathto('copyright'), copyright=copyright|e %}&copy; <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}
337+
{% trans path=pathto('copyright'), copyright=copyright %}&copy; <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}
338338
{%- else %}
339-
{% trans copyright=copyright|e %}&copy; Copyright {{ copyright }}.{% endtrans %}
339+
{% trans copyright=copyright %}&copy; Copyright {{ copyright }}.{% endtrans %}
340340
{%- endif %}
341341
{%- endif %}
342342
{%- if last_updated %}

runestone/common/project_template/conf.tmpl

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ extensions = ['sphinx.ext.mathjax'] + runestone_extensions()
3434

3535
#,'runestone.video','runestone.reveal','runestone.poll','runestone.tabbedStuff','runestone.disqus','runestone.codelens','runestone.activecode', 'runestone.assess', 'runestone.animation','runestone.meta', 'runestone.parsons', 'runestone.blockly', 'runestone.livecode','runestone.accessibility']
3636

37-
# This sets up your project to use the defaults. If you want to create a custom set of templates
38-
# for your own project you can over ride them by creating your own _templates folder
39-
templates_path = [pkg_resources.resource_filename('runestone', 'common/project_template/_templates')]
40-
4137
# The suffix of source filenames.
4238
source_suffix = '.rst'
4339

@@ -154,14 +150,22 @@ inline_highlight_literals = False
154150

155151
# -- Options for HTML output ---------------------------------------------------
156152

157-
# The theme to use for HTML and HTML Help pages. See the documentation for
158-
# a list of builtin themes.
153+
# The theme to use for HTML and HTML Help pages. sphinx_bootstrap is provided with
154+
# Runestone. Other themes are built into sphinx:
155+
# https://www.sphinx-doc.org/en/master/usage/theming.html?highlight=html_theme_path#using-a-theme
159156
html_theme = 'sphinx_bootstrap'
160157

158+
# If using a non-sphinx theme, the path to the theme folder must be in this list
159+
html_theme_path = [pkg_resources.resource_filename('runestone', 'common/project_template/_templates/plugin_layouts')]
160+
161+
# To override individual templates from the theme, you can make a directory and add its path
162+
# relative to this file to the templates_path list. In it, place copies of any template files
163+
# you wish to override - your template file(s) will be used instead of the default ones from the theme
164+
#templates_path = ['_templates']
165+
161166
# Theme options are theme-specific and customize the look and feel of a theme
162167
# further. For a list of options available for each theme, see the
163168
# documentation.
164-
#html_theme_options = {'nosidebar': 'true'}
165169
html_theme_options = {
166170
# Navigation bar title. (Default: ``project`` value)
167171
'navbar_title': "%(project_title)s",
@@ -203,12 +207,27 @@ html_theme_options = {
203207
#'bootswatch_theme': "slate",
204208
}
205209

210+
# Additional templates that should be rendered to pages, maps page names to
211+
# template names.
212+
# https://www.sphinx-doc.org/en/master/usage/configuration.html?highlight=html_sidebars#confval-html_additional_pages
213+
#html_additional_pages = {}
214+
215+
# A list of paths that contain custom static files (such as style sheets) here,
216+
# relative to this directory. They are copied after the builtin static files,
217+
# so a file named "default.css" will overwrite the builtin "default.css".
218+
# Example: html_static_path = runestone_static_dirs() + ['_static', 'other']
219+
html_static_path = runestone_static_dirs()
206220

207-
# This is set up to use the default runestone themes, you can override them by
208-
# creating your own folder and modifying this path.
209-
# Add any paths that contain custom themes here, relative to this directory.
210-
html_theme_path = [pkg_resources.resource_filename('runestone', 'common/project_template/_templates/plugin_layouts')]
221+
# List of extra stylesheets that should be added to all html pages
222+
# Files must be on a path contained in html_static_path
223+
#setup.custom_css_files = ["sample.css", "sample2.css"]
211224

225+
# List of extra js files that should be added to all html pages
226+
# Items may be a file name or a dict with properties {"file":FILENAME, "key1", "value1", "key2, "value2"...}
227+
# in which case file should have the file name and other key/value pairs are used as attrs
228+
# on the script tag. The sample below will set sample2.js's script tag to have the defer attr
229+
# Files must be on a path contained in html_static_path
230+
#setup.custom_js_files = ["sample.css", {"file": "sample2.js", "defer": ""}]
212231
213232
# The name for this set of Sphinx documents. If None, it defaults to
214233
# "<project> v<release> documentation".
@@ -217,23 +236,14 @@ html_title = 'Runestone Interactive Overview'
217236
# A shorter title for the navigation bar. Default is the same as html_title.
218237
html_short_title ='Runestone Interactive Overview'
219238
220-
# The name of an image file (relative to this directory) to place at the top
221-
# of the sidebar.
222-
223-
# logo is included in layout file
239+
# Logo is included at the top of the page
224240
#html_logo = "../source/_static/logo_small.png"
225241
226242
# The name of an image file (within the static path) to use as favicon of the
227243
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
228244
# pixels large.
229245
#html_favicon = None
230246
231-
# Add any paths that contain custom static files (such as style sheets) here,
232-
# relative to this directory. They are copied after the builtin static files,
233-
# so a file named "default.css" will overwrite the builtin "default.css".
234-
235-
html_static_path = runestone_static_dirs()
236-
237247
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
238248
# using the given strftime format.
239249
#html_last_updated_fmt = '%%b %%d, %%Y'
@@ -242,13 +252,6 @@ html_static_path = runestone_static_dirs()
242252
# typographically correct entities.
243253
#html_use_smartypants = True
244254
245-
# Custom sidebar templates, maps document names to template names.
246-
#html_sidebars = {}
247-
248-
# Additional templates that should be rendered to pages, maps page names to
249-
# template names.
250-
#html_additional_pages = {}
251-
252255
# If false, no module index is generated.
253256
#html_domain_indices = True
254257

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = (env, argv) => {
2424
rules: [
2525
{
2626
test: /\.css$/i,
27-
use: [argv.mode === "development" ? "style-loader" : MiniCssExtractPlugin.loader, "css-loader"],
27+
use: [MiniCssExtractPlugin.loader, "css-loader"],
2828
},
2929
{
3030
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i,

0 commit comments

Comments
 (0)