如何打印类属性/元素的文档字符串?

Tom*_*Mac 5 python django docstring django-models python-3.x

我有一堂课:

class Holiday(ActivitiesBaseClass):
    """Holiday is an activity that involves taking time off work"""

    Hotel = models.CharField(max_length=255)
    """ Name of hotel """
Run Code Online (Sandbox Code Playgroud)

我可以通过键入以下内容来打印类文档字符串:

print(Holiday.__doc__)
Run Code Online (Sandbox Code Playgroud)

这输出为:

Holiday is an activity that involves taking time off work 
Run Code Online (Sandbox Code Playgroud)

如何打印属于 Class 属性/元素的 Hotel 的文档字符串?

我试过的

print(Holiday.Hotel.__doc__)
Run Code Online (Sandbox Code Playgroud)

返回:

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

Run Code Online (Sandbox Code Playgroud)

我也试过这个help()功能无济于事。

NB

Sphinx 似乎能够提取类属性的文档字符串并将它们包含在 readthedocs 中,所以我希望有一种方法

nev*_*ner 5

不要认为可以为特定字段添加文档字符串,但您可以使用字段的help_text参数来代替:

Hotel = models.CharField(max_length=255, help_text="Name of hotel")
Run Code Online (Sandbox Code Playgroud)