1

我有一个模块,我在其中创建了一个函数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_iterableImportErrorchain

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在这种情况下如何包含文档?

4

0 回答 0