简体   繁体   中英

Cross reference a Python function generated by Sphinx's automodule directive from Jupyter notebook

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?

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 (ie the extension of the source file) and not .html (ie the extension of the generated output file).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM