Saturday, June 6, 2015

Setting a Sphinx theme

To set a theme in Sphinx:

  • find a theme you want to copy.  It will generally be a directory full of files.
  • copy the directory under your project's _templates directory.
  • set the html_theme in conf.py
  • some docs mention setting html_theme_path as well, but it doesn't seem necessary if it's under _templates.
  • There's some nice themes at https://readthedocs.org
Example:

$ ls _templates/
sphinx_rtd_theme/

$ diff conf.py-orig conf.py
113c113,114
< html_theme = 'alabaster'
---
> html_theme = "sphinx_rtd_theme"
> html_theme_path = ["_themes", ]    ### probably not necessary

No comments: