Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ Bugs fixed
Patch by Jean-François B.
* #13685: gettext: Correctly ignore trailing backslashes.
Patch by Bénédikt Tran.
* #13688: HTML5: Replace ``<em class="property">`` with ``<span class="property">``
for Python attribute type annotations to improve semantic HTML structure.
Patch by Mark O.

Testing
-------
4 changes: 2 additions & 2 deletions sphinx/writers/html5.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,10 @@ def depart_desc_optional(self, node: Element) -> None:
self.param_group_index += 1

def visit_desc_annotation(self, node: Element) -> None:
self.body.append(self.starttag(node, 'em', '', CLASS='property'))
self.body.append(self.starttag(node, 'span', '', CLASS='property'))

def depart_desc_annotation(self, node: Element) -> None:
self.body.append('</em>')
self.body.append('</span>')

##############################################

Expand Down
6 changes: 3 additions & 3 deletions tests/test_domains/test_domain_py_pyobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,17 +925,17 @@ def test_domain_py_type_alias(app):

content = (app.outdir / 'type_alias.html').read_text(encoding='utf8')
assert (
'<em class="property"><span class="k"><span class="pre">type</span></span><span class="w"> </span></em>'
'<span class="property"><span class="k"><span class="pre">type</span></span><span class="w"> </span></span>'
'<span class="sig-prename descclassname"><span class="pre">module_one.</span></span>'
'<span class="sig-name descname"><span class="pre">MyAlias</span></span>'
'<em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span>'
'<span class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span>'
'<span class="w"> </span><span class="pre">list</span>'
'<span class="p"><span class="pre">[</span></span>'
'<span class="pre">int</span><span class="w"> </span>'
'<span class="p"><span class="pre">|</span></span><span class="w"> </span>'
'<a class="reference internal" href="#module_two.SomeClass" title="module_two.SomeClass">'
'<span class="pre">module_two.SomeClass</span></a>'
'<span class="p"><span class="pre">]</span></span></em>'
'<span class="p"><span class="pre">]</span></span></span>'
) in content
assert app.warning.getvalue() == ''

Expand Down
Loading