-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Widget, requirejs - troublesome again #519
Comments
Thanks for the report! It is indeed unfortunate that I moved Luckily, in Sphinx you can customize everything. Instead of using the Python API to inject your {% extends "!layout.html" %}
{% block scripts %}
{{ super() }}
<script src="{{ pathto('_static/embed-periodictable.js', 1) }}"></script>
{% endblock %} This way, your Does that work for you?
It would be great if you could provide a PR with improved documentation! |
Thanks for the feedback @mgeier I unfortunately did not have time to test the fix - but it sounds correct. I added some pointers in the documentation. Hope it is meaningful. |
Jupyter widget provides a nice cookiecutter template that provide a template for generating documentation. The template preloads
jupyter-sphinx
andnbsphinx
. But if you dropjupyter-sphinx
, the widgets are not renderer (i did not found a workaround). And if you keep it the widgets are rendered twice (this can be fixed xref #378).jupyter-sphinx
is needed because when activating the two extensions (and applying #378), the JS scripts order is (using https://osscar-docs.readthedocs.io/en/latest/widgets/periodictable.html):The trouble is the JS ordering (again 😭 ):
jupyter-sphinx
../_static/embed-periodictable.js
nbsphinx
(only requirejs appears as jupyter widget was drop using Widget output is duplicated #378 fix)If
jupyter-sphinx
is removed, requireJS is loaded after the local widget bundle. Therefore those widgets are not loaded (error: define is undefined).For now the best configuration I found is to use
jupyter-sphinx
just to ensure requireJS to be loaded before the local widget bundle. And I setnbsphinx_requirejs_path
andnbsphinx_widgets_path
to""
to ensure they are not loaded twice.I know that requireJS has been moved to a later stage following #409. So I don't rely know what could be a good solution except documenting it. Or maybe you know a better hook than
builder-inited
to insert the local widget bundle.The text was updated successfully, but these errors were encountered: