Customize sphinxdoc theme

后端 未结 4 1961
礼貌的吻别
礼貌的吻别 2020-12-01 04:58

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 log

4条回答
  •  不思量自难忘°
    2020-12-01 05:30

    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.`
    

提交回复
热议问题