Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
194 views
in Technique[技术] by (71.8m points)

python - Customize sphinxdoc theme

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

In theme/theme.conf:

[theme]
inherit = default
stylesheet = style.css
pygments_style = pygments.css

(this makes it look like the default theme (l. 2))

In 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;
}

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

More here: https://sphinx.readthedocs.io/en/master/theming.html.

(Optional) In global.rst:

.. role:: strike
   :class: strike

and in a example.rst:

.. include:: global.rst

:strike:`This looks like it is outdated.`

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...