2

最近我开始通过我sphinx_autodoc_typehintssphinx_autodoc_defaultargs项目的conf.py. 因为它似乎不是 readthedocs 上 sphinx 安装中的默认包(在那里 sphinx 在 v1.8.5 上)。因为我的构建失败并Extension error显示此处

Could not import extension sphinx_autodoc_typehints (exception: No module named 
'sphinx_autodoc_typehints')

我知道我必须以某种方式告诉 readthedocs 从 PyPI 获取 sphinx_autodoc_typehints (以及后来的 sphinx_autodoc_defaultargs )。或者有什么方法可以让我自己在 readthedocs 上安装软件包?

因为我pbr用于包管理,所以我使用 readthedocs 知道的 requirements.txt。我不想在那里指定 sphinx 扩展,因为我的包的每个用户都必须安装它们。没有其他方法可以告诉 readthedocs 使用哪些扩展?

4

1 回答 1

1

根据 Steve Piercy 的评论,我找到了一种拥有两个 requiremens.txt 的方法。readthedocs 的高级设置(在网站上)只允许一个 requirements.txt。

readthedocs 的首选方式是.readthedocs.yaml,它需要位于根文件夹中。在https://docs.readthedocs.io/en/stable/config-file/v2.html之后,文件现在看起来像这样:

version: 2

sphinx:
  configuration: docs/conf.py

python:
  version: 3.7
  install:
    - requirements: requirements.txt
    - requirements: docs/requirements.txt

docs/requirements.txt看起来像这样:

sphinx==3.4.3
sphinx_autodoc_typehints==1.12.0
sphinx_autodoc_defaultargs==0.1.2

在高级设置页面中,我必须手动设置 sphinx' 的位置conf.py,尽管它是标准位置。如果没有这个设置,我的构建仍然会失败。

于 2021-07-13T09:04:05.523 回答