本文介绍了autodoc指令在本地有效,但在readthedocs上无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的存储库位于github上的此处:

本地生成的html文件如下所示:

为什么会这样?

解决方案

您有用Cython编写并编译为C的模块.我认为 ReadTheDocs不支持C扩展.您必须保护要在ReadTheDocs上生成的导入.

类似:

  import os如果'READTHEDOCS'不在os.environ中:导入cython_genic_ext 

My repo is located on github here: https://github.com/AshleySetter/optoanalysis

And the docs are in https://github.com/AshleySetter/optoanalysis/tree/master/optoanalysis/docs

ReadTheDocs doesn't fail but the produced documentation (hosted here: https://optoanalysis.readthedocs.io/en/latest/) doesn't display the doc strings that should be produced by the ..autodoc:: command.

However it runs fine locally and displays the documentation when I open the build/html/index.html file.

On ReadTheDocs it looks like:

Whereas the locally built html file looks like so:

Why might this be?

解决方案

You have modules written in Cython and compiled to C. I think ReadTheDocs doesn't support C extensions. You have to protect you imports to be generated at ReadTheDocs.

Something like this:

import os
if 'READTHEDOCS' not in os.environ:
    import cython_generated_ext

这篇关于autodoc指令在本地有效,但在readthedocs上无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 19:54