autodoc 指令在本地有效,但在 readthedocs 上无效
autodoc directive works locally but not on readthedocs
我的仓库位于 github 此处:https://github.com/AshleySetter/optoanalysis
文档在 https://github.com/AshleySetter/optoanalysis/tree/master/optoanalysis/docs
ReadTheDocs 没有失败,但生成的文档(此处托管:https://optoanalysis.readthedocs.io/en/latest/)没有显示应由 ..autodoc::
命令生成的文档字符串。
但是它在本地运行良好,并在我打开 build/html/index.html 文件时显示文档。
在 ReadTheDocs 上看起来像:
而本地构建的 html 文件如下所示:
为什么会这样?
您有用 Cython 编写并编译为 C 的模块。我认为 ReadTheDocs doesn't support C extensions。您必须保护要在 ReadTheDocs 生成的导入内容。
类似于this:
import os
if 'READTHEDOCS' not in os.environ:
import cython_generated_ext
我的仓库位于 github 此处:https://github.com/AshleySetter/optoanalysis
文档在 https://github.com/AshleySetter/optoanalysis/tree/master/optoanalysis/docs
ReadTheDocs 没有失败,但生成的文档(此处托管:https://optoanalysis.readthedocs.io/en/latest/)没有显示应由 ..autodoc::
命令生成的文档字符串。
但是它在本地运行良好,并在我打开 build/html/index.html 文件时显示文档。
在 ReadTheDocs 上看起来像:
而本地构建的 html 文件如下所示:
为什么会这样?
您有用 Cython 编写并编译为 C 的模块。我认为 ReadTheDocs doesn't support C extensions。您必须保护要在 ReadTheDocs 生成的导入内容。
类似于this:
import os
if 'READTHEDOCS' not in os.environ:
import cython_generated_ext