diff --git a/CHANGELOG.md b/CHANGELOG.md index a6051524..e2096e6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,17 @@ 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.5.1](https://github.com/mkdocstrings/python/releases/tag/1.5.1) - 2023-08-24 + +[Compare with 1.5.0](https://github.com/mkdocstrings/python/compare/1.5.0...1.5.1) + +### Code Refactoring + +- Never show full path in separate signature since it would appear in the heading already ([9e02049](https://github.com/mkdocstrings/python/commit/9e0204930cf4dc973ba8eb41c471fc0132e1631f) by Timothée Mazzucotelli). +- Improve guessing whether an object is public ([35eb811](https://github.com/mkdocstrings/python/commit/35eb81162582d794f170cd7e8c68f10ecfd8ff9d) by Timothée Mazzucotelli). +- Always sort modules alphabetically as source order wouldn't make sense ([70c81ce](https://github.com/mkdocstrings/python/commit/70c81cebb62366cbfc6124bc84d1563db176afb6) by Timothée Mazzucotelli). +- Return anchors as a tuple, not a set, to preserve order ([736a2b5](https://github.com/mkdocstrings/python/commit/736a2b5e729d25bb184db8d42f2ad01025a5bc58) by Timothée Mazzucotelli). [Related-to #mkdocstrings/crystal#6](https://github.com/mkdocstrings/crystal/pull/6) + ## [1.5.0](https://github.com/mkdocstrings/python/releases/tag/1.5.0) - 2023-08-20 [Compare with 1.4.0](https://github.com/mkdocstrings/python/compare/1.4.0...1.5.0) diff --git a/pyproject.toml b/pyproject.toml index c25588d5..d7f58317 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ classifiers = [ ] dependencies = [ "mkdocstrings>=0.20", - "griffe>=0.33", + "griffe>=0.35", ] [project.urls] diff --git a/src/mkdocstrings_handlers/python/handler.py b/src/mkdocstrings_handlers/python/handler.py index 5fe76682..7b3a8a50 100644 --- a/src/mkdocstrings_handlers/python/handler.py +++ b/src/mkdocstrings_handlers/python/handler.py @@ -357,11 +357,17 @@ def update_env(self, md: Markdown, config: dict) -> None: # noqa: D102 (ignore self.env.filters["get_template"] = rendering.do_get_template self.env.tests["existing_template"] = lambda template_name: template_name in self.env.list_templates() - def get_anchors(self, data: CollectorItem) -> set[str]: # noqa: D102 (ignore missing docstring) + def get_anchors(self, data: CollectorItem) -> tuple[str, ...]: # noqa: D102 (ignore missing docstring) + anchors = [data.path] try: - return {data.path, data.canonical_path, *data.aliases} + if data.canonical_path != data.path: + anchors.append(data.canonical_path) + for anchor in data.aliases: + if anchor not in anchors: + anchors.append(anchor) except AliasResolutionError: - return {data.path} + return tuple(anchors) + return tuple(anchors) def get_handler( diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/attribute.html b/src/mkdocstrings_handlers/python/templates/material/_base/attribute.html index 1d416a3b..404532c6 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/attribute.html +++ b/src/mkdocstrings_handlers/python/templates/material/_base/attribute.html @@ -45,7 +45,7 @@ {% if config.separate_signature %} {% filter highlight(language="python", inline=False) %} {% filter format_code(config.line_length) %} - {% if show_full_path %}{{ attribute.path }}{% else %}{{ attribute.name }}{% endif %} + {{ attribute.name }} {% if attribute.annotation %}: {{ attribute.annotation|safe }}{% endif %} {% if attribute.value %} = {{ attribute.value|safe }}{% endif %} {% endfilter %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/children.html b/src/mkdocstrings_handlers/python/templates/material/_base/children.html index 2c5d4087..19b9c676 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/children.html +++ b/src/mkdocstrings_handlers/python/templates/material/_base/children.html @@ -31,7 +31,7 @@ {% endif %} {% with heading_level = heading_level + extra_level %} {% for attribute in attributes|order_members(config.members_order, members_list) %} - {% if not attribute.is_alias or attribute.is_explicitely_exported or attribute.inherited %} + {% if members_list is none and attribute.is_public(check_name=False) %} {% include attribute|get_template with context %} {% endif %} {% endfor %} @@ -51,7 +51,7 @@ {% endif %} {% with heading_level = heading_level + extra_level %} {% for class in classes|order_members(config.members_order, members_list) %} - {% if not class.is_alias or class.is_explicitely_exported or class.inherited %} + {% if members_list is none and class.is_public(check_name=False) %} {% include class|get_template with context %} {% endif %} {% endfor %} @@ -72,7 +72,7 @@ {% with heading_level = heading_level + extra_level %} {% for function in functions|order_members(config.members_order, members_list) %} {% if not (obj.kind.value == "class" and function.name == "__init__" and config.merge_init_into_class) %} - {% if not function.is_alias or function.is_explicitely_exported or function.inherited %} + {% if members_list is none and function.is_public(check_name=False) %} {% include function|get_template with context %} {% endif %} {% endif %} @@ -93,8 +93,8 @@ {% filter heading(heading_level, id=html_id ~ "-modules") %}Modules{% endfilter %} {% endif %} {% with heading_level = heading_level + extra_level %} - {% for module in modules|order_members(config.members_order, members_list) %} - {% if not module.is_alias or module.is_explicitely_exported or module.inherited %} + {% for module in modules|order_members(config.members_order.alphabetical, members_list) %} + {% if members_list is none and module.is_public(check_name=False) %} {% include module|get_template with context %} {% endif %} {% endfor %} @@ -119,7 +119,7 @@ {% if not (obj.is_class and child.name == "__init__" and config.merge_init_into_class) %} - {% if not child.is_alias or child.is_explicitely_exported or child.inherited %} + {% if members_list is none and child.is_public(check_name=False) %} {% if child.is_attribute %} {% with attribute = child %} {% include attribute|get_template with context %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/class.html b/src/mkdocstrings_handlers/python/templates/material/_base/class.html index af019330..f137686f 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/class.html +++ b/src/mkdocstrings_handlers/python/templates/material/_base/class.html @@ -49,7 +49,7 @@ {% if "__init__" in class.members %} {% with function = class.members["__init__"] %} {% filter format_signature(function, config.line_length, crossrefs=config.signature_crossrefs) %} - {% if show_full_path %}{{ class.path }}{% else %}{{ class.name }}{% endif %} + {{ class.name }} {% endfilter %} {% endwith %} {% endif %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/function.html b/src/mkdocstrings_handlers/python/templates/material/_base/function.html index a224f4de..bccafc0c 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/function.html +++ b/src/mkdocstrings_handlers/python/templates/material/_base/function.html @@ -45,7 +45,7 @@ {% block signature scoped %} {% if config.separate_signature %} {% filter format_signature(function, config.line_length, crossrefs=config.signature_crossrefs) %} - {% if show_full_path %}{{ function.path }}{% else %}{{ function.name }}{% endif %} + {{ function.name }} {% endfilter %} {% endif %} {% endblock signature %}