Merge pull request #2636 from tk0miya/rescue_old_styled_indices

Fix #2633: Sphinx crashes with old styled indices
This commit is contained in:
Takeshi KOMIYA 2016-06-07 13:32:54 +09:00
commit 5c42bb0172
3 changed files with 21 additions and 2 deletions

View File

@ -6,6 +6,7 @@ Bugs fixed
* #2630: Latex sphinx.sty Notice Enviroment formatting problem
* #2632: Warning directives fail in quote environment latex build
* #2633: Sphinx crashes with old styled indices
Release 1.4.3 (released Jun 5, 2016)

View File

@ -15,7 +15,7 @@ from six import string_types, text_type
from sphinx.transforms import ApplySourceWorkaround, ExtraTranslatableNodes, Locale, \
CitationReferences, DefaultSubstitutions, MoveModuleTargets, HandleCodeBlocks, \
AutoNumbering, SortIds, RemoveTranslatableInline
AutoNumbering, AutoIndexUpgrader, SortIds, RemoveTranslatableInline
from sphinx.util import import_object, split_docinfo
@ -59,7 +59,7 @@ class SphinxStandaloneReader(SphinxBaseReader):
"""
transforms = [ApplySourceWorkaround, ExtraTranslatableNodes, Locale, CitationReferences,
DefaultSubstitutions, MoveModuleTargets, HandleCodeBlocks,
AutoNumbering, SortIds, RemoveTranslatableInline]
AutoNumbering, AutoIndexUpgrader, SortIds, RemoveTranslatableInline]
class SphinxI18nReader(SphinxBaseReader):

View File

@ -170,6 +170,24 @@ class ApplySourceWorkaround(Transform):
apply_source_workaround(n)
class AutoIndexUpgrader(Transform):
"""
Detect old style; 4 column based indices and automatically upgrade to new style.
"""
default_priority = 210
def apply(self):
env = self.document.settings.env
for node in self.document.traverse(addnodes.index):
if 'entries' in node and any(len(entry) == 4 for entry in node['entries']):
msg = ('4 column based index found. '
'It might be a bug of extensions you use: %r' % node['entries'])
env.warn_node(msg, node)
for i, entry in enumerate(node['entries']):
if len(entry) == 4:
node['entries'][i] = entry + (None,)
class ExtraTranslatableNodes(Transform):
"""
make nodes translatable