10000 refactor: Sync templates with insiders, remove useless lines · mkdocstrings/python@38b317f · GitHub
[go: up one dir, main page]

Skip to content

Commit 38b317f

Browse files
committed
refactor: Sync templates with insiders, remove useless lines
1 parent c6f36c0 commit 38b317f

File tree

4 files changed

+27
-29
lines changed

4 files changed

+27
-29
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
{% set show_full_path = config.show_object_full_path %}
1414
{% endif %}
1515

16+
{% set attribute_name = attribute.path if show_full_path else attribute.name %}
17+
1618
{% if not root or config.show_root_heading %}
1719

1820
{% filter heading(heading_level,
@@ -23,11 +25,10 @@
2325

2426
{% block heading scoped %}
2527
{% if config.separate_signature %}
26-
<span class="doc doc-object-name doc-attribute-name">{% if show_full_path %}{{ attribute.path }}{% else %}{{ attribute.name }}{% endif %}</span>
28+
<span class="doc doc-object-name doc-attribute-name">{{ attribute_name }}</span>
2729
{% else %}
2830
{%+ filter highlight(language="python", inline=True) %}
29-
{% if show_full_path %}{{ attribute.path }}{% else %}{{ attribute.name }}{% endif %}
30-
{% if attribute.annotation %}: {{ attribute.annotation }}{% endif %}
31+
{{ attribute_name }}{% if attribute.annotation %}: {{ attribute.annotation }}{% endif %}
3132
{% if attribute.value %} = {{ attribute.value }}{% endif %}
3233
{% endfilter %}
3334
{% endif %}
@@ -45,8 +46,7 @@
4546
{% if config.separate_signature %}
4647
{% filter highlight(language="python", inline=False) %}
4748
{% filter format_code(config.line_length) %}
48-
{{ attribute.name }}
49-
{% if attribute.annotation %}: {{ attribute.annotation|safe }}{% endif %}
49+
{{ attribute.name }}{% if attribute.annotation %}: {{ attribute.annotation|safe }}{% endif %}
5050
{% if attribute.value %} = {{ attribute.value|safe }}{% endif %}
5151
{% endfilter %}
5252
{% endfilter %}

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
{% set show_full_path = config.show_object_full_path %}
1414
{% endif %}
1515

16+
{% set class_name = class.path if show_full_path else class.name %}
17+
1618
{% if not root or config.show_root_heading %}
1719

1820
{% filter heading(heading_level,
@@ -23,16 +25,15 @@
2325

2426
{% block heading scoped %}
2527
{% if config.separate_signature %}
26-
<span class="doc doc-object-name doc-class-name">{% if show_full_path %}{{ class.path }}{% else %}{{ class.name }}{% endif %}</span>
28+
<span class="doc doc-object-name doc-class-name">{{ class_name }}</span>
2729
{% elif config.merge_init_into_class and "__init__" in class.members %}
2830
{% with function = class.members["__init__"] %}
2931
{%+ filter highlight(language="python", inline=True) %}
30-
{% if show_full_path %}{{ class.path }}{% else %}{{ class.name }}{% endif %}
31-
{% include "signature.html" with context %}
32+
{{ class_name }}{% include "signature.html" with context %}
3233
{% endfilter %}
3334
{% endwith %}
3435
{% else %}
35-
<code>{% if show_full_path %}{{ class.path }}{% else %}{{ class.name }}{% endif %}</code>
36+
<code>{{ class_name }}</code>
3637
{% endif %}
3738
{% endblock heading %}
3839

@@ -112,11 +113,9 @@
112113
{% endblock source %}
113114

114115
{% block children scoped %}
115-
{% with obj = class %}
116-
{% set root = False %}
117-
{% set heading_level = heading_level + 1 %}
118-
{% include "children.html" with context %}
119-
{% endwith %}
116+
{% set root = False %}
117+
{% set heading_level = heading_level + 1 %}
118+
{% include "children.html" with context %}
120119
{% endblock children %}
121120
{% endblock contents %}
122121
</div>

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
{% set show_full_path = config.show_object_full_path %}
1616
{% endif %}
1717

18+
{% set function_name = function.path if show_full_path else function.name %}
19+
1820
{% if not root or config.show_root_heading %}
1921

2022
{% filter heading(heading_level,
@@ -25,11 +27,10 @@
2527

2628
{% block heading scoped %}
2729
{% if config.separate_signature %}
28-
<span class="doc doc-object-name doc-function-name">{% if show_full_path %}{{ function.path }}{% else %}{{ function.name }}{% endif %}</span>
30+
<span class="doc doc-object-name doc-function-name">{{ function_name }}</span>
2931
{% else %}
3032
{%+ filter highlight(language="python", inline=True) %}
31-
{% if show_full_path %}{{ function.path }}{% else %}{{ function.name }}{% endif %}
32-
{% include "signature.html" with context %}
33+
{{ function_name }}{% include "signature.html" with context %}
3334
{% endfilter %}
3435
{% endif %}
3536
{% endblock heading %}

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
{% set show_full_path = config.show_object_full_path %}
1414
{% endif %}
1515

16+
{% set module_name = module.path if show_full_path else module.name %}
17+
1618
{% if not root or config.show_root_heading %}
1719

1820
{% filter heading(heading_level,
@@ -22,13 +24,11 @@
2224
toc_label=module.name) %}
2325

2426
{% block heading scoped %}
25-
{% with module_name = module.path if show_full_path else module.name %}
26-
{% if config.separate_signature %}
27-
<span class="doc doc-object-name doc-module-name">{{ module_name }}</span>
28-
{% else %}
29-
<code>{{ module_name }}</code>
30-
{% endif %}
31-
{% endwith %}
27+
{% if config.separate_signature %}
28+
<span class="doc doc-object-name doc-module-name">{{ module_name }}</span>
29+
{% else %}
30+
<code>{{ module_name }}</code>
31+
{% endif %}
3232
{% endblock heading %}
3333

3434
{% block labels scoped %}
@@ -60,11 +60,9 @@
6060
{% endblock docstring %}
6161

6262
{% block children scoped %}
63-
{% with obj = module %}
64-
{% set root = False %}
65-
{% set heading_level = heading_level + 1 %}
66-
{% include "children.html" with context %}
67-
{% endwith %}
63+
{% set root = False %}
64+
{% set heading_level = heading_level + 1 %}
65+
{% include "children.html" with context %}
6866
{% endblock children %}
6967
{% endblock contents %}
7068
</div>

0 commit comments

Comments
 (0)
0