Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sphinx linking functions between files

I've been looking for an answer on stackoverflow and in official docs and still can't find the solution.

In the main Sphinx-doc document I have:

Contents:

.. toctree::

    views/index.rst
    db/index.rst

In views/index.rst

.. py:currentmodule:: app.views
.. py:function:: create_user

  this function uses create_user_db

and in db/index.rst

.. py:currentmodule:: app.db

.. py:function:: create_user_db
   this function creates the user in database

What I need is a hyperlink from create_user to exacly the place create_user_db is.

Functions are not genereated by autodoc, I don't want to use sections and *.. _section_label :* for every function that is listed in db/index.

Is it even possible to link it that way that views can move you to db/index.html#app.db.create_user_db using :doc:, :ref: or something?

like image 654
Archarachne Avatar asked Mar 13 '26 19:03

Archarachne


1 Answers

This should work:

this function uses :py:func:`app.db.create_user_db`

You need to use the fully qualified name.

like image 98
mzjn Avatar answered Mar 16 '26 08:03

mzjn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!