python-sphinx - 修复 Sphinx RemovedInSphinx30Warning
问题描述
Sphinx v2.1.2
尝试使用和构建我的文档时收到两条警告消息sphinx-rtd-theme 0.4.3
。
第一个是:
/docs/numsec.py:50: RemovedInSphinx30Warning: app.override_domain() is deprecated. Use app.add_domain() with override option instead.
app.override_domain(CustomStandardDomain)
我的那部分numsec.py
看起来像:
def setup(app):
app.override_domain(CustomStandardDomain)
app.connect('doctree-resolved', doctree_resolved)
我不知道什么override option
意思。我试过用它替换那条线,app.add_domain()
但app.add_domain(CustomStandardDomain)
都不管用。
第二条警告信息是:
/miniconda3/envs/py3/lib/python3.7/site-packages/sphinx_rtd_theme/search.html:20: RemovedInSphinx30Warning: To modify script_files in the theme is deprecated. Please insert a <script> tag directly in your theme instead.
{{ super() }}
我不知道要解决这个问题。我应该删除{{ super() }}
线吗?
解决方案
目前,可以忽略警告。一切仍然会奏效。但在 Sphinx 3.0(尚未发布)中,已弃用的功能将停止工作。
如果您更换,第一个警告就会消失
app.override_domain(CustomStandardDomain)
和
app.add_domain(CustomStandardDomain, override=True)
在 numsec.py 中(我认为它与https://github.com/jterrace/sphinxtr/blob/master/extensions/numsec.py相同)。
第二个警告是关于 sphinx-rtd-theme 中 search.html 中已弃用的功能。这已在 GitHub 存储库中修复,但该修复不在最新版本 (0.4.3) 中。
推荐阅读
- vega - 是否可以控制 vega 图表中非同级标记的分层?
- discord.py - 我怎样才能让机器人改变它的存在(听、看、玩等)以他们的名字显示在不和谐上?
- python - 多个实例访问的 Python 类变量
- angular - 如何在单击按钮时打开一个新窗口说提交按钮并应用另一个组件中存在的功能来显示一些数据?
- python - 用于图像预测的 ConvLSTM 模型的输入形状
- python - 如何修复 TypeError:预期的字符串或类似字节的对象
- javascript - 如何通过遍历DOM来获取元素的值
- jenkins - 如何在 Jenkinsfile 中使用环境变量
- excel - 将共享组 Outlook 日历约会导入 Excel
- excel - 查找特定文本并返回更改单元格颜色的单元格