0

Using Sphinx's automodule directive, I am creating an API documentation for all functions in my module from their respective docstrings. The respective .rst file comprises just the following lines:

API Reference
=============
.. automodule:: pkg_name.module_name
   :members:
   :undoc-members:
   :show-inheritance:

I am also integrating a Jupyter notebook into the documentation using nbSphinx.

How can I cross-reference a function, which has been created by the automodule directive, from a markdown cell within the Jupyter notebook?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Andi
  • 3,196
  • 2
  • 24
  • 44

1 Answers1

1

It's admittedly a bit clunky, but that's how I would do it: https://nbsphinx.readthedocs.io/en/0.8.2/markdown-cells.html#Links-to-Domain-Objects

In other words:

If your .rst file is called api_reference.rst, you can link to the auto-generated function documentation like this:

[my_function()](api_reference.rst#pkg_name.module_name.my_function)

If you don't know what exactly to put after the #, you can just look at the auto-generated permalink of the function documentation. The important thing is that you use .rst (i.e. the extension of the source file) and not .html (i.e. the extension of the generated output file).

Matthias
  • 4,524
  • 2
  • 31
  • 50
  • I get a file not found error. I thought it was because the notebook is in the /notebooks directory and the .rst is in the parent, but even when I move and re-save the notebook I get the error. – Eli S Jun 09 '22 at 23:47