on master help sign in
Merge pull request #2083 from jfdm/docs/local-rtd-theme

Build docs locally using ReadTheDocs Theme.

commited99f386448be56e1cee1c8cb7177d347609b8c2 authorJan de Muijnck-Hughes <jfdm@users.noreply.github.com> dateTue 31 Mar 2015, 12:29 (12 years ago) parent9429eb6572d70f
2 files changed+17
docs/README.md+6 docs/conf.py+11
docs/README.md+6
@@ -18,6 +18,12 @@ Sphinx can be installed either through your hosts package manager or using pip/e
1818 of readthedocs and be ignored. In the past we had several code-blocks
1919 disappear because of that.
2020
21+The ReadTheDocs theme can be installed using pip as follows:
22+
23+```sh
24+pip install sphinx_rtd_theme
25+```
26+
2127### LaTeX
2228
2329LaTeX can be install either using your systems package manager or direct from TeXLive.
docs/conf.py+11
@@ -15,6 +15,9 @@
1515import sys
1616import os
1717
18+# True if the readthedocs theme is locally installed
19+on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
20+
1821# If extensions (or modules to document with autodoc) are in another directory,
1922# add these directories to sys.path here. If the directory is relative to the
2023# documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -111,6 +114,14 @@ todo_include_todos = True
111114# a list of builtin themes.
112115html_theme = "default"
113116
117+if not on_rtd: # only import and set the theme if we're building docs locally
118+ try:
119+ import sphinx_rtd_theme
120+ html_theme = 'sphinx_rtd_theme'
121+ html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
122+ except ImportError:
123+ html_theme = "default"
124+
114125# Theme options are theme-specific and customize the look and feel of a theme
115126# further. For a list of options available for each theme, see the
116127# documentation.