mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add extension version check ability with new config value "needs_extensions".
This commit is contained in:
5
CHANGES
5
CHANGES
@@ -27,8 +27,9 @@ Features added
|
||||
* Added ``sphinx.ext.napoleon`` extension for NumPy and Google style docstring
|
||||
support.
|
||||
* Added support for extension versions (a string returned by ``setup()``, these
|
||||
can be shown in the traceback log files). In the future this might also be
|
||||
used for version checking.
|
||||
can be shown in the traceback log files). Version requirements for extensions
|
||||
can be specified in projects using the new :confval:`needs_extensions` config
|
||||
value.
|
||||
* PR#214: Added stemming support for 14 languages, so that the built-in document
|
||||
search can now handle these. Thanks to Shibukawa Yoshiki.
|
||||
* PR#202: Allow "." and "~" prefixed references in ``:param:`` doc fields
|
||||
|
@@ -201,6 +201,19 @@ General configuration
|
||||
|
||||
.. versionadded:: 1.0
|
||||
|
||||
.. confval:: needs_extensions
|
||||
|
||||
This value can be a dictionary specifying version requirements for extensions
|
||||
in :confval:`extensions`, e.g. ``needs_extensions =
|
||||
{'sphinxcontrib.something': '1.5'}``. The version strings should be in the
|
||||
form ``major.minor``. Requirements do not have to be specified for all
|
||||
extensions, only for those you want to check.
|
||||
|
||||
This requires that the extension specifies its version to Sphinx (see
|
||||
:ref:`dev-extensions` for how to do that).
|
||||
|
||||
.. versionadded:: 1.3
|
||||
|
||||
.. confval:: nitpicky
|
||||
|
||||
If true, Sphinx will warn about *all* references where the target cannot be
|
||||
|
@@ -144,6 +144,21 @@ class Sphinx(object):
|
||||
'This project needs at least Sphinx v%s and therefore cannot '
|
||||
'be built with this version.' % self.config.needs_sphinx)
|
||||
|
||||
# check extension versions if requested
|
||||
if self.config.needs_extensions:
|
||||
for extname, needs_ver in self.config.needs_extensions.items():
|
||||
if extname not in self._extensions:
|
||||
self.warn('needs_extensions config value specifies a '
|
||||
'version requirement for extension %s, but it is '
|
||||
'not loaded' % extname)
|
||||
continue
|
||||
has_ver = self._extension_versions[extname]
|
||||
if has_ver == 'unknown version' or needs_ver > has_ver:
|
||||
raise VersionRequirementError(
|
||||
'This project needs the extension %s at least in '
|
||||
'version %s and therefore cannot be built with the '
|
||||
'loaded version (%s).' % (extname, needs_ver, has_ver))
|
||||
|
||||
# set up translation infrastructure
|
||||
self._init_i18n()
|
||||
# set up the build environment
|
||||
|
@@ -68,6 +68,7 @@ class Config(object):
|
||||
trim_doctest_flags = (True, 'env'),
|
||||
primary_domain = ('py', 'env'),
|
||||
needs_sphinx = (None, None),
|
||||
needs_extensions = ({}, None),
|
||||
nitpicky = (False, 'env'),
|
||||
nitpick_ignore = ([], 'html'),
|
||||
|
||||
|
Reference in New Issue
Block a user