【发布时间】:2015-10-29 13:59:16
【问题描述】:
我正在尝试运行 Sphinx 来记录以下 Celery 任务,但在生成 Sphinx 文档时得到一个空文档:
@celery.task(name='taskname')
def taskname(data):
"""
Some documentation
"""
...
...而以下内容记录良好:
def non_decorated_function(data):
"""
Some documentation
"""
...
我知道函数签名被 celery 任务装饰器破坏了,但我认为 conf.py 中的以下内容应该可以解决这个问题:
extensions = [
'sphinx.ext.autodoc',
'celery.contrib.sphinx',
]
我的 .rst 文件如下所示:
.. automodule:: tasks
:members:
:undoc-members:
:show-inheritance:
使用自动任务 确实 工作,但我希望让它与自动模块一起工作,因为我正在将它添加到一个重要的代码库中:
.. automodule:: tasks
:members:
:undoc-members:
:show-inheritance:
.. autotask:: tasks.taskname
有什么方法可以修复 Sphinx 文档支持的 celery 任务装饰器?
【问题讨论】:
-
你需要换行将
"""Some documentation"""转为"""Some documentation{enter key here}""" -
无论换行状态如何,都会发生这种情况;很抱歉造成混乱!
-
你确定吗?注意你的编辑它不是正确的格式。
"""description{enter}""" -
autotask是官方的做法见here -
@KobiK 这不是文档所说的。 “使用扩展安装的 autodoc 将自动查找任务修饰对象...”和“使用 .. autotask:: 手动记录任务。”看起来得到官方支持的自动部分不起作用。只有手动部分有效。
标签: python celery python-sphinx