sphinx覆盖模板块无法识别

时间:2015-07-28 13:14:26

标签: templates jinja2 python-sphinx

我试图添加一个链接到我用于我的文档页面页脚的图标,但我似乎无法弄清楚如何复制此链接。我跟随this教程,但没有运气。我创建了一个文件_templates/layout.html

{% extends "!layout.html" %}
{% block footer %}
    <li><a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0">CC BY 3.0</a></li>
    {{ super() }}
{% endblock %}

然后在我的conf.py我做

templates_path = ['_templates']

# ...

html_theme = 'sphinx_rtd_theme'

问题在于,当我构建时,页面的页脚中不会显示任何额外内容。我最初认为sphinx没有找到我的文件,但是如果我将{% extends "!layout.html" %}更改为{% extends "layout.html" %}我就会收到错误

Running Sphinx v1.3.1
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 30 source files that are out of date
updating environment: 0 added, 0 changed, 0 removed
looking for now-outdated files... none found
preparing documents... done
writing output... [  3%] dev/conventions
Exception occurred:
  File "C:\...\Anaconda\lib\site-packages\jinja2\utils.py", line 389,
 in __getitem__
    if self._queue[-1] != key:
RuntimeError: maximum recursion depth exceeded in cmp
The full traceback has been saved in c:\...\appdata\local\temp\1\sphi
nx-err-tjhk_m.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message c
an be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphin
x/issues>. Thanks!

所以我知道狮身人面像看到了我的文件,但它似乎没有写任何东西。我做错了什么?

1 个答案:

答案 0 :(得分:0)

我最终遇到的问题是我覆盖了错误的文件,而layout.html确实实现了页脚块,这不是我的块期待加入。相反,sphinx_rtd_theme有一个footer.html文件,我最终覆盖了它,一切都按预期工作。