Sphinx documentation: how to reference a Python property?

How can I refer to the method decorated with @property ?

For simple methods :py:meth: works fine, but not for properties: it doesn't create a link to them.

+5
source share
1 answer

Instead, use :py:attr: This example is great 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` """ 
+7
source

Source: https://habr.com/ru/post/1207805/


All Articles