在 ReadTheDocs 上出现但不显示功能的模块,在 Sphinx 中没有明显的错误

Modules appearing but not displaying functions on ReadTheDocs, with no apparent errors in Sphinx

我正在使用 ReadTheDocs (RTD) 记录一段代码。这是它构建的 GitHub 存储库,下面是网站的当前状态:

回购:https://github.com/GluonicPenguin/AutoDQM

RTD:https://autodqm.readthedocs.io/en/latest/index.html

我在本地有 运行 一个 Sphinx 构建并检查了 RTD 上的构建,我没有收到任何警告或错误,但是 autodqm/dqm.py module does not display the list of functions properly on RTD, i.e. the lists of functions aren't appearing. I had an issue with autodqm/compare_hists.py 也是如此,我发现问题是我有顶部的 import ROOT 行(与其他导入行),当通过 ROOT() 函数调用导入时,出于某种原因,这解决了问题并且 autodqm/compare_hists.py 模块正确显示在网站。

我认为类似的修复方法适用于 autodqm/dqm.py 但在这种情况下,我必须在顶部附近定义函数

def lxml():
    import lxml.html
    return lxml.html

def FuturesSession():
    from requests_futures.sessions import FuturesSession
    return FuturesSession

我必须删除 class DQMSession。我最多可以认为 RTD 不喜欢处理 import <package>.<subpackage>.

形式的导入函数

我也提前为所有提交和 vague/poor 提交消息道歉 - 我正在做这件事,并且在本地而不是在 GitHub 上开发它,所以我不得不继续推动测试这个。

我目前的设置不起作用有什么原因吗?还有其他我遗漏的问题吗?我以前从未使用过 Sphinx/RTD,所以在修复此类问题时我是个新手。我不想用“隔离”导入函数支持上面的快速修复的原因是这段代码需要高效,因为它被设计为扫描很多直方图来执行统计比较,在那个规模上效率是必不可少的。

根据Steve的上述回复,我修复了AutoDQM RE中无法导入模块的问题,所以现在网站上的所有功能都可以正常显示了。修复是:

dqm.py - requests-futures 和 lxml 现在要求在 setup.py 中指定,它们是通过

安装的 pip

install_requires=['lxml==4.5.2','requests-futures==1.0.0']

compare_hists.py - 使用扩展名 autodoc_mock_imports 从 autodoc 导入 ROOT fixed,因此 docs/conf.py autodoc_mock_imports = ["ROOT"] 中有一行。我们需要这样的需求,因为它是一个有 C 依赖的包,所以不能像其他的一样 pip 安装。

感谢您的帮助!