fal*_*cat 14 colors read-the-docs
我正在为我的API库构建文档,而我正在使用readthedocs.io来托管文档,并使用Sphinx支持.我为Sphinx使用安装了Read The Docs主题pip install,而Read the Docs网站目前正在运行文档.
我想改变文档的颜色.我已经通过他们的GitHub存储库GitHub.com进行了一些搜索,并看到了一些关于编辑sass文件的讨论.但是,我似乎无法找到这些文件的位置.
任何帮助表示赞赏!
Aid*_*ick 16
我相信规范的方法是创建一个_static文件夹,在其中包含CSS文件,然后使用文件夹中的include引用模板中的CSS _templates.
为了演示这一点,您可以尝试简单地覆盖该layout.html文件:首先,_templates在docs文件夹中创建(如果它尚不存在),然后创建一个名为的文件layout.html.
使用以下内容填充:
{% extends "!layout.html" %}
{% block footer %} {{ super() }}
<style>
/* Sidebar header (and topbar for mobile) */
.wy-side-nav-search, .wy-nav-top {
background: #00ff00;
}
/* Sidebar */
.wy-nav-side {
background: #ff0000;
}
</style>
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
一旦你重建了你的文档,你应该看到一个花哨的侧栏和标题.(我在Sphinx/Read The Docs主题实现中使用了类似的技术.查看源代码等以查看我们覆盖的位数.)
您可以通过将自定义 CSS 文件添加到_static. 要真正让 Sphinx 使用该文件,请将其添加到您的conf.py:
def setup(app):
app.add_css_file('custom.css')
Run Code Online (Sandbox Code Playgroud)
示例 CSS ( custom.css) 将侧边栏颜色更改为深绿色(基于@afit 的回答):
.wy-side-nav-search, .wy-nav-top {
background: #0b750a;
}
Run Code Online (Sandbox Code Playgroud)
html_css_files添加 CSS 文件的一种更简单的方法是在 conf.py 中设置:
# custom.css is inside one of the html_static_path folders (e.g. _static)
html_css_files = ["custom.css"]
Run Code Online (Sandbox Code Playgroud)
请参阅:https ://docs.readthedocs.io/en/latest/guides/adding-custom-css.html
小智 5
如果你只是想改变导航标题的颜色,你可以使用这样做html_theme_options的变量conf.py。有一个参数叫做'style_nav_header_background'.
https://sphinx-rtd-theme.readthedocs.io/en/stable/configuring.html#theme-options
| 归档时间: |
|
| 查看次数: |
3561 次 |
| 最近记录: |