Merge branch 'stable'

This commit is contained in:
Takeshi KOMIYA
2017-10-21 13:45:56 +09:00
4 changed files with 19 additions and 1 deletions

View File

@@ -114,6 +114,7 @@ Bugs fixed
* #4152: HTML writer crashes if a field list is placed on top of the document
* #4063: Sphinx crashes when labeling directive ``.. todolist::``
* #4134: [doc] :file:`docutils.conf` is not documented explicitly
* #4169: Chinese language doesn't trigger Chinese search automatically
Testing
--------

View File

@@ -217,7 +217,7 @@ def load_mappings(app):
if isinstance(value, (list, tuple)):
# new format
name, (uri, inv) = key, value # type: ignore
name, (uri, inv) = key, value
if not isinstance(name, string_types):
logger.warning('intersphinx identifier %r is not string. Ignored', name)
continue

View File

@@ -265,6 +265,11 @@ class IndexBuilder(object):
# objtype index -> (domain, type, objname (localized))
lang_class = languages.get(lang) # type: Type[SearchLanguage]
# add language-specific SearchLanguage instance
# fallback; try again with language-code
if lang_class is None and '_' in lang:
lang_class = languages.get(lang.split('_')[0])
if lang_class is None:
self.lang = SearchEnglish(options) # type: SearchLanguage
elif isinstance(lang_class, str):

View File

@@ -228,3 +228,15 @@ def test_IndexBuilder():
}
assert index._objtypes == {('dummy', 'objtype'): 0}
assert index._objnames == {0: ('dummy', 'objtype', 'objtype')}
def test_IndexBuilder_lookup():
env = DummyEnvironment('1.0', {})
# zh
index = IndexBuilder(env, 'zh', {}, None)
assert index.lang.lang == 'zh'
# zh_CN
index = IndexBuilder(env, 'zh_CN', {}, None)
assert index.lang.lang == 'zh'