如何打印 class attribute/element 的文档字符串?
How to print docstring for class attribute/element?
我有一个class:
class Holiday(ActivitiesBaseClass):
"""Holiday is an activity that involves taking time off work"""
Hotel = models.CharField(max_length=255)
""" Name of hotel """
我可以通过键入以下内容来打印 class 文档字符串:
print(Holiday.__doc__)
这输出为:
Holiday is an activity that involves taking time off work
如何打印酒店的文档字符串 Class attribute/element?
我试过的
print(Holiday.Hotel.__doc__)
returns:
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
我也试过 help()
功能没用。
N.B
Sphinx 似乎能够提取 class 属性的文档字符串并将它们包含在 readthedocs 中,所以我希望有办法
我有一个class:
class Holiday(ActivitiesBaseClass):
"""Holiday is an activity that involves taking time off work"""
Hotel = models.CharField(max_length=255)
""" Name of hotel """
我可以通过键入以下内容来打印 class 文档字符串:
print(Holiday.__doc__)
这输出为:
Holiday is an activity that involves taking time off work
如何打印酒店的文档字符串 Class attribute/element?
我试过的
print(Holiday.Hotel.__doc__)
returns:
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
我也试过 help()
功能没用。
N.B
Sphinx 似乎能够提取 class 属性的文档字符串并将它们包含在 readthedocs 中,所以我希望有办法