Fix #4701: viewcode: Misplaced `<div>` in viewcode html output

This commit is contained in:
Takeshi KOMIYA committed 2018-03-05 23:46:34 +09:00
1 parent 8e0cca01e5
commit f1c6c22e84
3 files changed
+13 -1

No files matched your search

+1
View File
@@ -20,6 +20,7 @@ Bugs fixed
* #4685: autosummary emits meaningless warnings
* autodoc: crashed when invalid options given
* pydomain: always strip parenthesis if empty (refs: #1042)
* #4701: viewcode: Misplaced ``<div>`` in viewcode html output
Testing
--------
+1 -1
View File
@@ -178,7 +178,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[min(end - 1, maxindex)] += '</div>'
lines[min(end, maxindex)] += '</div>'
# try to find parents (for submodules)
parents = []
parent = modname
+11
View File
@@ -38,6 +38,17 @@ def test_viewcode(app, status, warning):
# the next assert fails, until the autodoc bug gets fixed
assert result.count('this is the class attribute class_attr') == 2
result = (app.outdir / '_modules/spam/mod1.html').text(encoding='utf-8')
result = re.sub('<span class=".*?">', '<span>', result) # filter pygments classes
assert ('<div class="viewcode-block" id="Class1"><a class="viewcode-back" '
'href="../../index.html#spam.Class1">[docs]</a>'
'<span>@decorator</span>\n'
'<span>class</span> <span>Class1</span>'
'<span>(</span><span>object</span><span>):</span>\n'
' <span>&quot;&quot;&quot;</span>\n'
'<span> this is Class1</span>\n'
'<span> &quot;&quot;&quot;</span></div>\n') in result
@pytest.mark.sphinx(testroot='ext-viewcode', tags=['test_linkcode'])
def test_linkcode(app, status, warning):