我已经使用 Sphinx 编写了 Node.js 库的文档。在我的本地 PC 上,我可以毫无问题地生成 html 文档。但是,当我尝试在“阅读文档”上发布它时,编译失败。这是我的 .readthedocs.yaml 文件。
# Required
version: 2
# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"
# You can also specify other tool versions:
# nodejs: "19"
# rust: "1.64"
# golang: "1.19"
# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py
这是我的conf.py
project = 'My-Library'
copyright = '2023, Hector E. Socarras'
author = 'Hector E. Socarras'
release = '1.0.0'
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = ['sphinx.ext.autosectionlabel', "sphinx_rtd_theme"]
templates_path = ['_templates']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
# on_rtd is whether we are on readthedocs.org
#on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
#if not on_rtd: # only import and set the theme if we're building docs locally
#import sphinx_rtd_theme
#import sphinx_rtd_theme
html_theme = "sphinx_rtd_theme"
html_static_path = ['static']
它编译成功一次,然后总是失败并显示以下消息
Extension error:
Could not import extension sphinx_rtd_theme (exception: No module named 'sphinx_rtd_theme')
如果添加带有 sphinx_rtd_theme 的 requeriments.txt 然后会失败并显示以下消息
ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.
显然,它不是一个Python包。
我需要帮助,我希望在“阅读文档”中获得可用的文档。
我在 readthedocs FAQ 上读到了这篇文章:
sphinx-rtd-theme:
Projects created before October 20, 2020 (January 21, 2021 for About Read the Docs for Business) use 0.4.3. New projects use the latest version. Projects created after August 7, 2023 won’t install this dependency by default.
因此,有关“无法导入扩展 sphinx_rtd_theme”的问题适用于 2023 年 8 月 7 日之后创建的项目。