Reputation: 3581
How can I reference a method, decorated with @property
?
For simple methods, :py:meth:
is working fine, but not for properties: it does not create a link to them.
Upvotes: 21
Views: 10696
Reputation: 9916
This works for me. It renders MyClass.my_prop
with the proper link.
:attr:`.MyClass.my_prop`
This renders just my_prop
, with the same link.
:attr:`~.MyClass.my_prop`
Upvotes: 6
Reputation: 11
I use :py:obj:
instead.
:py:attr:
won't work for me when the property is in another page.
Upvotes: 1
Reputation: 13415
You should use :py:attr:
instead. This example works fine for me:
class SomeClass(object):
"""This is the docstring of SomeClass."""
@property
def some_property(self):
"""This is the docstring of some_property"""
return None
def some_method(self):
"""This is the docstring of some_method.
And this is a reference to :py:attr:`~some_property`
"""
Upvotes: 29