Link to class method in python docstring


I want to add a link to a method in my class from within the docstring of another method of the same class. I want the link to work in sphinx and preferentially also in Spyder and other Python IDE"s.

I tried several options and found only one that works, but it"s cumbersome.

Suppose the following structure in

def class MyClass():
    def foo(self):
        print "foo"
    def bar(self):
        """This method does the same as <link to foo>"""
        print "foo"

I tried the following options for <link to foo>:

  • :func:'foo'
  • :func:''
  • :func:''
  • :func:''

The only one that effectively produces a link is :func:'', but the link is shown as and I want a link that is shown as foo() or foo.
None of the options above produces a link in Spyder.

Thanks for your help.

Get Solution for free from DataCamp guru