From af6fab31142204872ace716392dcb314b2cb5d0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Tue, 3 Dec 2024 16:36:26 +0100 Subject: [PATCH] fix: Handle `__init__` overloads when merging into class Issue-212: https://github.com/mkdocstrings/python/issues/212 --- .../templates/material/_base/class.html.jinja | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja b/src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja index eac70be..ff5e51c 100644 --- a/src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja +++ b/src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja @@ -76,13 +76,26 @@ Context: {#- Signature block. This block renders the signature for the class. + Overloads of the `__init__` method are rendered if `merge_init_into_class` is enabled. + The actual `__init__` method signature is only rendered if `separate_signature` is also enabled. -#} - {% if config.separate_signature and config.merge_init_into_class %} + {% if config.merge_init_into_class %} {% if "__init__" in all_members %} {% with function = all_members["__init__"] %} - {% filter format_signature(function, config.line_length, crossrefs=config.signature_crossrefs) %} - {{ class.name }} - {% endfilter %} + {% if function.overloads %} +
+ {% for overload in function.overloads %} + {% filter format_signature(overload, config.line_length, annotations=True, crossrefs=config.signature_crossrefs) %} + {{ class.name }} + {% endfilter %} + {% endfor %} +
+ {% endif %} + {% if config.separate_signature %} + {% filter format_signature(function, config.line_length, crossrefs=config.signature_crossrefs) %} + {{ class.name }} + {% endfilter %} + {% endif %} {% endwith %} {% endif %} {% endif %}