Skip to content

Commit bcbc314

Browse files
committed
refactor: Improve support for signatures rendering (wip)
1 parent 9648248 commit bcbc314

8 files changed

+117
-16
lines changed

src/mkdocstrings_handlers/typescript/templates/material/_base/accessor.html.jinja

+14-5
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,20 @@
5555
{{ accessor.comment.markdown(symbol_map=accessor.symbol_map)|convert_markdown(heading_level, html_id) }}
5656
{% endif %}
5757
{% endblock docstring %}
58-
{% block children scoped %}
59-
{% set root = False %}
60-
{% set heading_level = heading_level + 1 %}
61-
{% include "children.html.jinja" with context %}
62-
{% endblock children %}
58+
{% block setsignature %}
59+
{% if accessor.setsignature %}
60+
{% with setsignature = access.setsignature %}
61+
{% include "setsignature.html.jinja" with context %}
62+
{% endwith %}
63+
{% endif %}
64+
{% endblock setsignature %}
65+
{% block getsignature %}
66+
{% if accessor.getsignature %}
67+
{% with getsignature = access.getsignature %}
68+
{% include "getsignature.html.jinja" with context %}
69+
{% endwith %}
70+
{% endif %}
71+
{% endblock getsignature %}
6372
{% endblock contents %}
6473
</div>
6574

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{ log.debug("Rendering " + call_signature.path) }}
2+
3+
<div class="doc doc-object doc-call_signature">
4+
{% with obj = call_signature, html_id = call_signature.path %}
5+
6+
{% filter highlight(language="typescript", inline=False) %}
7+
{{ call_signature.source_contents }}
8+
{% endfilter %}
9+
10+
{% if call_signature.comment %}
11+
{{ call_signature.comment.markdown(symbol_map=call_signature.symbol_map)|convert_markdown(heading_level, html_id) }}
12+
{% endif %}
13+
{% endwith %}
14+
</div>

src/mkdocstrings_handlers/typescript/templates/material/_base/constructor.html.jinja

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@
5555
{{ constructor.comment.markdown(symbol_map=constructor.symbol_map)|convert_markdown(heading_level, html_id) }}
5656
{% endif %}
5757
{% endblock docstring %}
58-
{% block children scoped %}
59-
{% set root = False %}
60-
{% set heading_level = heading_level + 1 %}
61-
{% include "children.html.jinja" with context %}
62-
{% endblock children %}
58+
{% block signatures scoped %}
59+
{% for obj in obj.signatures %}
60+
{% include "dispatch.html.jinja" with context %}
61+
{% endfor %}
62+
{% endblock signatures %}
6363
{% endblock contents %}
6464
</div>
6565

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{{ log.debug("Rendering " + constructor_signature.path) }}
2+
3+
<div class="doc doc-object doc-constructor_signature">
4+
{% with obj = constructor_signature, html_id = constructor_signature.path %}
5+
6+
{% if root %}
7+
{% set show_full_path = config.show_root_full_path %}
8+
{% set root_members = True %}
9+
{% elif root_members %}
10+
{% set show_full_path = config.show_root_members_full_path or config.show_object_full_path %}
11+
{% set root_members = False %}
12+
{% else %}
13+
{% set show_full_path = config.show_object_full_path %}
14+
{% endif %}
15+
16+
{% set constructor_signature_name = constructor_signature.path if show_full_path else constructor_signature.name %}
17+
{% set symbol_type = "method" if constructor_signature.parent.is_class else "constructor_signature" %}
18+
19+
{% if not root or config.show_root_heading %}
20+
{% filter heading(
21+
heading_level,
22+
role="constructor_signature",
23+
id=html_id,
24+
class="doc doc-heading",
25+
toc_label=(('<code class="doc-symbol doc-symbol-toc doc-symbol-' + symbol_type + '"></code>&nbsp;')|safe if config.show_symbol_type_toc else '') + constructor_signature.name,
26+
) %}
27+
28+
{% block heading scoped %}
29+
{% if config.show_symbol_type_heading %}<code class="doc-symbol doc-symbol-heading doc-symbol-{{ symbol_type }}"></code>{% endif %}
30+
{% if config.separate_signature %}
31+
<span class="doc doc-object-name doc-constructor_signature-name">{{ constructor_signature_name }}</span>
32+
{% else %}
33+
{%+ filter highlight(language="typescript", inline=True) %}
34+
{{ constructor_signature_name }}
35+
{% endfilter %}
36+
{% endif %}
37+
{% endblock heading %}
38+
39+
{% endfilter %}
40+
41+
{% block signature scoped %}
42+
{% if config.separate_signature %}
43+
{% for signature in constructor_signature.signatures %}
44+
{% filter highlight(language="typescript", inline=False) %}
45+
{{ signature.source_contents }}
46+
{% endfilter %}
47+
{% endfor %}
48+
{% endif %}
49+
{% endblock signature %}
50+
51+
{% else %}
52+
53+
{% if config.show_root_toc_entry %}
54+
{% filter heading(
55+
heading_level,
56+
role="constructor_signature",
57+
id=html_id,
58+
toc_label=(('<code class="doc-symbol doc-symbol-toc doc-symbol-' + symbol_type + '"></code>&nbsp;')|safe if config.show_symbol_type_toc else '') + constructor_signature.name,
59+
hidden=True,
60+
) %}
61+
{% endfilter %}
62+
{% endif %}
63+
{% set heading_level = heading_level - 1 %}
64+
{% endif %}
65+
66+
<div class="doc doc-contents {% if root %}first{% endif %}">
67+
{% block contents scoped %}
68+
{% block docstring scoped %}
69+
{% if constructor_signature.comment %}
70+
{{ constructor_signature.comment.markdown(symbol_map=constructor_signature.symbol_map)|convert_markdown(heading_level, html_id) }}
71+
{% endif %}
72+
{% endblock docstring %}
73+
{% endblock contents %}
74+
</div>
75+
{% endwith %}
76+
</div>

src/mkdocstrings_handlers/typescript/templates/material/_base/function.html.jinja

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
{% if config.separate_signature %}
4343
{% for signature in function.signatures %}
4444
{% filter highlight(language="typescript", inline=False) %}
45-
{{ signature.source_contents(config.base_file_path) }}
45+
{{ signature.source_contents }}
4646
{% endfilter %}
4747
{% endfor %}
4848
{% endif %}

src/mkdocstrings_handlers/typescript/templates/material/_base/method.html.jinja

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@
5555
{{ method.comment.markdown(symbol_map=method.symbol_map)|convert_markdown(heading_level, html_id) }}
5656
{% endif %}
5757
{% endblock docstring %}
58-
{% block children scoped %}
59-
{% set root = False %}
60-
{% set heading_level = heading_level + 1 %}
61-
{% include "children.html.jinja" with context %}
62-
{% endblock children %}
58+
{% block signatures scoped %}
59+
{% for obj in obj.signatures %}
60+
{% include "dispatch.html.jinja" with context %}
61+
{% endfor %}
62+
{% endblock signatures %}
6363
{% endblock contents %}
6464
</div>
6565

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% extends "_base/call_signature.html.jinja" %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% extends "_base/constructor_signature.html.jinja" %}

0 commit comments

Comments
 (0)