8000 fix: Don't escape signatures return annotations · Thomzoy/python@ac54bfc · GitHub
[go: up one dir, main page]

Skip to content

Commit ac54bfc

Browse files
committed
fix: Don't escape signatures return annotations
Issue mkdocstrings#6: mkdocstrings#6
1 parent 4e895b0 commit ac54bfc

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/mkdocstrings_handlers/python/templates/material/_base/signature.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
{%- endif -%}
3939
{%- endfor -%}
4040
)
41-
{%- if config.show_signature_annotations and function.annotation %} -> {{ function.annotation }}{%- endif -%}
41+
{%- if config.show_signature_annotations and function.annotation %} -> {{ function.annotation|safe }}{%- endif -%}
4242

4343
{%- endwith -%}
4444
{%- endif -%}

tests/test_renderer.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,15 @@ def test_render_docstring_examples_section(renderer):
3131
assert "<p>This is an example.</p>" in rendered
3232
assert "print" in rendered
3333
assert "Hello" in rendered
34+
35+
36+
def test_format_code_and_signature(renderer):
37+
"""Assert code and signatures can be Black-formatted.
38+
39+
Parameters:
40+
renderer: A renderer instance (parametrized).
41+
"""
42+
assert renderer.do_format_code("print('Hello')", 100)
43+
assert renderer.do_format_code('print("Hello")', 100)
44+
assert renderer.do_format_signature("(param: str = 'hello') -> 'Class'", 100)
45+
assert renderer.do_format_signature('(param: str = "hello") -> "Class"', 100)

0 commit comments

Comments
 (0)
0