sphinx 升级到6.x后的Jquery问题

sphinx 升级到6.0 后,以前对于jquery的默认引用方式发生了改变

以前在编译后的html中jquery是如下引用的:

<script src="_static/jquery.js"></script>

而升级到6.0后,对于jquery 是一个googleapi的远程jquery调用,这会导致sphinx 半天才能打开。

解决这个问题的方案是:

升级所有的包,包括sphinxcontrib-jquery,然后进行争取的配置。

在sphinx 的changelog中对于这点有明确的说明:

#7405: Removed the jQuery and underscore.js JavaScript frameworks.
These frameworks are no longer be automatically injected into themes from Sphinx 6.0. If you develop a theme or extension that uses thejQuery, $, or $u global objects, you need to update yourJavaScript to modern standards, or use the mitigation below.
The first option is to use the sphinxcontrib.jquery extension, which has been developed by the Sphinx team and contributors. To use this, addsphinxcontrib.jquery to the extensions list in conf.py, or callapp.setup_extension("sphinxcontrib.jquery") if you develop a Sphinx themeor extension.
The second option is to manually ensure that the frameworks are present.To re-add jQuery and underscore.js, you will need to copy jquery.js andunderscore.js from the Sphinx repository to your static directory,and add the following to your layout.html:
{%- block scripts %}
    <script src="{{ pathto('_static/jquery.js', resource=True) }}"></script>
    <script src="{{ pathto('_static/underscore.js', resource=True) }}"></script>
    {{ super() }}
{%- endblock %}

原文地址:https://www.sphinx-doc.org/en/master/changes.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值