-
Notifications
You must be signed in to change notification settings - Fork 131
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
How to include the JavaScript for widgets? #84
Comments
It looks like In the meantime, the notebook state has to be saved manually with the menu item "Save Notebook Widget State". See also https://ipywidgets.readthedocs.io/en/stable/embedding.html#using-the-nbsphinx-project. The necessary JavaScript can be added like this in For Sphinx >= 1.8: from ipywidgets.embed import DEFAULT_EMBED_REQUIREJS_URL
html_js_files = [
'https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js',
DEFAULT_EMBED_REQUIREJS_URL,
] A work-around for Sphinx < 1.8 is this: from ipywidgets.embed import DEFAULT_EMBED_REQUIREJS_URL
def setup(app):
app.add_javascript('https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js')
app.add_javascript(DEFAULT_EMBED_REQUIREJS_URL) Note that |
A little update 1: Saving the widget state now works in A little update 2: Since #302, Therefore, only the from ipywidgets.embed import DEFAULT_EMBED_REQUIREJS_URL
html_js_files = [
DEFAULT_EMBED_REQUIREJS_URL,
] The |
This isn't working for me. Double checking that nbsphinx/nbconvert are up to date and the state is correctly embedded in the html doesn't show any obvious troubles. JS errors on the page are:
But these seems fairly common with Sphinx/RTD. Any ideas of what to try here? |
@dgasmith Yes, sorry, this is indeed broken (which I didn't know when writing my comment above). This has been fixed in #334, but there hasn't been a new release yet. Maybe I will even implement loading the widget JS by default, see jupyter-widgets/ipywidgets#2284 (comment) I'd be happy to hear feedback about that! |
@mgeier Awesome, I just checked with current master and everything works great! Reading through your PR I understood that the Any ideas on a timeline for the next release? If not I can pull the GitHub tags. |
@dgasmith Thanks for checking!
But, as I said, there is still an issue with
I want to check first if I can make embedding the widget JS fully automatic before the next release. If you are in a hurry, you should just depend on the |
Is it really necessary to load
jupyter_sphinx.embed_widgets
?Since #76, only adding the JS file is necessary, nothing else from
jupyter_sphinx.embed_widgets
is needed, right?What about adding a config option like
nbsphinx_widgets
?This could be
False
by default andTrue
if widgets should be displayed.It could even be set to an alternative path to the JS file (e.g. for offline use).
See also jupyter/jupyter-sphinx#3.
The text was updated successfully, but these errors were encountered: