如何将自定义 css 文件添加到 Sphinx? [英] How to add custom css file to Sphinx?

查看:75
本文介绍了如何将自定义 css 文件添加到 Sphinx?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何添加自定义 css 文件?以下配置不起作用:

How can I add a custom css file? The following config does not work:

# conf.py
html_static_path = ['_static']
html_theme = 'default'
html_theme_options = {
  'cssfiles': ['_static/style.css']
}

结果:

C:\temp\test-docs\docs>make html
Running Sphinx v1.2.2
loading pickled environment... not yet created
building [html]: targets for 2 source files that are out of date
updating environment: 2 added, 0 changed, 0 removed
reading sources... [ 50%] help
reading sources... [100%] index

looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents...
Theme error:
unsupported theme option 'cssfiles' given

推荐答案

更简单的方法是将其添加到您的 conf.py 中:

A simpler way is to add this to your conf.py:

def setup(app):
    app.add_css_file('css/custom.css')  # may also be an URL

然后将文件放入_static/css/文件夹.

Then put the file into the _static/css/ folder.

这篇关于如何将自定义 css 文件添加到 Sphinx?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆