首页 > 解决方案 > 修复 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() }}线吗?

标签: python-sphinx

解决方案


目前,可以忽略警告。一切仍然会奏效。但在 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) 中。

请参阅https://github.com/readthedocs/sphinx_rtd_theme/commit/a49a812c8821123091166fae1897d702cdc2d627#diff-b3d4a9c32d5abd89b9214dcfbb2ece79


推荐阅读