自定义sphinxdoc主题

发布于 2021-01-29 18:57:50

有没有简单的方法可以自定义现有sphinxdoc主题?对于默认主题,有很多主题属性,但是在sphinxdoc中,我什至无法设置徽标或更改某些颜色。

还是可以向我推荐一个可以学习如何修改主题的网站?

关注者
0
被浏览
146
1 个回答
  • 面试哥
    面试哥 2021-01-29
    为面试而生,有面试问题,就找面试哥。

    我只想在我的狮身人面像文档中添加ReST删除线。这是我的做法:

    $ 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
    

    (这使其看起来像默认主题(图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中:

    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/theming.html

    (可选)在global.rst中:

    .. role:: strike
       :class: strike
    

    并在example.rst中:

    .. include:: global.rst
    
    :strike:`This looks like it is outdated.`
    


知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看