mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#424: Fix IndexError in viewcode extension.
This commit is contained in:
parent
d3d93a54f0
commit
7e7593c4dd
@ -104,6 +104,7 @@ def collect_pages(app):
|
|||||||
# now that we have code lines (starting at index 1), insert anchors for
|
# 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
|
# the collected tags (HACK: this only works if the tag boundaries are
|
||||||
# properly nested!)
|
# properly nested!)
|
||||||
|
maxindex = len(lines)
|
||||||
for name, docname in used.iteritems():
|
for name, docname in used.iteritems():
|
||||||
type, start, end = tags[name]
|
type, start, end = tags[name]
|
||||||
backlink = urito(pagename, docname) + '#' + modname + '.' + 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" '
|
'<div class="viewcode-block" id="%s"><a class="viewcode-back" '
|
||||||
'href="%s">%s</a>' % (name, backlink, _('[docs]'))
|
'href="%s">%s</a>' % (name, backlink, _('[docs]'))
|
||||||
+ lines[start])
|
+ lines[start])
|
||||||
lines[end - 1] += '</div>'
|
lines[min(end - 1, maxindex)] += '</div>'
|
||||||
# try to find parents (for submodules)
|
# try to find parents (for submodules)
|
||||||
parents = []
|
parents = []
|
||||||
parent = modname
|
parent = modname
|
||||||
|
Loading…
Reference in New Issue
Block a user