mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix all files are treated as reST if old styled source_suffix used
This commit is contained in:
parent
0cdd9ee72a
commit
2b6c8b33be
@ -371,11 +371,14 @@ def convert_source_suffix(app, config):
|
||||
"""
|
||||
source_suffix = config.source_suffix
|
||||
if isinstance(source_suffix, string_types):
|
||||
# if str, considers as reST
|
||||
config.source_suffix = OrderedDict({source_suffix: 'restructuredtext'}) # type: ignore
|
||||
# if str, considers as default filetype (None)
|
||||
#
|
||||
# The default filetype is determined on later step.
|
||||
# By default, it is considered as restructuredtext.
|
||||
config.source_suffix = OrderedDict({source_suffix: None}) # type: ignore
|
||||
elif isinstance(source_suffix, (list, tuple)):
|
||||
# if list, considers as all of them are reST
|
||||
config.source_suffix = OrderedDict([(s, 'restructuredtext') for s in source_suffix]) # type: ignore # NOQA
|
||||
# if list, considers as all of them are default filetype
|
||||
config.source_suffix = OrderedDict([(s, None) for s in source_suffix]) # type: ignore # NOQA
|
||||
elif isinstance(source_suffix, dict):
|
||||
# if dict, convert it to OrderedDict
|
||||
config.source_suffix = OrderedDict(config.source_suffix) # type: ignore
|
||||
|
@ -233,7 +233,8 @@ class SphinxComponentRegistry(object):
|
||||
# type: (unicode) -> unicode
|
||||
for suffix, filetype in iteritems(self.source_suffix):
|
||||
if filename.endswith(suffix):
|
||||
return filetype
|
||||
# If default filetype (None), considered as restructuredtext.
|
||||
return filetype or 'restructuredtext'
|
||||
else:
|
||||
raise FiletypeNotFoundError
|
||||
|
||||
@ -273,8 +274,8 @@ class SphinxComponentRegistry(object):
|
||||
try:
|
||||
filetype = self.get_filetype(filename)
|
||||
input_class = self.source_inputs[filetype]
|
||||
except FiletypeNotFoundError:
|
||||
# use special source_input for unknown file-type '*' (if exists)
|
||||
except (FiletypeNotFoundError, KeyError):
|
||||
# use special source_input for unknown filetype
|
||||
input_class = self.source_inputs.get('*')
|
||||
|
||||
if input_class is None:
|
||||
@ -377,6 +378,10 @@ def merge_source_suffix(app):
|
||||
for suffix in app.registry.source_suffix:
|
||||
if suffix not in app.config.source_suffix:
|
||||
app.config.source_suffix[suffix] = suffix
|
||||
elif app.config.source_suffix[suffix] is None:
|
||||
# filetype is not specified (default filetype).
|
||||
# So it overrides default filetype by extensions setting.
|
||||
app.config.source_suffix[suffix] = suffix
|
||||
|
||||
# copy config.source_suffix to registry
|
||||
app.registry.source_suffix = app.config.source_suffix
|
||||
|
Loading…
Reference in New Issue
Block a user