diff options
author | Takayuki SHIMIZUKAWA <shimizukawa@gmail.com> | 2016-01-15 11:55:09 +0900 |
---|---|---|
committer | Takayuki SHIMIZUKAWA <shimizukawa@gmail.com> | 2016-01-15 11:55:09 +0900 |
commit | 4391521b814a5bd52edcec211f2676a5071e34cb (patch) | |
tree | 0f1c152774fb2a2e867a15ce6117b77d58a8660f /sphinx/theming.py | |
parent | 6b7b51a55aa0dc419d9fd8dae17bbec197bd2724 (diff) | |
parent | 8ca05af9bc199aa59209dc9552aeec3889ce042c (diff) | |
download | sphinx-git-4391521b814a5bd52edcec211f2676a5071e34cb.tar.gz |
Merge pull request #2087 from cppformat/optional-rtd
refs #2087, #2086, #1845, #2097: Make sphinx_rtd_theme optional
Diffstat (limited to 'sphinx/theming.py')
-rw-r--r-- | sphinx/theming.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/sphinx/theming.py b/sphinx/theming.py index 01f0a7089..b27368c79 100644 --- a/sphinx/theming.py +++ b/sphinx/theming.py @@ -27,7 +27,6 @@ from sphinx import package_dir from sphinx.errors import ThemeError import alabaster -import sphinx_rtd_theme NODEFAULT = object() THEMECONF = 'theme.conf' @@ -71,7 +70,13 @@ class Theme(object): @classmethod def load_extra_theme(cls, name): - if name in ('alabaster', 'sphinx_rtd_theme'): + themes = ['alabaster'] + try: + import sphinx_rtd_theme + themes.append('sphinx_rtd_theme') + except ImportError: + pass + if name in themes: if name == 'alabaster': themedir = alabaster.get_path() # alabaster theme also requires 'alabaster' extension, it will be loaded @@ -97,8 +102,12 @@ class Theme(object): if name not in self.themes: self.load_extra_theme(name) if name not in self.themes: - raise ThemeError('no theme named %r found ' - '(missing theme.conf?)' % name) + if name == 'sphinx_rtd_theme': + raise ThemeError('sphinx_rtd_theme has been unbundled since version ' + '1.4.0. Please install it manually.') + else: + raise ThemeError('no theme named %r found ' + '(missing theme.conf?)' % name) self.name = name # Do not warn yet -- to be compatible with old Sphinxes, people *have* |