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.
ivar is an "instance variable", or a variable that is set on an instance object (an instance of a class). Typically these would be defined (in Python) inside of an __init__ method.
To support Markdown-based documentation, Sphinx can use MyST-Parser. MyST-Parser is a Docutils bridge to markdown-it-py, a Python package for parsing the CommonMark Markdown flavor.
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`
"""
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`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With