python - 狮身人面像 : How set the right path for html_static_path in config. py?

标签 python path python-sphinx

我是初学者所以也许这个问题听起来很愚蠢但无论如何:

我正在使用 sphinx,我想在 config.py 文件中设置 html_static_path 变量。

默认是:

html_static_path = ['_static']

我的项目设置是:

docs/
    build/
         doctrees
         html/
             _static/ 
    source/
          conf.py

sphinx 文档说我需要设置相对于该目录的路径,即来自 conf.py 的 rel 路径。所以我尝试了:

html_static_path = ['..\build\html\source\_static']

我尝试设置绝对路径。

但我仍然收到警告:

WARNING: html_static_path entry 'build\html\source\_static' does not exist

也许值得一提:

conf.py 文件的“路径设置”是:

import os
import sys
sys.path.insert(0, os.path.abspath('..'))
sys.setrecursionlimit(1500)

你能帮帮我吗?我真的已经尝试了我能想到的路径的每一种组合。 谢谢!

最佳答案

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

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

conf.py 中的值更改为:

html_static_path = ["_static"]

关于python - 狮身人面像 : How set the right path for html_static_path in config. py?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70739677/

相关文章:

python - 尝试访问 sdk 数据存储管理时出现导入错误

python - DatabaseError : current transaction is aborted, 命令在事务 block 结束之前被忽略?

php - 正则表达式:如何验证路径不包含//

c++ - 未通过路径变量识别 MinGW

python - python 的 sphinx autodoc 没有显示任何内容(在 readthedocs 上)

python - 如何在 Django 表单中添加 GenericRelation 字段

python - 从 iOS 上传 Flask 文件

python - brew 安装的 Python 没有覆盖系统 python

latex - 警告中的 tabularcolumns 指令未显示在 latex 中

python - 链接到 Python 文档字符串中的类方法