MyST-NB
MyST-NB copied to clipboard
Code hyperlinks to API documentation
Context
Sphinx gallery has a nice feature that allows users to click on a function in a code cell, directing to the relevant API documentation of that function. It is described here: https://sphinx-gallery.github.io/stable/configuration.html#link-to-documentation
Proposal
I propose to add a simmilar feature, i.e. parsing code cells in jupyter notebooks, finding functions and adding links to the respective API docs. To start with, linking to functions from the same project is sufficient. Later, one can also make use of intersphinx to link to external sites.
Tasks and updates
No response
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
Heya, this is already possible apparently 😄 : https://sphinx-codeautolink.readthedocs.io/en/latest/examples.html#ipython-blocks-and-notebooks
Happy to add a link in the docs somewhere
Thank you very much @chrisjsewell for pointing this out, it works perfectly 🚀
Indeed, a hint in the docs with some keywords that can be searched for would be much appreciated.
For reference, here are the required steps to make it work:
pip install sphinx-codeautolink- In
conf.py:extensions = [ ... "sphinx.ext.intersphinx", "sphinx_codeautolink", ] codeautolink_concat_default = True # !!! without this, only the first cell of a notebook is handled correctly intersphinx_mapping = { 'python': ('https://docs.python.org/3', None), ... }
Regarding codeautolink_concat_default @mgeier commented in https://github.com/felix-hilden/sphinx-codeautolink/pull/121#issuecomment-1356326069
FYI, this is not needed when using
nbsphinx, which takes care of this situation here: https://github.com/spatialaudio/nbsphinx/blob/30dd9728ea674a0a97cf1c11d695a25491d58212/src/nbsphinx.py#L1124-L1125Maybe something similar should be implemented for MyST-NB? Then users wouldn't have to worry about this.
Which I think would we wonderful to have in MyST-NB too.