spatialaudio / nbsphinx

:ledger: Sphinx source parser for Jupyter notebooks
https://nbsphinx.readthedocs.io/
MIT License
450 stars 130 forks source link

Pass through HTMLExporter.html_manager_semver_range config to nbconvert #672

Closed ohrely closed 1 year ago

ohrely commented 2 years ago

@jnnamchi and I are running into an issue introduced by a recent release of @jupyter-widgets/html-manager (1.0.1) that could be circumvented by the approach described in this comment on an ipydatagrid issue:

try running nbconvert with the option --HTMLExporter.html_manager_semver_range="0.20.2"

As far as we can tell, nbconvert will only respect a pinned version of html-manager if it's passed as a config in the nbconvert call, which for us is abstracted by nbsphinx. It looks like there are already a few precedents for passing through config values from nbsphinx to nbconvert in https://github.com/spatialaudio/nbsphinx/blob/master/src/nbsphinx.py; is there any reason not to take that same approach for exposing this config?

mgeier commented 1 year ago

is there any reason not to take that same approach for exposing this config?

I don't think so.

But maybe that's not even necessary. Did you try passing the option via nbsphinx_execute_arguments?

https://nbsphinx.readthedocs.io/en/latest/configuring-kernels.html#Kernel-Arguments

Jnnamchi commented 1 year ago

Our config has the nbsphinx_execute = 'never' setting in conf.py, so nbsphinx_execute_arguments will not have an effect on the html that gets produced.

So we did still try to run nbsphinx build with nbsphinx_execute_arguments just in case but as expected it had no effect.

We will try to implement @ohrely 's suggestion and get a PR out next week for review. Until then any other ideas are welcome!

Thanks!

mgeier commented 1 year ago

Sorry for leading you on a wrong path, I didn't read your description very carefully.

Now that it read it somewhat more carefully, I'm starting to understand that this is about the version of the JavaScript that is inserted to make widgets work, right?

I guess you want to set nbsphinx_widgets_path in your conf.py?

https://nbsphinx.readthedocs.io/en/0.8.9/usage.html#nbsphinx_widgets_path

mgeier commented 1 year ago

Alternatively, it might work by downgrading ipywidgets, which is the source for the default URL.

mgeier commented 1 year ago

BTW, nbconvert is only used for executing the notebooks, not for generating the HTML, so setting the parameter --HTMLExporter.html_manager_semver_range wouldn't have any effect.

Jnnamchi commented 1 year ago

@mgeier nbsphinx_widgets_path turned out to be the solution for us. We set it to the following and all the built html pages call that path. Thanks for the note! We can close this issue.