Skip to content

Commit e35e5ff

Browse files
authored
Merge pull request #4278 from italia/extendconfpyctx
make it easier to use a different default theme
2 parents 0f40231 + 96a4b94 commit e35e5ff

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

readthedocs/doc_builder/backends/sphinx.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ def get_config_params(self):
108108
downloads = api.version(self.version.pk).get()['downloads']
109109

110110
data = {
111+
'html_theme': 'sphinx_rtd_theme',
112+
'html_theme_import': 'sphinx_rtd_theme',
111113
'current_version': self.version.verbose_name,
112114
'project': self.project,
113115
'version': self.version,

readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#
1515

1616

17+
import importlib
1718
import sys
1819
import os.path
1920
from six import string_types
@@ -39,31 +40,23 @@ if os.path.exists('_static'):
3940
html_static_path.append('{{ static_path }}')
4041

4142
# Add RTD Theme only if they aren't overriding it already
42-
using_rtd_theme = False
43-
if 'html_theme' in globals():
44-
if html_theme in ['default']:
43+
using_rtd_theme = (
44+
(
45+
'html_theme' in globals() and
46+
html_theme in ['default'] and
4547
# Allow people to bail with a hack of having an html_style
46-
if not 'html_style' in globals():
47-
import sphinx_rtd_theme
48-
html_theme = 'sphinx_rtd_theme'
49-
html_style = None
50-
html_theme_options = {}
51-
if 'html_theme_path' in globals():
52-
html_theme_path.append(sphinx_rtd_theme.get_html_theme_path())
53-
else:
54-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
55-
56-
using_rtd_theme = True
57-
else:
58-
import sphinx_rtd_theme
59-
html_theme = 'sphinx_rtd_theme'
48+
'html_style' not in globals()
49+
) or 'html_theme' not in globals()
50+
)
51+
if using_rtd_theme:
52+
theme = importlib.import_module('{{ html_theme_import }}')
53+
html_theme = '{{ html_theme }}'
6054
html_style = None
6155
html_theme_options = {}
6256
if 'html_theme_path' in globals():
63-
html_theme_path.append(sphinx_rtd_theme.get_html_theme_path())
57+
html_theme_path.append(theme.get_html_theme_path())
6458
else:
65-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
66-
using_rtd_theme = True
59+
html_theme_path = [theme.get_html_theme_path()]
6760

6861
if globals().get('websupport2_base_url', False):
6962
websupport2_base_url = '{{ api_host }}/websupport'

0 commit comments

Comments
 (0)