【发布时间】:2021-04-02 12:46:13
【问题描述】:
我在向我的 Sphinx .html 文件添加自定义页脚时遇到了一些问题。我正在使用 sphinx_rtd_theme。我已经检查了这个post 并尝试了它(以及 cmets 中的一些建议)但无济于事。我不确定我错过了什么。抱歉,如果我没有在此处发布足够的内容以实际指出导致问题的原因。感谢您提供任何帮助或建议!
我的 css 主题文件(我不是 HTML/CSS 人!)已经(很差地)修改过,但我认为这不重要吗?我唯一能想到的另一件事是,当我重新编译输出文件时,也许我必须做一些特别的事情。我只是使用:
make clean html && make html
我的conf.py 位于:root/source/conf.py。以下是我的conf.py 文件的一些摘录:
import sphinx_rtd_theme
project = 'Project Name'
copyright = '2021, My Company'
author = 'My Name, Coworker Name'
master_doc = 'Home'
extensions = ["sphinx_rtd_theme", "sphinx.ext.todo"]
todo_include_todos = True
templates_path = ['_templates']
source_suffix = ['.rst']
html4_writer = True
html_theme = 'sphinx_rtd_theme'
# html_theme_path = ['_static']
html_static_path = ['_static']
# html_extra_path = []
html_show_sphinx = True
html_show_copyright = True
html_style = 'css/my_theme.css'
这是我已覆盖的layout.html 文件。它位于评论中显示的路径中。
<!-- layout.html
* Place this file in root/source/_templates
* -->
{% extends "!layout.html" %}
{% block extrahead %}
{{super}}
<link href="{{ pathto("_static/my_theme.css", True) }}" rel="stylesheet" type="text/css">
{% endblock %}
{% block extrafooter %}
{{super}}
<div class="footer">
My custom footer just needs to add a single sentance to the existing footer.
</div>
{% endblock %}
【问题讨论】:
-
@LexLi 我没有构建一个全新的模板...我正在尝试向现有模板的现有部分添加一行。
-
即使不是完整的主题,您也需要具备相同水平的 HTML/JavaScript/CSS 专业知识才能自定义几行代码。
-
sphinx_rtd_theme 是一个独立于 Sphinx 及其默认主题的包,因此该技术需要修改。它的configuration options 开箱即用是有限的。您可以分叉包并修改主题模板。我不知道有什么其他方法可以扩展它的模板,但是有一个open issue。
标签: html css themes python-sphinx