修复Sphinx已删除InSphinx30警告

时间:2019-08-07 19:36:43

标签: python-sphinx

尝试使用Sphinx v2.1.2sphinx-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() }}行吗?

1 个答案:

答案 0 :(得分:2)

目前,可以仅忽略警告。一切仍然会起作用。但是在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