diff --git a/CHANGELOG.md b/CHANGELOG.md index e2096e6c..207a8803 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,20 @@ 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.2](https://github.com/mkdocstrings/python/releases/tag/1.5.2) - 2023-08-25 + +[Compare with 1.5.1](https://github.com/mkdocstrings/python/compare/1.5.1...1.5.2) + +### Bug Fixes + +- Regression in children template: fix condition for when members are specified ([beeebff](https://github.com/mkdocstrings/python/commit/beeebffa36288d1f71d122f78ecd9064b41a75d0) by Timothée Mazzucotelli). [Issue #100](https://github.com/mkdocstrings/python/issues/100) +- Prevent whitespace removal before highlight filter ([c6f36c0](https://github.com/mkdocstrings/python/commit/c6f36c0c9e5141800f8c5c988c9b67720fccccb8) by Timothée Mazzucotelli). + +### Code Refactoring + +- Never show full object path in ToC entry ([9aa758b](https://github.com/mkdocstrings/python/commit/9aa758bcc42dfcf7c416d87b8f7cd407b7fdf148) by Timothée Mazzucotelli). +- Sync templates with insiders, remove useless lines ([38b317f](https://github.com/mkdocstrings/python/commit/38b317f4fc74b583a4788721a5559c51a5a47d86) by Timothée Mazzucotelli). + ## [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) diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/attribute.html b/src/mkdocstrings_handlers/python/templates/material/_base/attribute.html index 404532c6..c9fa126f 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/attribute.html +++ b/src/mkdocstrings_handlers/python/templates/material/_base/attribute.html @@ -13,6 +13,8 @@ {% set show_full_path = config.show_object_full_path %} {% endif %} + {% set attribute_name = attribute.path if show_full_path else attribute.name %} + {% if not root or config.show_root_heading %} {% filter heading(heading_level, @@ -23,11 +25,10 @@ {% block heading scoped %} {% if config.separate_signature %} - {% if show_full_path %}{{ attribute.path }}{% else %}{{ attribute.name }}{% endif %} + {{ attribute_name }} {% else %} - {% filter highlight(language="python", inline=True) %} - {% if show_full_path %}{{ attribute.path }}{% else %}{{ attribute.name }}{% endif %} - {% if attribute.annotation %}: {{ attribute.annotation }}{% endif %} + {%+ filter highlight(language="python", inline=True) %} + {{ attribute_name }}{% if attribute.annotation %}: {{ attribute.annotation }}{% endif %} {% if attribute.value %} = {{ attribute.value }}{% endif %} {% endfilter %} {% endif %} @@ -45,8 +46,7 @@ {% if config.separate_signature %} {% filter highlight(language="python", inline=False) %} {% filter format_code(config.line_length) %} - {{ attribute.name }} - {% if attribute.annotation %}: {{ attribute.annotation|safe }}{% endif %} + {{ attribute.name }}{% if attribute.annotation %}: {{ attribute.annotation|safe }}{% endif %} {% if attribute.value %} = {{ attribute.value|safe }}{% endif %} {% endfilter %} {% endfilter %} @@ -58,7 +58,7 @@ {% filter heading(heading_level, role="data" if attribute.parent.kind.value == "module" else "attr", id=html_id, - toc_label=attribute.path if config.show_root_full_path else attribute.name, + toc_label=attribute.name, hidden=True) %} {% endfilter %} {% endif %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/children.html b/src/mkdocstrings_handlers/python/templates/material/_base/children.html index 19b9c676..25534f70 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 members_list is none and attribute.is_public(check_name=False) %} + {% if members_list is not none or 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 members_list is none and class.is_public(check_name=False) %} + {% if members_list is not none or 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 members_list is none and function.is_public(check_name=False) %} + {% if members_list is not none or function.is_public(check_name=False) %} {% include function|get_template with context %} {% endif %} {% endif %} @@ -94,7 +94,7 @@ {% endif %} {% with heading_level = heading_level + extra_level %} {% for module in modules|order_members(config.members_order.alphabetical, members_list) %} - {% if members_list is none and module.is_public(check_name=False) %} + {% if members_list is not none or 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 members_list is none and child.is_public(check_name=False) %} + {% if members_list is not none or 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 f137686f..186de8ff 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/class.html +++ b/src/mkdocstrings_handlers/python/templates/material/_base/class.html @@ -13,6 +13,8 @@ {% set show_full_path = config.show_object_full_path %} {% endif %} + {% set class_name = class.path if show_full_path else class.name %} + {% if not root or config.show_root_heading %} {% filter heading(heading_level, @@ -23,16 +25,15 @@ {% block heading scoped %} {% if config.separate_signature %} - {% if show_full_path %}{{ class.path }}{% else %}{{ class.name }}{% endif %} - {% elif config.merge_init_into_class and "__init__" in class.members -%} - {%- with function = class.members["__init__"] -%} - {%- filter highlight(language="python", inline=True) -%} - {% if show_full_path %}{{ class.path }}{% else %}{{ class.name }}{% endif %} - {%- include "signature.html" with context -%} - {%- endfilter -%} - {%- endwith -%} + {{ class_name }} + {% elif config.merge_init_into_class and "__init__" in class.members %} + {% with function = class.members["__init__"] %} + {%+ filter highlight(language="python", inline=True) %} + {{ class_name }}{% include "signature.html" with context %} + {% endfilter %} + {% endwith %} {% else %} - {% if show_full_path %}{{ class.path }}{% else %}{{ class.name }}{% endif %} + {{ class_name }} {% endif %} {% endblock heading %} @@ -61,7 +62,7 @@ {% filter heading(heading_level, role="class", id=html_id, - toc_label=class.path if config.show_root_full_path else class.name, + toc_label=class.name, hidden=True) %} {% endfilter %} {% endif %} @@ -112,11 +113,9 @@ {% endblock source %} {% block children scoped %} - {% with obj = class %} - {% set root = False %} - {% set heading_level = heading_level + 1 %} - {% include "children.html" with context %} - {% endwith %} + {% set root = False %} + {% set heading_level = heading_level + 1 %} + {% include "children.html" with context %} {% endblock children %} {% endblock contents %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/function.html b/src/mkdocstrings_handlers/python/templates/material/_base/function.html index bccafc0c..c12bb1c3 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/function.html +++ b/src/mkdocstrings_handlers/python/templates/material/_base/function.html @@ -15,6 +15,8 @@ {% set show_full_path = config.show_object_full_path %} {% endif %} + {% set function_name = function.path if show_full_path else function.name %} + {% if not root or config.show_root_heading %} {% filter heading(heading_level, @@ -25,11 +27,10 @@ {% block heading scoped %} {% if config.separate_signature %} - {% if show_full_path %}{{ function.path }}{% else %}{{ function.name }}{% endif %} + {{ function_name }} {% else %} - {% filter highlight(language="python", inline=True) %} - {% if show_full_path %}{{ function.path }}{% else %}{{ function.name }}{% endif %} - {% include "signature.html" with context %} + {%+ filter highlight(language="python", inline=True) %} + {{ function_name }}{% include "signature.html" with context %} {% endfilter %} {% endif %} {% endblock heading %} @@ -55,7 +56,7 @@ {% filter heading(heading_level, role="function", id=html_id, - toc_label=function.path if config.show_root_full_path else function.name, + toc_label=function.name, hidden=True) %} {% endfilter %} {% endif %} diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/module.html b/src/mkdocstrings_handlers/python/templates/material/_base/module.html index ce62f8e7..dc44142b 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/module.html +++ b/src/mkdocstrings_handlers/python/templates/material/_base/module.html @@ -13,6 +13,8 @@ {% set show_full_path = config.show_object_full_path %} {% endif %} + {% set module_name = module.path if show_full_path else module.name %} + {% if not root or config.show_root_heading %} {% filter heading(heading_level, @@ -22,13 +24,11 @@ toc_label=module.name) %} {% block heading scoped %} - {% with module_name = module.path if show_full_path else module.name %} - {% if config.separate_signature %} - {{ module_name }} - {% else %} - {{ module_name }} - {% endif %} - {% endwith %} + {% if config.separate_signature %} + {{ module_name }} + {% else %} + {{ module_name }} + {% endif %} {% endblock heading %} {% block labels scoped %} @@ -44,7 +44,7 @@ {% filter heading(heading_level, role="module", id=html_id, - toc_label=module.path if config.show_root_full_path else module.name, + toc_label=module.name, hidden=True) %} {% endfilter %} {% endif %} @@ -60,11 +60,9 @@ {% endblock docstring %} {% block children scoped %} - {% with obj = module %} - {% set root = False %} - {% set heading_level = heading_level + 1 %} - {% include "children.html" with context %} - {% endwith %} + {% set root = False %} + {% set heading_level = heading_level + 1 %} + {% include "children.html" with context %} {% endblock children %} {% endblock contents %}