Sphinx autodoc - 装饰器和 ReadTheDocs
Sphinx autodoc - decorator and ReadTheDocs
我在使用 autodoc 自动生成 Sphinx 文档时遇到了一些问题。我基本上和这里有同样的问题:Python Sphinx autodoc and decorated members
当我在函数上使用装饰器时,文档中显示的签名是装饰器的签名。按照上述帖子的说明,我在我的装饰器定义中添加了@decorator装饰器,它确实解决了问题。
现在我已经将我的项目挂钩到 ReadTheDoc.org,效果很好,唯一的问题是装饰器问题回来了,不管之前的修复如何。
我对 Sphinx 很陌生,所以我不确定这是否值得在 RTD Github 项目上产生问题。我可以在这里错过什么?查看损坏的签名 here
难道是配置?我用 Python3
构建文档
此外,如果模块不可用,我定义了一个虚拟 @decorator
,如下所示:
try:
from decorator import decorator
except ImportError:
def decorator(f):
return f
您可以在 RTD 中添加一个 requirements.txt
文件,在该文件中,您可以指定与本地环境完全相同的环境。
当然包括 sphinx
,因为 RTD 使用 sphinx==1.6.5
。该版本的行为可能与您的不同。
根据您的 recent build log on RTD, decorator 未安装在 RTD 上。
您必须将装饰器指定为包中的依赖项或将其添加到 RTD 需求文件中 requirements.txt
。
我在使用 autodoc 自动生成 Sphinx 文档时遇到了一些问题。我基本上和这里有同样的问题:Python Sphinx autodoc and decorated members
当我在函数上使用装饰器时,文档中显示的签名是装饰器的签名。按照上述帖子的说明,我在我的装饰器定义中添加了@decorator装饰器,它确实解决了问题。
现在我已经将我的项目挂钩到 ReadTheDoc.org,效果很好,唯一的问题是装饰器问题回来了,不管之前的修复如何。
我对 Sphinx 很陌生,所以我不确定这是否值得在 RTD Github 项目上产生问题。我可以在这里错过什么?查看损坏的签名 here
难道是配置?我用 Python3
构建文档此外,如果模块不可用,我定义了一个虚拟 @decorator
,如下所示:
try:
from decorator import decorator
except ImportError:
def decorator(f):
return f
您可以在 RTD 中添加一个 requirements.txt
文件,在该文件中,您可以指定与本地环境完全相同的环境。
当然包括 sphinx
,因为 RTD 使用 sphinx==1.6.5
。该版本的行为可能与您的不同。
根据您的 recent build log on RTD, decorator 未安装在 RTD 上。
您必须将装饰器指定为包中的依赖项或将其添加到 RTD 需求文件中 requirements.txt
。