mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #4701: viewcode: Misplaced `<div>
` in viewcode html output
This commit is contained in:
parent
8e0cca01e5
commit
f1c6c22e84
1
CHANGES
1
CHANGES
@ -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
|
||||
--------
|
||||
|
@ -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
|
||||
|
@ -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>"""</span>\n'
|
||||
'<span> this is Class1</span>\n'
|
||||
'<span> """</span></div>\n') in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='ext-viewcode', tags=['test_linkcode'])
|
||||
def test_linkcode(app, status, warning):
|
||||
|
Loading…
Reference in New Issue
Block a user