summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-10-30 16:47:05 +0000
committerGeorg Brandl <georg@python.org>2010-10-30 16:47:05 +0000
commitc62a19bca5b262ab46dbc7737157352805424f96 (patch)
tree71743620ddd9173c0661482cb0c04e971c5d541b
parent65505907f1f09ccc2385d21758254f9516abb5de (diff)
downloadsphinx-git-c62a19bca5b262ab46dbc7737157352805424f96.tar.gz
Make Theme class usable without a builder object.
-rw-r--r--sphinx/builders/changes.py3
-rw-r--r--sphinx/builders/html.py3
-rw-r--r--sphinx/theming.py11
3 files changed, 10 insertions, 7 deletions
diff --git a/sphinx/builders/changes.py b/sphinx/builders/changes.py
index 980ed7606..488bc0374 100644
--- a/sphinx/builders/changes.py
+++ b/sphinx/builders/changes.py
@@ -30,7 +30,8 @@ class ChangesBuilder(Builder):
def init(self):
self.create_template_bridge()
- Theme.init_themes(self)
+ Theme.init_themes(self.confdir, self.config.html_theme_path,
+ warn=self.warn)
self.theme = Theme('default')
self.templates.init(self, self.theme)
diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py
index b85e94423..3d4370530 100644
--- a/sphinx/builders/html.py
+++ b/sphinx/builders/html.py
@@ -117,7 +117,8 @@ class StandaloneHTMLBuilder(Builder):
return self.config.html_theme, self.config.html_theme_options
def init_templates(self):
- Theme.init_themes(self)
+ Theme.init_themes(self.confdir, self.config.html_theme_path,
+ warn=self.warn)
themename, themeoptions = self.get_theme_config()
self.theme = Theme(themename)
self.theme_options = themeoptions.copy()
diff --git a/sphinx/theming.py b/sphinx/theming.py
index 92e63f31c..42bc44f63 100644
--- a/sphinx/theming.py
+++ b/sphinx/theming.py
@@ -30,13 +30,13 @@ class Theme(object):
themes = {}
@classmethod
- def init_themes(cls, builder):
+ def init_themes(cls, confdir, theme_path, warn=None):
"""Search all theme paths for available themes."""
- cls.themepath = list(builder.config.html_theme_path)
+ cls.themepath = list(theme_path)
cls.themepath.append(path.join(package_dir, 'themes'))
for themedir in cls.themepath[::-1]:
- themedir = path.join(builder.confdir, themedir)
+ themedir = path.join(confdir, themedir)
if not path.isdir(themedir):
continue
for theme in os.listdir(themedir):
@@ -48,8 +48,9 @@ class Theme(object):
tname = theme[:-4]
tinfo = zfile
except Exception:
- builder.warn('file %r on theme path is not a valid '
- 'zipfile or contains no theme' % theme)
+ if warn:
+ warn('file %r on theme path is not a valid '
+ 'zipfile or contains no theme' % theme)
continue
else:
if not path.isfile(path.join(themedir, theme, THEMECONF)):