diff --git a/sphinx/environment/collectors/indexentries.py b/sphinx/environment/collectors/indexentries.py index a9ba897d0..2a5abcc8e 100644 --- a/sphinx/environment/collectors/indexentries.py +++ b/sphinx/environment/collectors/indexentries.py @@ -50,11 +50,7 @@ class IndexEntriesCollector(EnvironmentCollector): node.parent.remove(node) else: for entry in node['entries']: - if len(entry) == 5: - # Since 1.4: new index structure including index_key (5th column) - entries.append(entry) - else: - entries.append(entry + (None,)) + entries.append(entry) def setup(app): diff --git a/sphinx/util/compat.py b/sphinx/util/compat.py index 43ced1f5e..9fa0d56ad 100644 --- a/sphinx/util/compat.py +++ b/sphinx/util/compat.py @@ -14,9 +14,12 @@ from __future__ import absolute_import import sys import warnings +from docutils.utils import get_source_line from six import string_types, iteritems -from sphinx.deprecation import RemovedInSphinx30Warning +from sphinx import addnodes +from sphinx.deprecation import RemovedInSphinx30Warning, RemovedInSphinx40Warning +from sphinx.transforms import SphinxTransform from sphinx.util import import_object if False: @@ -52,8 +55,23 @@ def register_application_for_autosummary(app): autosummary._app = app +class IndexEntriesMigrator(SphinxTransform): + """Migrating indexentries from old style (4columns) to new style (5columns).""" + default_priority = 700 + + def apply(self): + for node in self.document.traverse(addnodes.index): + for entries in node['entries']: + if len(entries) == 4: + source, line = get_source_line(node) + warnings.warn('An old styled index node found: %r at (%s:%s)' % + (node, source, line), RemovedInSphinx40Warning) + entries.extend([None]) + + def setup(app): # type: (Sphinx) -> Dict[unicode, Any] + app.add_transform(IndexEntriesMigrator) app.connect('config-inited', deprecate_source_parsers) app.connect('builder-inited', register_application_for_autosummary)