mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #5911 from tk0miya/refactor_versioning_method
env.set_versioning_method() allows callable object as a method
This commit is contained in:
commit
efd5328c34
@ -265,7 +265,7 @@ class BuildEnvironment:
|
|||||||
self.settings.setdefault('smart_quotes', True)
|
self.settings.setdefault('smart_quotes', True)
|
||||||
|
|
||||||
def set_versioning_method(self, method, compare):
|
def set_versioning_method(self, method, compare):
|
||||||
# type: (str, bool) -> None
|
# type: (Union[str, Callable], bool) -> None
|
||||||
"""This sets the doctree versioning method for this environment.
|
"""This sets the doctree versioning method for this environment.
|
||||||
|
|
||||||
Versioning methods are a builder property; only builders with the same
|
Versioning methods are a builder property; only builders with the same
|
||||||
@ -273,9 +273,13 @@ class BuildEnvironment:
|
|||||||
raise an exception if the user tries to use an environment with an
|
raise an exception if the user tries to use an environment with an
|
||||||
incompatible versioning method.
|
incompatible versioning method.
|
||||||
"""
|
"""
|
||||||
|
if callable(method):
|
||||||
|
condition = method
|
||||||
|
else:
|
||||||
if method not in versioning_conditions:
|
if method not in versioning_conditions:
|
||||||
raise ValueError('invalid versioning method: %r' % method)
|
raise ValueError('invalid versioning method: %r' % method)
|
||||||
condition = versioning_conditions[method]
|
condition = versioning_conditions[method]
|
||||||
|
|
||||||
if self.versioning_condition not in (None, condition):
|
if self.versioning_condition not in (None, condition):
|
||||||
raise SphinxError(__('This environment is incompatible with the '
|
raise SphinxError(__('This environment is incompatible with the '
|
||||||
'selected builder, please choose another '
|
'selected builder, please choose another '
|
||||||
|
Loading…
Reference in New Issue
Block a user