spatialaudio / nbsphinx

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

JavaScript loading issue while offline browsing #799

Closed o5x closed 2 months ago

o5x commented 6 months ago

Hi, by trying to use nbsphinx on an offline computer, I've noticed the documentation was really slow to load.

After debugging I've noticed that the generated html documentation is trying to load tex-mml-chtml.js and require.min.js which are not stored locally.

Hence when browsing the documentation offline, it is trying to fetch these JavaScript files for a minute, to finally return an error and show the doc.

Is it possible to make these resources local ? I haven't checked in the code but there could be more links like these when using other features.

I also could not find a workaround to fix it unless I remove these scripts sources manually.

Thanks.

mgeier commented 6 months ago

https://www.sphinx-doc.org/en/master/usage/extensions/math.html#confval-mathjax_path https://nbsphinx.readthedocs.io/en/0.9.3/configuration.html#nbsphinx_requirejs_path

o5x commented 6 months ago

https://www.sphinx-doc.org/en/master/usage/extensions/math.html#confval-mathjax_path https://nbsphinx.readthedocs.io/en/0.9.3/configuration.html#nbsphinx_requirejs_path

It is actually working, it's unlucky that require.min.js is not automatically included, maybe there is a reason behind that.

Thank you

mgeier commented 3 months ago

it's unlucky that require.min.js is not automatically included, maybe there is a reason behind that.

Are you suggesting to change something?

Can you please elaborate?

o5x commented 2 months ago

I mean its good as it is possible to add it manually thanks to the config. If you build doc and give it to someone offline he can't use it which is unlucky Especially if you're unaware that someone offline can't open the docs as it will try to load forever NB : the loading forever is with a restricted internet access, i think it would work if totally offline as it would cancel the request

mgeier commented 2 months ago

I don't know how to improve the situation, but I'm open for PRs!

o5x commented 2 months ago

A solution would be to include require.min.js locally instead of using the remote one

In my case i have to add this to my setup.py :

# Extra ressources
nbsphinx_requirejs_path = "require.min.js"
mathjax_path = "tex-mml-chtml.js"

And add require.min.js and tex-mml-chtml.js to ressources/ folder next to setup.py

It would be nice if the nbsphinx extension could do it automatically 👍 Note that mathjax_path is also needed for latex if i'm correct

I unfortunately don't have time to look into it atm for a PR !

It's a very useful extension btw, good job 🥇