#424: Fix IndexError in viewcode extension.

This commit is contained in:
Georg Brandl 2010-05-26 19:32:17 +02:00
parent d3d93a54f0
commit 7e7593c4dd

View File

@ -104,6 +104,7 @@ def collect_pages(app):
# now that we have code lines (starting at index 1), insert anchors for
# the collected tags (HACK: this only works if the tag boundaries are
# properly nested!)
maxindex = len(lines)
for name, docname in used.iteritems():
type, start, end = tags[name]
backlink = urito(pagename, docname) + '#' + modname + '.' + name
@ -111,7 +112,7 @@ def collect_pages(app):
'<div class="viewcode-block" id="%s"><a class="viewcode-back" '
'href="%s">%s</a>' % (name, backlink, _('[docs]'))
+ lines[start])
lines[end - 1] += '</div>'
lines[min(end - 1, maxindex)] += '</div>'
# try to find parents (for submodules)
parents = []
parent = modname