Sphinx documentation at http://www.sphinx-doc.org/en/stable/domains.html#cross-referencing-python-objects says
: py: func: Python function reference; dot names can be used. Role text should not include sliding parentheses to enhance readability; they will be added automatically by Sphinx if the add_function_parentheses configuration value is True (default).
: py: met: Link to the method of the object. Role text may include type name and method name; if this happens in the description of the type, the type name can be omitted. You can use a dotted name.
But I could not find a difference in how they behave.
Here is my Python module for which I generated the documentation.
"""foo module.""" def hello(name): """Print hello addressed to *name*. Args: name (str): Name to address. """ print('hello', name) class Foo: """Foo class.""" def bye(self, name): """Print bye addressed to *name*. Args: name (str): Name to address. """ print('bye', name) if __name__ == '__main__': hello('world') Foo().bye('python')
This is what I have in the index.rst file.
Foo Documentation ================= See :func:`foo.hello` and :func:`foo.Foo.bye`. Also, see :meth:`foo.hello` and :meth:`foo.Foo.bye`. foo module ========== .. automodule:: foo :members:
After doing make html this is the result I see.

Both roles :func: and :meth: generate valid hyperlink hyperlinks to hello and Foo.bye regardless of whether the target is a function or method.
What is the difference between the roles :func: and :meth: Can you give an example by which they behave differently?
python python-sphinx
Lone learningner
source share