mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Refactor needs_sphinx
This commit is contained in:
@@ -133,12 +133,14 @@ class Sphinx(object):
|
||||
self.config.check_unicode(self.warn)
|
||||
# defer checking types until i18n has been initialized
|
||||
|
||||
# initialize some limited config variables before loading extensions
|
||||
self.config.pre_init_values(self.warn)
|
||||
|
||||
# check the Sphinx version if requested
|
||||
needs_sphinx = self.config.get_needs_sphinx()
|
||||
if needs_sphinx and needs_sphinx > sphinx.__display_version__:
|
||||
if self.config.needs_sphinx and self.config.needs_sphinx > sphinx.__display_version__:
|
||||
raise VersionRequirementError(
|
||||
'This project needs at least Sphinx v%s and therefore cannot '
|
||||
'be built with this version.' % needs_sphinx)
|
||||
'be built with this version.' % self.config.needs_sphinx)
|
||||
|
||||
# set confdir to srcdir if -C given (!= no confdir); a few pieces
|
||||
# of code expect a confdir to be set
|
||||
|
||||
@@ -338,9 +338,11 @@ class Config(object):
|
||||
'characters; this can lead to Unicode errors occurring. '
|
||||
'Please use Unicode strings, e.g. %r.' % (name, u'Content'))
|
||||
|
||||
def get_needs_sphinx(self):
|
||||
"""Obtain the value of ``needs_sphinx``"""
|
||||
return self.overrides.get('needs_sphinx') or self._raw_config.get('needs_sphinx')
|
||||
def pre_init_values(self, warn):
|
||||
"""Initialize some limited config variables before loading extensions"""
|
||||
variables = ['needs_sphinx']
|
||||
for name in variables:
|
||||
self.__dict__[name] = self.overrides.get(name) or self._raw_config.get(name)
|
||||
|
||||
def init_values(self, warn):
|
||||
config = self._raw_config
|
||||
|
||||
Reference in New Issue
Block a user