当我搜索 readthedocs 页面上不存在的短语时,我收到消息:
“正在搜索...”,这将花费很长时间。相反,当我搜索一些已知短语时,我会在一秒钟内得到结果。
我查看了页面的控制台:
The resource from “https://xxxxxx.readthedocs.io/en/latest/_static/css/yy.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff). Read the Docs search failed. Falling back to Sphinx search.
我已经尝试过:
[conf.py] 我有一行:
html_css_files = [ "css/yy.css", ]
所以我添加了:
def setup(app) 中的
app.add_css_file(html_css_files)
:
但这导致了 readthedocs 中的构建错误
我在conf.py中添加了:
notfound_urls_prefix = "/projects/xxxxxx/en/latest/"
但这也没有帮助。
你遇到过类似的事情吗?如果是这样,您是如何解决这个问题的?
最佳答案
最终,根本原因是在其他地方。 当我查看 rtd 上的原始输出时,我发现 sphinx_rtd_theme 是随 0.4.3 安装的,这不是最新的。最新的是0.5.2。所以我将最新版本固定在我的 docs/requiremets.txt 中。这解决了搜索问题。
关于python - 当页面上不存在该短语时,"Searching..."需要永远读取文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68709496/