mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #2636 from tk0miya/rescue_old_styled_indices
Fix #2633: Sphinx crashes with old styled indices
This commit is contained in:
commit
5c42bb0172
1
CHANGES
1
CHANGES
@ -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)
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user