Skip to content

Commit e86bcd1

Browse files
Allow require.js by bundling all js dependencies UMD style (#167)
Co-authored-by: Chris Holdgraf <[email protected]> Co-authored-by: Robin Houdmeyers <[email protected]>
1 parent 1e8295d commit e86bcd1

File tree

10 files changed

+124
-8
lines changed

10 files changed

+124
-8
lines changed

docs/conf.py

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"sphinx.ext.autosummary",
3737
"numpydoc",
3838
"recommonmark",
39+
"jupyter_sphinx.execute",
3940
]
4041

4142
autosummary_generate = True

docs/demo/demo.rst

+18
Original file line numberDiff line numberDiff line change
@@ -475,3 +475,21 @@ Download Links
475475
==============
476476

477477
:download:`This long long long long long long long long long long long long long long long download link should be blue, normal weight text with a leading icon, and should wrap white-spaces <static/yi_jing_01_chien.jpg>`
478+
479+
HTML
480+
====
481+
482+
The HTML below shouldn't display, but it uses RequireJS to make sure that all
483+
works as expected. If the widgets don't show up, RequireJS may be broken.
484+
485+
.. jupyter-execute::
486+
487+
import plotly.io as pio
488+
import plotly.express as px
489+
import plotly.offline as py
490+
491+
pio.renderers.default = "notebook"
492+
493+
df = px.data.iris()
494+
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species", size="sepal_length")
495+
fig

docs/requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ sphinx
22
numpydoc
33
recommonmark
44
pandas
5+
jupyter_sphinx
6+
plotly
57
numpy

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
},
3131
"dependencies": {
3232
"bootstrap": "^4.4.1",
33-
"optimize-css-assets-webpack-plugin": "^5.0.3"
33+
"jquery": "3.4.1",
34+
"optimize-css-assets-webpack-plugin": "^5.0.3",
35+
"popper.js": "^1.16.1"
3436
}
3537
}

pydata_sphinx_theme/layout.html

-4
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,8 @@
1818
{%- endblock %}
1919

2020
{%- block extrahead %}
21-
2221
<meta name="viewport" content="width=device-width, initial-scale=1">
2322
<meta name="docsearch:language" content="en">
24-
25-
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
26-
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
2723
{%- endblock %}
2824

2925
{# Silence the sidebar's, relbar's #}

pydata_sphinx_theme/static/js/index.js

+75-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pydata_sphinx_theme/theme.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ google_analytics_id =
1313
show_prev_next = True
1414
search_bar_text = Search the docs ...
1515
search_bar_position = sidebar
16-
navigation_with_keys = True
16+
navigation_with_keys = True

src/js/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
require('jquery/dist/jquery');
2+
require('popper.js/dist/umd/popper');
3+
require("bootstrap/dist/js/bootstrap.bundle");
4+
5+
16
/**
27
* This file should be edited in ./src/js/index.js. After bundling the resulting file in ./pydata_sphinx_theme/static/js/index.js should never be manually changed.
38
* Edit ./src/js/index.js and run yarn build:dev or yarn build:production.

webpack.common.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const webpack = require('webpack');
12
const path = require('path');
23
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
34

@@ -40,5 +41,12 @@ module.exports = {
4041
},
4142
],
4243
},
43-
plugins: [new CleanWebpackPlugin()],
44+
plugins: [
45+
new CleanWebpackPlugin(),
46+
new webpack.ProvidePlugin({
47+
'$': "jquery",
48+
'jQuery': "jquery",
49+
'Popper': 'popper.js'
50+
}),
51+
],
4452
};

yarn.lock

+10
Original file line numberDiff line numberDiff line change
@@ -2895,6 +2895,11 @@ isstream@~0.1.2:
28952895
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
28962896
integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=
28972897

2898+
2899+
version "3.4.1"
2900+
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.4.1.tgz#714f1f8d9dde4bdfa55764ba37ef214630d80ef2"
2901+
integrity sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw==
2902+
28982903
js-base64@^2.1.8:
28992904
version "2.5.2"
29002905
resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.5.2.tgz#313b6274dda718f714d00b3330bbae6e38e90209"
@@ -3919,6 +3924,11 @@ pkg-dir@^3.0.0:
39193924
dependencies:
39203925
find-up "^3.0.0"
39213926

3927+
popper.js@^1.16.1:
3928+
version "1.16.1"
3929+
resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.16.1.tgz#2a223cb3dc7b6213d740e40372be40de43e65b1b"
3930+
integrity sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ==
3931+
39223932
portfinder@^1.0.25:
39233933
version "1.0.25"
39243934
resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.25.tgz#254fd337ffba869f4b9d37edc298059cb4d35eca"

0 commit comments

Comments
 (0)