【发布时间】:2011-07-31 21:53:03
【问题描述】:
如果我有一些文档,例如 Galleria's documentation,我该如何设置它,以便在我运行 make html 命令时,它会在每个页面上添加自定义页脚?
我发现如果我将其输出为 pdf 格式,我可能会使用 conf.py 的 the latex preamble 部分。
谢谢!
【问题讨论】:
标签: linux unix makefile restructuredtext python-sphinx
如果我有一些文档,例如 Galleria's documentation,我该如何设置它,以便在我运行 make html 命令时,它会在每个页面上添加自定义页脚?
我发现如果我将其输出为 pdf 格式,我可能会使用 conf.py 的 the latex preamble 部分。
谢谢!
【问题讨论】:
标签: linux unix makefile restructuredtext python-sphinx
您必须通过提供这样的 html 文件来扩展默认布局:
{% extends '!layout.html' %}
{% block footer %}
<!-- your html code here -->
{% endblock %}
将其保存在_templates/ 子目录中为layout.html 并确保告诉conf.py 在哪里可以找到该目录:
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
更多关于模板的信息可以在这里找到:https://www.sphinx-doc.org/en/master/templating.html
【讨论】:
_templates 目录的默认位置(基于conf.py 中的templates_path 设置)与conf.py 所在的目录相同,应该成为您的source 目录。此外,如果您希望您的页脚具有与默认页脚相同的样式,则需要将页脚的 HTML 包含在 <div class="footer"> 标记中。
{% extends '!footer.html' %} {% block extrafooter %} <!-- your html code here --> {% endblock %}