Yaash Yaash - 3 years ago 71
Python Question

Link to class method of another module in python docstring

I want to add a link of a method of one module(

say module_2.py
) in another method of another module(
say module_1.py
). I want the link to work in
Sphinx
.

Suppose:

module_1.py

class ABC:
def foo(self):
"""
See docstring of module_2.py bar():<link to bar() in module_2.py>
"""
print("foo")


module_2.py

class XYZ:
def bar(self):
"""
This function prints hello.
"""
print("hello")

Answer Source

You can just include the path of the particular function. Like in your example do:

class ABC:
  def foo(self):
    """
    See docstring
    ========

    module_2.XYZ.bar
    """
    print("foo")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download