【问题标题】:Some Python modules don't show up on readthedocs.io despite appearing when generating Sphinx docs locally尽管在本地生成 Sphinx 文档时出现了一些 Python 模块,但它并没有出现在 readthedocs.io 上
【发布时间】:2025-12-05 19:40:02
【问题描述】:

我正在尝试为 Python 项目生成 Sphinx 文档并使用 Read The Docs 托管文档。项目代码为here。当我运行 make clean && make html 在本地生成文档时,文档会生成并包含我的所有四个 Python 模块: Local Docs

我已阅读连接到 Github 的文档以生成有关新提交的文档,它成功地为我的 2/4 的 Python 模块生成了文档,但其中两个没有出现。 Read The Docs 构建似乎运行没有错误: Read The Docs

我的本​​地构建有一些警告,但它们似乎与未出现的文档无关:

$ make clean && make html
Removing everything under '_build'...
Running Sphinx v3.2.1
making output directory... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 3 source files that are out of date
updating environment: [new config] 3 added, 0 changed, 0 removed
reading sources... [100%] source/modules                                                             
/<home>/argos-translate/argostranslate/package.py:docstring of argostranslate.package.Package:24: WARNING: Unexpected indentation.
/<home>/argos-translate/argostranslate/package.py:docstring of argostranslate.package.Package:30: WARNING: Block quote ends without a blank line; unexpected unindent.
/<home>/argos-translate/argostranslate/translate.py:docstring of argostranslate.translate.Language:7: WARNING: Unexpected indentation.
/<home>/argos-translate/argostranslate/translate.py:docstring of argostranslate.translate.Language:8: WARNING: Block quote ends without a blank line; unexpected unindent.
looking for now-outdated files... none found
pickling environment... done
checking consistency... /<home>/argos-translate/docs/source/modules.rst: WARNING: document isn't included in any toctree
done
preparing documents... done
writing output... [100%] source/modules                                                              
generating indices...  genindex py-modindexdone
writing additional pages...  searchdone
copying static files... ... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded, 5 warnings.

The HTML pages are in _build/html.

Here's a link to the Read The Docs documentation.

【问题讨论】:

    标签: python python-sphinx read-the-docs


    【解决方案1】:

    始终检查 RTD 构建日志是否有“警告”或“错误”。

    在您的情况下,latest build log 对 RTD 上未记录的两个模块有以下相关警告:

    WARNING: autodoc: failed to import module 'gui' from module 'argostranslate'; the following exception was raised:
    No module named 'ctranslate2'
    
    ...
    
    WARNING: autodoc: failed to import module 'translate' from module 'argostranslate'; the following exception was raised:
    No module named 'ctranslate2'
    

    这意味着尚未指定在 RTD 上安装所需的依赖项。确保在项目中指定 ctranslate2 作为要求,以便 RTD 可以安装它。详情请参阅Specifying Dependencies

    【讨论】:

    • 这是问题谢谢!我有两个 requirements.txt 文件,一个在我的整个应用程序的根目录中,一个在我的 docs/ 文件夹中。阅读文档只查看 docs/ 文件夹中的那个。结合它们并将 requirements.txt 设置为我在 Read The Docs 中的需求文件解决了这个问题。
    最近更新 更多