自定义 sphinxdoc 主题 [英] Customize sphinxdoc theme
问题描述
是否有一种简单的方法可以自定义现有的 sphinxdoc
主题?对于默认主题,有很多主题属性,但是在 sphinxdoc 中我什至无法设置徽标或更改某些颜色.
Is there an easy way to customize the existing sphinxdoc
theme? For the default theme, there are many theme-attributes, but in sphinxdoc I can't even set a logo or change some colors.
或者你能给我推荐一个我可以学习如何修改主题的网站吗?
Or can you recommend me a site where I can learn how to modify themes?
推荐答案
我只想在我的狮身人面像医生.我是这样做的:
All I wanted is to add ReST strikethrough in my sphinx doc. Here is how I did it:
$ cd my-sphinx-dir
$ mkdir -p theme/static
$ touch theme/theme.conf
$ touch theme/static/style.css
在theme/theme.conf
中:
[theme]
inherit = default
stylesheet = style.css
pygments_style = pygments.css
(这使它看起来像默认主题(l. 2))
(this makes it look like the default theme (l. 2))
在theme/static/style.css
中:
@import url("default.css"); /* make sure to sync this with the base theme's css filename */
.strike {
text-decoration: line-through;
}
然后,在您的 conf.py 中:
Then, in your conf.py:
html_theme = 'theme' # use the theme in subdir 'theme'
html_theme_path = ['.'] # make sphinx search for themes in current dir
更多信息:https://sphinx.readthedocs.io/en/master/主题.html.
(可选)在 global.rst 中:
(Optional) In global.rst:
.. role:: strike
:class: strike
在example.rst中:
and in a example.rst:
.. include:: global.rst
:strike:`This looks like it is outdated.`
这篇关于自定义 sphinxdoc 主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!