1
votes

I am using Sphinx to document a python project. The documentation includes both an API reference and a user guide. I would like to include links from the user guide to the relevant section of the API reference, but can't seem to figure it out.

My API refrence uses the autodoc extension; however, I list my methods out individually, e.g.:

.. automodule:: module_name

    .. autoclass:: class_name

        .. automethod:: method_a

        .. automethod:: method_b

In another rst file I have my user guide. I can link to an arbitrary place in another rst file using ref; however, it seems that the lable must come before a section title. So for instance the below doesn't work.

userguide.rst

see :ref:`my-reference-label` for more details on method_b

api.rst

.. automodule:: module_name

    .. autoclass:: class_name

        .. automethod:: method_a

        .. _my-reference-label:

        .. automethod:: method_b

How can a link to a specific place in my API documentation?

1

1 Answers

2
votes

You don't need to define a label. A hyperlink to method_b can be created using the :py:meth: role:

:py:meth:`module_name.class_name.method_b`

This markup can be customized and simplified in various ways (for example, the :py prefix is not necessary when the domain is Python).

More details here: