Skip to content

Commit 76f7f85

Browse files
committed
simplify holoviews js and css
1 parent 6fca822 commit 76f7f85

3 files changed

Lines changed: 20 additions & 28 deletions

File tree

docs/source/_static/jquery.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// This file is empty because we are already loading jQuery with holoviews in the <head>

docs/source/_templates/layout.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{% extends "!layout.html" %}
2+
{% block extrahead %}
3+
{%- for scriptfile in holoviews_js_files %}
4+
{{ js_tag(scriptfile) }}
5+
{%- endfor %}
6+
{% endblock %}

docs/source/conf.py

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
#
8888
html_theme = 'sphinx_rtd_theme'
8989

90+
9091
# Theme options are theme-specific and customize the look and feel of a theme
9192
# further. For a list of options available for each theme, see the
9293
# documentation.
@@ -128,38 +129,22 @@
128129
}
129130

130131

131-
# -- Add Holoviews js and css ------------------------------------------------
132-
133-
def setup(app):
132+
def get_holoviews_js_css():
134133
from holoviews.plotting import Renderer
134+
dependencies = {**Renderer.core_dependencies,
135+
**Renderer.extra_dependencies}
136+
required = ['jQueryUI', 'jQuery', 'require']
137+
js = [url for name in required for url in dependencies[name].get('js', [])]
138+
css = [url for name in required for url in dependencies[name].get('css', [])]
139+
return js, css
135140

136-
hv_js, hv_css = Renderer.html_assets(
137-
extras=False, backends=[], script=True)
138-
139-
fname_css = 'holoviews.css'
140-
fname_js = 'holoviews.js'
141-
static_dir = 'source/_static'
142141

143-
os.makedirs(static_dir, exist_ok=True)
142+
js, css = get_holoviews_js_css()
143+
html_context = {'holoviews_js_files': js}
144144

145-
with open(f'{static_dir}/{fname_css}', 'w') as f:
146-
hv_css = hv_css.split('<style>')[1].replace('</style>', '')
147-
f.write(hv_css)
148145

149-
with open(f'{static_dir}/{fname_js}', 'w') as f:
150-
f.write(hv_js)
151-
152-
app.add_stylesheet(fname_css)
153-
app.add_javascript(fname_js)
154-
155-
dependencies = {**Renderer.core_dependencies, **Renderer.extra_dependencies}
156-
for name, type_url in dependencies.items():
157-
if name in ['bootstrap']:
158-
continue
159-
160-
for url in type_url.get('js', []):
161-
app.add_javascript(url)
162-
for url in type_url.get('css', []):
163-
app.add_stylesheet(url)
146+
def setup(app):
147+
for url in css:
148+
app.add_stylesheet(url)
164149

165150
app.add_javascript("https://unpkg.com/@jupyter-widgets/html-manager@0.14.4/dist/embed-amd.js")

0 commit comments

Comments
 (0)