diff --git a/CHANGELOG.md b/CHANGELOG.md index 3560a473..afb47eca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,18 @@ 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). +## [1.7.1](https://github.com/mkdocstrings/python/releases/tag/1.7.1) - 2023-09-28 + +[Compare with 1.7.0](https://github.com/mkdocstrings/python/compare/1.7.0...1.7.1) + +### Bug Fixes + +- Stop propagation of annotation to next parameter in signature template ([3a760ac](https://github.com/mkdocstrings/python/commit/3a760acacfabaef5abc658ee579e1c205e674994) by Timothée Mazzucotelli). [Issue #110](https://github.com/mkdocstrings/python/issues/110) + +### Code Refactoring + +- Look into inherited members for `__init__` methods when merging docstrings ([b97d51f](https://github.com/mkdocstrings/python/commit/b97d51f67c2ee3d1edfe6975274ead50fcb3fa8f) by Timothée Mazzucotelli). [Issue #106](https://github.com/mkdocstrings/python/issues/106) + ## [1.7.0](https://github.com/mkdocstrings/python/releases/tag/1.7.0) - 2023-09-14 [Compare with 1.6.3](https://github.com/mkdocstrings/python/compare/1.6.3...1.7.0) diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/class.html b/src/mkdocstrings_handlers/python/templates/material/_base/class.html index 186de8ff..a62459b1 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/class.html +++ b/src/mkdocstrings_handlers/python/templates/material/_base/class.html @@ -26,8 +26,8 @@ {% block heading scoped %} {% if config.separate_signature %} {{ class_name }} - {% elif config.merge_init_into_class and "__init__" in class.members %} - {% with function = class.members["__init__"] %} + {% elif config.merge_init_into_class and "__init__" in class.all_members %} + {% with function = class.all_members["__init__"] %} {%+ filter highlight(language="python", inline=True) %} {{ class_name }}{% include "signature.html" with context %} {% endfilter %} @@ -47,8 +47,8 @@ {% block signature scoped %} {% if config.separate_signature and config.merge_init_into_class %} - {% if "__init__" in class.members %} - {% with function = class.members["__init__"] %} + {% if "__init__" in class.all_members %} + {% with function = class.all_members["__init__"] %} {% filter format_signature(function, config.line_length, crossrefs=config.signature_crossrefs) %} {{ class.name }} {% endfilter %} @@ -86,8 +86,8 @@ {% include "docstring.html" with context %} {% endwith %} {% if config.merge_init_into_class %} - {% if "__init__" in class.members and class.members["__init__"].has_docstring %} - {% with docstring_sections = class.members["__init__"].docstring.parsed %} + {% if "__init__" in class.all_members and class.all_members["__init__"].has_docstring %} + {% with docstring_sections = class.all_members["__init__"].docstring.parsed %} {% include "docstring.html" with context %} {% endwith %} {% endif %} @@ -97,10 +97,10 @@ {% block source scoped %} {% if config.show_source %} {% if config.merge_init_into_class %} - {% if "__init__" in class.members and class.members["__init__"].source %} + {% if "__init__" in class.all_members and class.all_members["__init__"].source %}
Source code in {{ class.relative_filepath }} - {{ class.members["__init__"].source|highlight(language="python", linestart=class.members["__init__"].lineno, linenums=True) }} + {{ class.all_members["__init__"].source|highlight(language="python", linestart=class.all_members["__init__"].lineno, linenums=True) }}
{% endif %} {% elif class.source %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/signature.html b/src/mkdocstrings_handlers/python/templates/material/_base/signature.html index 3ea0f91e..74563385 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/signature.html +++ b/src/mkdocstrings_handlers/python/templates/material/_base/signature.html @@ -11,10 +11,6 @@ ) -%} - {%- if config.show_signature_annotations -%} - {%- set ns.equal = " = " -%} - {%- endif -%} - ( {%- for parameter in function.parameters -%} {%- if parameter.name not in ("self", "cls") or loop.index0 > 0 or not (function.parent and function.parent.is_class) -%} @@ -31,6 +27,7 @@ {%- endif -%} {%- if config.show_signature_annotations and parameter.annotation is not none -%} + {%- set ns.equal = " = " -%} {%- if config.separate_signature and config.signature_crossrefs -%} {%- with expression = parameter.annotation -%} {%- set ns.annotation -%}: {% include "expression.html" with context %}{%- endset -%} @@ -38,6 +35,9 @@ {%- else -%} {%- set ns.annotation = ": " + parameter.annotation|safe -%} {%- endif -%} + {%- else -%} + {%- set ns.equal = "=" -%} + {%- set ns.annotation = "" -%} {%- endif -%} {%- if parameter.default is not none and parameter.kind.value != "variadic positional" and parameter.kind.value != "variadic keyword" -%}