【发布时间】:2019-02-27 15:51:51
【问题描述】:
我正在尝试使用 Sphinx 结合阅读文档主题编写文档,但搜索功能似乎已损坏。
我在 Windows 10 上运行 Python 3.7 和最新版本的 Sphinx 和 Read the Docs 主题(均与 pip install 一起安装)。构建页面并在浏览器中打开 index.html 后(尝试 Edge 和 Chrome ) 我无法搜索我的离线文档。搜索页面打开但只显示动画Search -> Search . -> Search .. -> Search …,如果我将主题更改回标准主题,搜索将正常工作。
由于搜索适用于标准主题,它似乎不是与浏览器相关的问题,也似乎与我没有在 localhost 上托管页面这一事实有关。
如果我查看控制台中的错误,我会看到两个错误
jquery.js:4 Failed to load file:///C:/user/documentation/_build/html/searchindex.js:
Cross origin requests are only supported for protocol
schemes: http, data, chrome, chrome-extension, https.
和
searchtools.js:144 Uncaught ReferenceError: Stemmer is not defined
at Object.query (searchtools.js:144)
at Object.setIndex (searchtools.js:83)
at searchindex.js:1
我在网上搜索时找不到任何有用的东西来解决这个问题。同样刷新浏览器缓存 (Ctrl + F5),如 https://github.com/rtfd/readthedocs.org/issues/4026 中所述,也不起作用。
有人遇到过同样的问题吗?
【问题讨论】:
-
@mzjn:感谢您的评论。我已经尝试安装旧版本的 sphinx 1.7.9 但这也没有解决问题。
-
如果我以 HTML 格式下载 ReadTheDocs 文档,搜索不起作用的事实是意料之中的,对吧?
标签: python python-sphinx read-the-docs