我有一个模块,我在其中创建了一个函数chain
(有点像itertools.chain
),所以我想我也会模仿itertools
接口并公开一个chain.from_iterable
函数。为此,我只需定义另一个函数,然后chain
像这样用胶带将其粘贴到上面:
chain = _create_chain(environment)
在某处_create_chain
:
_chain.from_iterable = _from_iterable
return _chain
两者chain
都有chain.from_iterable
文档字符串,一切正常,但我想用 Sphinx 自动记录chain
两者。chain.from_iterable
现在我有
.. automodule:: mymodule
:members:
.. autofunction:: chain
并且它为 创建文档,但是为结果chain
添加另一个autofunction
指令,因为它认为是一个模块:chain.from_iterable
ImportError
chain
WARNING: autodoc: failed to import function u'from_iterable' from module u'chain'; the following exception was raised:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 335, in import_object
__import__(self.modname)
ImportError: No module named chain
chain.from_iterable
在这种情况下如何包含文档?