Skip to content

Commit af6fab3

Browse files
committed
fix: Handle __init__ overloads when merging into class
Issue-212: mkdocstrings#212
1 parent 3bf55b2 commit af6fab3

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,26 @@ Context:
7676
{#- Signature block.
7777
7878
This block renders the signature for the class.
79+
Overloads of the `__init__` method are rendered if `merge_init_into_class` is enabled.
80+
The actual `__init__` method signature is only rendered if `separate_signature` is also enabled.
7981
-#}
80-
{% if config.separate_signature and config.merge_init_into_class %}
82+
{% if config.merge_init_into_class %}
8183
{% if "__init__" in all_members %}
8284
{% with function = all_members["__init__"] %}
83-
{% filter format_signature(function, config.line_length, crossrefs=config.signature_crossrefs) %}
84-
{{ class.name }}
85-
{% endfilter %}
85+
{% if function.overloads %}
86+
<div class="doc-overloads">
87+
{% for overload in function.overloads %}
88+
{% filter format_signature(overload, config.line_length, annotations=True, crossrefs=config.signature_crossrefs) %}
89+
{{ class.name }}
90+
{% endfilter %}
91+
{% endfor %}
92+
</div>
93+
{% endif %}
94+
{% if config.separate_signature %}
95+
{% filter format_signature(function, config.line_length, crossrefs=config.signature_crossrefs) %}
96+
{{ class.name }}
97+
{% endfilter %}
98+
{% endif %}
8699
{% endwith %}
87100
{% endif %}
88101
{% endif %}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy