8000 refactor: Always hide `self` and `cls` parameters · Thomzoy/python@7f579d1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7f579d1

Browse files
committed
refactor: Always hide self and cls parameters
Issue mkdocstrings#7: mkdocstrings#7
1 parent 2ec638e commit 7f579d1

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
{%- with function = class.members["__init__"] -%}
2929
{%- filter highlight(language="python", inline=True) -%}
3030
{% if show_full_path %}{{ class.path }}{% else %}{{ class.name }}{% endif %}
31-
{% with no_self = True %}
32-
{%- include "signature.html" with context -%}
33-
{% endwith %}
31+
{%- include "signature.html" with context -%}
3432
{%- endfilter -%}
3533
{%- endwith -%}
3634
{% else %}
@@ -45,7 +43,7 @@
4543

4644
{% if config.separate_signature and config.merge_init_into_class %}
4745
{% if "__init__" in class.members %}
48-
{% with function = class.members["__init__"], no_self = True %}
46+
{% with function = class.members["__init__"] %}
4947
{% filter highlight(language="python", inline=False) %}
5048
{% filter format_signature(config.line_length) %}
5149
{% if show_full_path %}{{ class.path }}{% else %}{{ class.name }}{% endif %}

src/mkdocstrings_handlers/python/templates/material/_base/signature.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
(
1212
{%- for parameter in function.parameters -%}
13-
{%- if parameter.name != "self" or not no_self -%}
13+
{%- if parameter.name not in ("self", "cls") or loop.index0 > 0 or not (function.parent and function.parent.is_class) -%}
1414

1515
{%- if parameter.kind.value == "positional-only" -%}
1616
{%- if ns.render_pos_only_separator -%}

0 commit comments

Comments
 (0)
0