From ac54bfc5761337aa606fb1aa6575745062ce26f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Thu, 24 Feb 2022 21:40:42 +0100 Subject: [PATCH 1/2] fix: Don't escape signatures return annotations Issue #6: https://github.com/mkdocstrings/python/issues/6 --- .../python/templates/material/_base/signature.html | 2 +- tests/test_renderer.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/signature.html b/src/mkdocstrings_handlers/python/templates/material/_base/signature.html index 402e5d01..98658b6b 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/signature.html +++ b/src/mkdocstrings_handlers/python/templates/material/_base/signature.html @@ -38,7 +38,7 @@ {%- endif -%} {%- endfor -%} ) - {%- if config.show_signature_annotations and function.annotation %} -> {{ function.annotation }}{%- endif -%} + {%- if config.show_signature_annotations and function.annotation %} -> {{ function.annotation|safe }}{%- endif -%} {%- endwith -%} {%- endif -%} \ No newline at end of file diff --git a/tests/test_renderer.py b/tests/test_renderer.py index 76f68b7c..31232e12 100644 --- a/tests/test_renderer.py +++ b/tests/test_renderer.py @@ -31,3 +31,15 @@ def test_render_docstring_examples_section(renderer): assert "

This is an example.

" in rendered assert "print" in rendered assert "Hello" in rendered + + +def test_format_code_and_signature(renderer): + """Assert code and signatures can be Black-formatted. + + Parameters: + renderer: A renderer instance (parametrized). + """ + assert renderer.do_format_code("print('Hello')", 100) + assert renderer.do_format_code('print("Hello")', 100) + assert renderer.do_format_signature("(param: str = 'hello') -> 'Class'", 100) + assert renderer.do_format_signature('(param: str = "hello") -> "Class"', 100) From 0d5605498822efbb0055e487737e439ec2cbf1ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Thu, 24 Feb 2022 21:41:50 +0100 Subject: [PATCH 2/2] chore: Prepare release 0.6.5 --- CHANGELOG.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 990d0182..6cd416a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [0.6.5](https://github.com/mkdocstrings/python/releases/tag/0.6.5) - 2022-02-24 + +[Compare with 0.6.4](https://github.com/mkdocstrings/python/compare/0.6.4...0.6.5) + +### Bug Fixes +- Don't escape signatures return annotations ([ac54bfc](https://github.com/mkdocstrings/python/commit/ac54bfc5761337aa606fb1aa6575745062ce26f8) by Timothée Mazzucotelli). [Issue #6](https://github.com/mkdocstrings/python/issues/6) + + ## [0.6.4](https://github.com/mkdocstrings/python/releases/tag/0.6.4) - 2022-02-22 [Compare with 0.6.3](https://github.com/mkdocstrings/python/compare/0.6.3...0.6.4) @@ -18,7 +26,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. [Compare with 0.6.2](https://github.com/mkdocstrings/python/compare/0.6.2...0.6.3) ### Bug Fixes -- Fix examples rendering ([a06a7e3](https://github.com/mkdocstrings/python/commit/a06a7e34c7017374c5bed41f4757ed86ae64cb2e) by Timothée Mazzucotelli). References: [mkdocstrings/griffe#46](https://github.com/mkdocstrings/griffe/issues/46) +- Fix examples rendering ([a06a7e3](https://github.com/mkdocstrings/python/commit/a06a7e34c7017374c5bed41f4757ed86ae64cb2e) by Timothée Mazzucotelli). [Issue mkdocstrings/griffe#46](https://github.com/mkdocstrings/griffe/issues/46) ## [0.6.2](https://github.com/mkdocstrings/python/releases/tag/0.6.2) - 2022-02-17