The solution that works for Sphinx is to prefix the reference with ~.

Per the Sphinx documentation on Cross-referencing Syntax,

If you prefix the content with ~, the link text will only be the last component of the target. For example, :py:meth:`~Queue.Queue.get` will refer to Queue.Queue.get but only display get as the link text.

So the answer is:

class MyClass():
    def foo(self):
        print 'foo'
    def bar(self):
        """This method does the same as :func:`~mymodule.MyClass.foo`"""
        print 'foo'

This results in an HTML looking like this : This method does the same as foo(), and foo() is a link.

However, note that this may not display in Spyder as a link.

Answer from saroele on Stack Overflow
🌐
Python
peps.python.org › pep-0257
PEP 257 – Docstring Conventions | peps.python.org
A docstring is a string literal that occurs as the first statement in a module, function, class, or method definition.
🌐
Real Python
realpython.com › how-to-write-docstrings-in-python
How to Write Docstrings in Python – Real Python
August 25, 2025 - It’s the default formatting style for inline documentation in Python, as outlined in PEP 287, and is used with tools like Sphinx to generate documentation. When you write docstrings in reST, you need to include specific elements such as parameter names, type names, return value descriptions, and return types. You can also add headers, lists, and links to improve the structure.
🌐
Burke
kevin.burke.dev › kevin › sphinx-interlinks
How to create rich links in your Sphinx documentation | Kevin Burke
December 28, 2013 - # Add the "intersphinx" extension extensions = [ 'sphinx.ext.intersphinx', ] # Add mappings intersphinx_mapping = { 'urllib3': ('http://urllib3.readthedocs.org/en/latest', None), 'python': ('http://docs.python.org/3', None), } You can then link to other projects' documentation and then reference it the same way you do your own projects, and Sphinx will magically make everything work.
🌐
Mkdocstrings
mkdocstrings.github.io › python › usage › configuration › docstrings
Docstrings - mkdocstrings-python
Class docstring. Initialize a thing. ... Whether to enable the relative-crossref syntax. The relative-crossref syntax lets you reference the current object or its parent by prefixing a crossref identifier with dots. For example, to cross-reference the current object's name member, you can write [link ...
🌐
Lsst
developer.lsst.io › python › numpydoc.html
Documenting Python APIs with docstrings — LSST DM Developer Guide main documentation
The default reStructuredText role in docstrings is :py:obj:. Sphinx automatically generates links when the API names are marked up in single backticks.
🌐
DataCamp
datacamp.com › tutorial › docstrings-python
Python Docstrings Tutorial : Examples & Format for Pydoc, Numpy, Sphinx Doc Strings | DataCamp
February 14, 2025 - Python documentation string, commonly known as docstring, is a string literal, and it is used in the class, module, function, or method definition. Docstrings are accessible from the doc attribute (__doc__) for any of the Python objects and also with the built-in help() function.
Find elsewhere
🌐
GitHub
github.com › microsoft › pylance-release › issues › 4334
Support reference-style Markdown links in Docstring rendering · Issue #4334 · microsoft/pylance-release
May 8, 2023 - For example, [foo.bar][] should render as a link to the bar object in the foo module. This works great for my documentation site, but means that users of my package who use VS Code's intellisense have a suboptimal experience as the Python extension renders this markdown incorrectly.
Author: microsoft
🌐
JetBrains
youtrack.jetbrains.com › issue › PY-22175 › Not-able-to-reference-other-functions-in-my-docstrings-with-a-link
Not able to reference other functions in my docstrings with ...
Our website uses some cookies and records your IP address for the purposes of accessibility, security, and managing your access to the telecommunication network. You can disable data collection and cookies by changing your browser settings, but it may affect how this website functions.
🌐
Programiz
programiz.com › python-programming › docstrings
Python Docstrings (With Examples)
Python docstrings are the string literals that appear right after the definition of a function, method, class, or module.
🌐
Python-sprints
python-sprints.github.io › pandas › guide › pandas_docstring.html
pandas docstring guide — Python documentation
In rare occasions reST styles like bold text or itallics will be used in docstrings, but is it common to have inline code, which is presented between backticks. It is considered inline code: ... Python code, a module, function, built-in, type, literal… (e.g. os, list, numpy.abs, datetime.date, True) A pandas class (in the form :class:`pandas.Series`) A pandas method (in the form :meth:`pandas.Series.sum`) A pandas function (in the form :func:`pandas.to_datetime`) ... To display only the last component of the linked class, method or function, prefix it with ~. For example, :class:`~pandas.Series` will link to pandas.Series but only display the last part, Series as the link text.
🌐
Python
wiki.python.org › moin › HelpOnLinking
HelpOnLinking - Python Wiki
Brackets ([[ ]]) are used to link to a target (a local wiki page, an external URL, a file, etc).
🌐
Readthedocs
sphinxcontrib-napoleon.readthedocs.io › en › latest › example_google.html
Example Google Style Python Docstrings — napoleon 0.7 documentation
Sections support any reStructuredText formatting, including literal blocks:: $ python example_google.py Section breaks are created by resuming unindented text. Section breaks are also implicitly created anytime a new section starts. Attributes: module_level_variable1 (int): Module level variables may be documented in either the ``Attributes`` section of the module docstring, or in an inline docstring immediately following the variable.
🌐
Linux find Examples
queirozf.com › entries › python-docstrings-reference-examples
Python Docstrings: Reference & Examples
September 1, 2020 - Examples to help you document your Python code using any of the commonly used docstring styles.
🌐
Pandas
pandas.pydata.org › docs › development › contributing_docstring.html
pandas docstring guide — pandas 3.0.6 documentation
To display only the last component of the linked class, method or function, prefix it with ~. For example, :class:`~pandas.Series` will link to pandas.Series but only display the last part, Series as the link text. See Sphinx cross-referencing syntax for details. ... def add_values(arr): """ Add the values in ``arr``. This is equivalent to Python ``sum`` of :meth:`pandas.Series.sum`. Some sections are omitted here for simplicity. """ return sum(arr) ... def func(): """Some function. With several mistakes in the docstring.
🌐
Readthedocs
numpydoc.readthedocs.io › en › latest › format.html
Style guide — numpydoc v1.11.1.dev1+gca74aae44 Manual
Links : Depending on project settings, hyperlinks to documentation of modules, classes, functions, methods, and attributes should automatically be created if a recognized name is included within single backticks (e.g. `numpy` renders as numpy). If you need to include other hyperlinks, note that some docstring sections are not parsed as standard reST, and in these sections, numpydoc may become confused by hyperlink targets such as:
🌐
Sphinx
sphinx-doc.org › en › master › usage › extensions › autodoc.html
sphinx.ext.autodoc – Include documentation from docstrings — Sphinx documentation
autodoc considers a variable member does not have any default value if its docstring contains :meta hide-value: in its Info field lists. Example: ... Added in version 3.5. Python has no built-in support for docstrings for module data members or class attributes.
🌐
Pandas
pandas.pydata.org › pandas-docs › stable › development › contributing_docstring.html
pandas docstring guide — pandas 3.0.3 documentation
To display only the last component of the linked class, method or function, prefix it with ~. For example, :class:`~pandas.Series` will link to pandas.Series but only display the last part, Series as the link text. See Sphinx cross-referencing syntax for details. ... def add_values(arr): """ Add the values in ``arr``. This is equivalent to Python ``sum`` of :meth:`pandas.Series.sum`. Some sections are omitted here for simplicity. """ return sum(arr) ... def func(): """Some function. With several mistakes in the docstring.