是否可以使用Sphinx autodoc从函数docstrings生成我的fabfile的文档?
例如,对于包含setup_development
任务的fabfile,我尝试了以下方法:
.. automodule::fabfile
:members:
.. autofunction:: setup_development
但是没有任何生成。
fabfile片段:
@task
def setup_development(remote='origin', branch='development'):
"""Setup your development environment.
* Checkout development branch & pull updates from remote
* Install required python packages
* Symlink development settings
* Sync and migrate database
* Build HTML Documentation and open in web browser
Args:
remote: Name of remote git repository. Default: 'origin'.
branch: Name of your development branch. Default: 'development'.
"""
<code>
.. automodule::
和fabfile
之间缺少空格。如果你想使用.. autofunction::
(我认为不需要),它应该在前面加上一个空行。 - mzjn:members:
不能捕获包装函数(根据 shahjapan 给出的答案),所以我可以使用wraps
或者使用.. autofunction::
,它可以与@task
装饰器一起使用。 - Matt Austin