spatialaudio / nbsphinx

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

Add download ipynb button #548

Closed ma-sadeghi closed 3 years ago

ma-sadeghi commented 3 years ago

This feature probably exists, but just in case, is there a way to add a download ipynb button for each notebook?

mgeier commented 3 years ago

Yes, but you'll have to provide your own button.

For every HTML page, the (potentially executed) notebook is available at the same address, just replace html with ipynb, e.g.:

https://nbsphinx.readthedocs.io/en/0.8.2/code-cells.html https://nbsphinx.readthedocs.io/en/0.8.2/code-cells.ipynb

You can use nbsphinx_prolog and nbsphinx_epilog to create arbitrary links and buttons and whatever you want: https://nbsphinx.readthedocs.io/en/0.8.2/prolog-and-epilog.html.

I personally like to link to the non-executed files in the Git repository (e.g. on Github), as shown on every notebook in the nbsphinx documentation. Here's how this is done:

https://github.com/spatialaudio/nbsphinx/blob/31df9169555b31d663972507449a45937da5fbce/doc/conf.py#L33-L63

Those pages also have a link to the executed notebook on nbviewer, for example https://nbviewer.jupyter.org/urls/nbsphinx.readthedocs.io/en/0.8.2/code-cells.ipynb.

But if you want, you can of course also create a direct link to the executed notebook.

ma-sadeghi commented 3 years ago

Great, thanks!

mhash1m commented 3 years ago

@mgeier how do you make this work with nbsphinx-link?

mgeier commented 3 years ago

@mHash1m I don't, and I have never tried. You should probably ask at https://github.com/vidartf/nbsphinx-link?

If you create an issue, please leave a link here.

If you don't get an answer over there, feel free to ping me again.

If you need additional nbsphinx features, please open a separate issue.