8000 perf: Compute all members of a class only once · hahnbeelee/mkdocstrings-python@c6dab06 · GitHub
[go: up one dir, main page]

Skip to content

Commit c6dab06

Browse files
committed
perf: Compute all members of a class only once
1 parent 1b064a0 commit c6dab06

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Context:
1818
{% endblock logs %}
1919

2020
<div class="doc doc-object doc-class">
21-
{% with obj = class, html_id = class.path %}
21+
{% with obj = class, html_id = class.path, all_members = class.all_members %}
2222

2323
{% if root %}
2424
{% set show_full_path = config.show_root_full_path %}
@@ -49,8 +49,8 @@ Context:
4949
{% if config.show_symbol_type_heading %}<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code>{% endif %}
5050
{% if config.separate_signature %}
5151
<span class="doc doc-object-name doc-class-name">{{ class_name }}</span>
52-
{% elif config.merge_init_into_class and "__init__" in class.all_members %}
53-
{% with function = class.all_members["__init__"] %}
52+
{% elif config.merge_init_into_class and "__init__" in all_members %}
53+
{% with function = all_members["__init__"] %}
5454
{%+ filter highlight(language="python", inline=True) %}
5555
{{ class_name }}{% include "signature"|get_template with context %}
5656
{% endfilter %}
@@ -78,8 +78,8 @@ Context:
7878
This block renders the signature for the class.
7979
-#}
8080
{% if config.separate_signature and config.merge_init_into_class %}
81-
{% if "__init__" in class.all_members %}
82-
{% with function = class.all_members["__init__"] %}
81+
{% if "__init__" in all_members %}
82+
{% with function = all_members["__init__"] %}
8383
{% filter format_signature(function, config.line_length, crossrefs=config.signature_crossrefs) %}
8484
{{ class.name }}
8585
{% endfilter %}
@@ -132,8 +132,8 @@ Context:
132132
{% include "docstring"|get_template with context %}
133133
{% endwith %}
134134
{% if config.merge_init_into_class %}
135-
{% if "__init__" in class.all_members and class.all_members["__init__"].has_docstring %}
136-
{% with function = class.all_members["__init__"] %}
135+
{% if "__init__" in all_members and all_members["__init__"].has_docstring %}
136+
{% with function = all_members["__init__"] %}
137137
{% with obj = function, docstring_sections = function.docstring.parsed %}
138138
{% include "docstring"|get_template with context %}
139139
{% endwith %}
@@ -157,8 +157,8 @@ Context:
157157
-#}
158158
{% if config.show_source %}
159159
{% if config.merge_init_into_class %}
160-
{% if "__init__" in class.all_members and class.all_members["__init__"].source %}
161-
{% with init = class.all_members["__init__"] %}
160+
{% if "__init__" in all_members and all_members["__init__"].source %}
161+
{% with init = all_members["__init__"] %}
162162
<details class="quote">
163163
<summary>Source code in <code>
164164
{%- if init.relative_filepath.is_absolute() -%}

0 commit comments

Comments
 (0)
0