Sphinx:html_static_path条目不存在

Pau*_*aul 10 python path python-sphinx

我正在使用 Sphinx,我想在 config.py 文件中设置 html_static_path 变量。默认为:

html_static_path = ['_static']

我的项目设置是:

docs/
    build/
         doctrees
         html/
             _static/ 
    source/
          conf.py
Run Code Online (Sandbox Code Playgroud)

sphinx文档说我需要设置相对于该目录的路径,即conf.py的相对路径。因此,我尝试:

html_static_path = ['..\build\html\source\_static']
Run Code Online (Sandbox Code Playgroud)

我尝试设置绝对路径。但我仍然收到警告:

警告:html_static_path 条目“build\html\source\_static”不存在

你能帮助我吗?谢谢你!

Ste*_*rcy 12

构建目录是在构建文档后创建的,这就是您收到该错误的原因。当您制作文档时,Sphinx 会将静态目录从 定义的源位置复制html_static_path到构建位置。

创建一个新目录source/_static并将所有静态资源放入其中。

将值更改conf.py为:

html_static_path = ["_static"]
Run Code Online (Sandbox Code Playgroud)