diff --git a/CHANGES b/CHANGES index bf865f60d..8166cf945 100644 --- a/CHANGES +++ b/CHANGES @@ -6,7 +6,7 @@ New features added * Configuration: - - The new ``html_add_permalinks`` config value can be used to +- The new ``html_add_permalinks`` config value can be used to switch off the generated "paragraph sign" permalinks for each heading and definition environment. @@ -21,6 +21,12 @@ New features added command line. +Release 0.5.1 (in development) +============================== + +* Don't crash on empty index entries, only emit a warning. + + Release 0.5 (Nov 23, 2008) -- Birthday release! =============================================== diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py index 03df20770..b63d139c8 100644 --- a/sphinx/directives/other.py +++ b/sphinx/directives/other.py @@ -205,7 +205,10 @@ def index_directive(name, arguments, options, content, lineno, # shorthand notation for single entries else: for value in entry.split(','): - ne.append(('single', value.strip(), targetid, value.strip())) + value = value.strip() + if not value: + continue + ne.append(('single', value, targetid, value)) return [indexnode, targetnode] index_directive.arguments = (1, 0, 1) diff --git a/sphinx/environment.py b/sphinx/environment.py index be9576c02..c03da1100 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -1137,25 +1137,42 @@ class BuildEnvironment: pass for fn, entries in self.indexentries.iteritems(): - # new entry types must be listed in directives.py! + # new entry types must be listed in directives/other.py! for type, string, tid, alias in entries: if type == 'single': try: entry, subentry = string.split(';', 1) except ValueError: entry, subentry = string, '' + if not entry: + self.warn(fn, 'invalid index entry %r' % string) + continue add_entry(entry.strip(), subentry.strip()) elif type == 'pair': - first, second = map(lambda x: x.strip(), string.split(';', 1)) + try: + first, second = map(lambda x: x.strip(), + string.split(';', 1)) + if not first or not second: + raise ValueError + except ValueError: + self.warn(fn, 'invalid pair index entry %r' % string) + continue add_entry(first, second) add_entry(second, first) elif type == 'triple': - first, second, third = map(lambda x: x.strip(), string.split(';', 2)) + try: + first, second, third = map(lambda x: x.strip(), + string.split(';', 2)) + if not first or not second or not third: + raise ValueError + except ValueError: + self.warn(fn, 'invalid triple index entry %r' % string) + continue add_entry(first, second+' '+third) add_entry(second, third+', '+first) add_entry(third, first+' '+second) else: - self.warn(fn, "unknown index entry type %r" % type) + self.warn(fn, 'unknown index entry type %r' % type) newlist = new.items() newlist.sort(key=lambda t: t[0].lower())