summaryrefslogtreecommitdiff
path: root/sphinx/application.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-02-28 10:20:15 +0100
committerGeorg Brandl <georg@python.org>2010-02-28 10:20:15 +0100
commitcb653c494f300f5cc5208524b100878eca8ff8be (patch)
treec41a03f710749352a6795db0867f5bc20500e991 /sphinx/application.py
parentab61a3847381d3d1e40ffabc98b9e49940a4fa29 (diff)
parent59964efbfbcbeed5e0cd19bfae3d230bd3cb40fc (diff)
downloadsphinx-cb653c494f300f5cc5208524b100878eca8ff8be.tar.gz
merge with 0.6
Diffstat (limited to 'sphinx/application.py')
-rw-r--r--sphinx/application.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/sphinx/application.py b/sphinx/application.py
index 3817009f..636d436c 100644
--- a/sphinx/application.py
+++ b/sphinx/application.py
@@ -22,7 +22,8 @@ from docutils.parsers.rst import directives, roles
import sphinx
from sphinx.roles import xfileref_role, innernodetypes
from sphinx.config import Config
-from sphinx.errors import SphinxError, SphinxWarning, ExtensionError
+from sphinx.errors import SphinxError, SphinxWarning, ExtensionError, \
+ VersionRequirementError
from sphinx.builders import BUILTIN_BUILDERS
from sphinx.directives import GenericDesc, Target, additional_xref_types
from sphinx.environment import SphinxStandaloneReader
@@ -109,6 +110,13 @@ class Sphinx(object):
# now that we know all config values, collect them from conf.py
self.config.init_values()
+ # check the Sphinx version if requested
+ if self.config.needs_sphinx and \
+ self.config.needs_sphinx > sphinx.__version__[:3]:
+ raise VersionRequirementError(
+ 'This project needs at least Sphinx v%s and therefore cannot '
+ 'be built with this version.' % self.config.needs_sphinx)
+
if buildername is None:
print >>status, 'No builder selected, using default: html'
buildername = 'html'
@@ -178,9 +186,21 @@ class Sphinx(object):
self.warn('extension %r has no setup() function; is it really '
'a Sphinx extension module?' % extension)
else:
- mod.setup(self)
+ try:
+ mod.setup(self)
+ except VersionRequirementError, err:
+ # add the extension name to the version required
+ raise VersionRequirementError(
+ 'The %s extension used by this project needs at least '
+ 'Sphinx v%s; it therefore cannot be built with this '
+ 'version.' % (extension, err))
self._extensions[extension] = mod
+ def require_sphinx(self, version):
+ # check the Sphinx version if requested
+ if version > sphinx.__version__[:3]:
+ raise VersionRequirementError(version)
+
def import_object(self, objname, source=None):
"""Import an object from a 'module.name' string."""
try:
@@ -330,6 +350,11 @@ class Sphinx(object):
StandaloneHTMLBuilder.script_files.append(
posixpath.join('_static', filename))
+ def add_stylesheet(self, filename):
+ from sphinx.builders.html import StandaloneHTMLBuilder
+ StandaloneHTMLBuilder.css_files.append(
+ posixpath.join('_static', filename))
+
def add_lexer(self, alias, lexer):
from sphinx.highlighting import lexers
if lexers is None: