我使用Sphinx来记录我的python项目。我已经启用了autodoc扩展,并且在我的文档中有以下内容。
.. autoclass:: ClassName
:members:
问题是,它只记录了类中的非私有方法。如何将私有方法也包含进来?
发布于 2011-10-12 20:47:28
如果您使用的是sphinx1.1或更高版本,请访问sphinx文档站点http://www.sphinx-doc.org/en/master/ext/autodoc.html,
:special-members:
:private-members:
发布于 2017-06-20 03:49:51
您可以将其添加到conf.py
文件中:
autodoc_default_flags = ['members', 'undoc-members', 'private-members', 'special-members', 'inherited-members', 'show-inheritance']
发布于 2011-05-24 15:03:00
解决这个问题的一种方法是显式地强制Sphinx记录私有成员。您可以通过将automethod
附加到类级别文档的末尾来完成此操作:
class SmokeMonster(object):
"""
A large smoke monster that protects the island.
"""
def __init__(self,speed):
"""
:param speed: Velocity in MPH of the smoke monster
:type speed: int
.. document private functions
.. automethod:: _evaporate
"""
self.speed = speed
def _evaporate(self):
"""
Removes the smoke monster from reality. Not to be called by client.
"""
pass
https://stackoverflow.com/questions/1149280
复制相似问题