Open jorisvandenbossche opened 4 years ago
This is timely, given the comment I just made in https://github.com/executablebooks/meta/issues/119#issuecomment-683670162.
You should probably use the mathjax approach to only add JS (but CSS in this case) given an env value you set when you copy the CSS: https://github.com/sphinx-doc/sphinx/blob/a16cca27ef1415ff271084f156e0fb33ccfbefae/sphinx/ext/mathjax.py#L84
Tricky: injecting css during build prevents users from overriding it since it is then inserted after the user-provided css.
This change is due to fixing #149
The original issue report was about jupyter-sphinx.css, which could still be kept in the app setup. Of course the same issue applies to thebelab.css, but that is maybe less common to want to override?
This comment https://github.com/sphinx-doc/sphinx/issues/6241#issuecomment-705070598 contains an implementation of conditional js/css inclusion, however I believe the proper way to address this issue is to switch to sphinx-thebe #137
Still, we may want to use the same logic for widgets code.
Using jupyter-sphinx pydata-sphinx-theme docs (https://pydata-sphinx-theme.readthedocs.io/en/latest/), I noticed that it gives errors in the browser console related to thebe css/js:
This seems to be caused because it is added to the html output of sphinx. From the source of the html of the url linked above:
But this
thebelab.css
is not actually to the_static
dir of the build html. And thus giving a 404 error.Based on a quick look, I think this is because here the thebelab css is only copied if there is a configuration active:
https://github.com/jupyter/jupyter-sphinx/blob/43280f89b1558b043aa51e7b3b007db2fe834b89/jupyter_sphinx/__init__.py#L122-L132
but it gets always registered to sphinx regardless of that configuration option:
https://github.com/jupyter/jupyter-sphinx/blob/43280f89b1558b043aa51e7b3b007db2fe834b89/jupyter_sphinx/__init__.py#L284-L287