mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add `sphinx.config.Any
` to represent the config value accepts any type of values
This commit is contained in:
parent
fa385f908e
commit
eda09a717a
2
CHANGES
2
CHANGES
@ -14,6 +14,8 @@ Features added
|
||||
--------------
|
||||
|
||||
* Add :event:`config-inited` event
|
||||
* Add ``sphinx.config.Any`` to represent the config value accepts any type of
|
||||
value
|
||||
|
||||
Bugs fixed
|
||||
----------
|
||||
|
@ -54,6 +54,10 @@ ConfigValue = NamedTuple('ConfigValue', [('name', str),
|
||||
('rebuild', Union[bool, unicode])])
|
||||
|
||||
|
||||
#: represents the config value accepts any type of value.
|
||||
Any = object()
|
||||
|
||||
|
||||
class ENUM(object):
|
||||
"""represents the config value should be a one of candidates.
|
||||
|
||||
@ -102,7 +106,7 @@ class Config(object):
|
||||
figure_language_filename = (u'{root}.{language}{ext}', 'env', [str]),
|
||||
|
||||
master_doc = ('contents', 'env'),
|
||||
source_suffix = (['.rst'], 'env'),
|
||||
source_suffix = (['.rst'], 'env', Any),
|
||||
source_encoding = ('utf-8-sig', 'env'),
|
||||
source_parsers = ({}, 'env'),
|
||||
exclude_patterns = ([], 'env'),
|
||||
@ -205,7 +209,10 @@ class Config(object):
|
||||
if default is None and not permitted:
|
||||
continue # neither inferrable nor expliclitly permitted types
|
||||
current = self[name]
|
||||
if isinstance(permitted, ENUM):
|
||||
if permitted is Any:
|
||||
# any type of value is accepted
|
||||
pass
|
||||
elif isinstance(permitted, ENUM):
|
||||
if not permitted.match(current):
|
||||
logger.warning(CONFIG_ENUM_WARNING.format(
|
||||
name=name, current=current, candidates=permitted.candidates))
|
||||
|
Loading…
Reference in New Issue
Block a user