Skip to content

Commit

Permalink
Revert CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Jul 28, 2023
1 parent fc16aeb commit 4b71459
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions sphinx/ext/viewcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,16 @@ def collect_pages(app: Sphinx) -> Generator[tuple[str, dict[str, Any], str], Non
lines[0:1] = [before + '<pre>', after]
# nothing to do for the last line; it always starts with </pre> anyway
# now that we have code lines (starting at index 1), insert anchors for
# the collected tags
# the collected tags (HACK: this only works if the tag boundaries are
# properly nested!)
max_index = len(lines) - 1
for name, docname in used.items():
type, start, end = tags[name]
backlink = urito(pagename, docname) + '#' + refname + '.' + name
lines[start] = (
'<a class="viewcode-block viewcode-back" ' +
f'id="{name}" href="{backlink}">{_("[docs]")}</a>\n' +
lines[start])
f'<div class="viewcode-block" id="{name}">\n'
f'<a class="viewcode-back" href="{backlink}">{_("[docs]")}</a>\n' + lines[start])
lines[min(end, max_index)] += '</div>\n'

# try to find parents (for submodules)
parents = []
Expand Down
4 changes: 2 additions & 2 deletions tests/test_ext_viewcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def check_viewcode_output(app, status, warning):

result = (app.outdir / '_modules/spam/mod1.html').read_text(encoding='utf8')
result = re.sub('<span class="[^"]{,2}">', '<span>', result) # filter pygments classes
assert ('<a class="viewcode-block viewcode-back" id="Class1" '
'href="../../index.html#spam.Class1">[docs]</a>\n') in result
assert ('<div class="viewcode-block" id="Class1">\n'
'<a class="viewcode-back" href="../../index.html#spam.Class1">[docs]</a>\n') in result
assert '<span>@decorator</span>\n' in result
assert '<span>class</span> <span>Class1</span><span>:</span>\n' in result
if pygments.__version__ >= '2.14.0':
Expand Down

0 comments on commit 4b71459

Please sign in to comment.