Skip to content

Commit 88bc82c

Browse files
committed
feat: 関数の定義のメソッドの見出しにツールチップを追加
1 parent 40ee2c1 commit 88bc82c

File tree

4 files changed

+66
-4
lines changed

4 files changed

+66
-4
lines changed

static/assets/icons/16-warn.svg

Lines changed: 7 additions & 0 deletions
Loading

static/styles/docs.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,15 @@ h1 .pill {
528528
margin-bottom: -3px
529529
}
530530

531+
.deprecation {
532+
align-items: baseline;
533+
}
534+
535+
.deprecation svg {
536+
margin-bottom: -4px;
537+
padding: 0;
538+
}
539+
531540
.tooltip-context {
532541
position: relative
533542
}

templates/func_template.html.j2

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@
33
{% extends "base_template.html.j2" %}
44
{% block content %}
55

6-
<h1 id="summary"><code>{{ body['content']['name'] }}</code><small>{% if body['content']['element'] %}{{
7-
macros.tooltip_display('Element', 'Element functions can be customized with <code>set</code> and <code>show</code> rules.') }}{% endif %}</small></h1>
6+
<h1 id="summary">
7+
<code>{{ body['content']['name'] }}</code>
8+
<small>
9+
{% if body['content']['element'] %}
10+
{{ macros.tooltip_display('Element', 'Element functions can be customized with <code>set</code> and <code>show</code> rules.') }}
11+
{% endif %}
12+
{% if body['content']['contextual'] %}
13+
{{ macros.tooltip_display('Contextual', 'Contextual functions can only be used when the context is known') }}
14+
{% endif %}
15+
</small>
16+
</h1>
817
{{ body['content']['details'] | safe }}
918
<h2 id="parameters">
1019
{{ macros.tooltip_display('引数', 'Parameters are the inputs to a function. They are specified in parentheses after the function name.', prefix='parameters') }}
@@ -22,7 +31,34 @@
2231
</h2>
2332
{% endif %}
2433
{% for method in body['content']['scope'] %}
25-
<h3 id="{{ prefix }}-{{ method['name'] }}" class="method-head"><span><code>{{ method['name'] }}</code></span></h3>
34+
<h3 id="definitions-{{ method['name'] }}" class="method-head">
35+
<code{% if method['deprecation'] %} style="text-decoration: line-through;"{% endif %}>{{ method['name'] }}</code>
36+
37+
<small>
38+
{% if method['element'] %}
39+
{{ macros.tooltip_display('Element', 'Element functions can be customized with <code>set</code> and <code>show</code> rules.') }}
40+
{% endif %}
41+
{% if method['contextual'] %}
42+
{{ macros.tooltip_display('Contextual', 'Contextual functions can only be used when the context is known') }}
43+
{% endif %}
44+
</small>
45+
{% if method['deprecation'] %}
46+
<small class="deprecation">
47+
<div class="tooltip-context">
48+
<svg width="16" height="16" viewBox="0 0 16 16" tabindex="0" role="img"
49+
aria-labelledby="definitions-{{ method['name'] }}-deprecation-tooltip">
50+
<title id="definitions-{{ method['name'] }}-deprecation-tooltip">
51+
Warning
52+
</title>
53+
<use href="/assets/icons/16-warn.svg#icon"></use>
54+
</svg>
55+
</div>
56+
<span>
57+
<span>{{ method['deprecation'] }}</span>
58+
</span>
59+
</small>
60+
{% endif %}
61+
</h3>
2662
{{ macros.function_display(method, type2href, type2class, gen_path, prefix='definitions-' + method['name']) }}
2763
{% endfor %}
2864

templates/type_template.html.j2

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,17 @@
2020
</h2>
2121
{% endif %}
2222
{% for method in body['content']['scope'] %}
23-
<h3 id="{{ prefix }}-{{ method['name'] }}" class="method-head"><span><code>{{ method['name'] }}</code></span></h3>
23+
<h3 id="definitions-{{ method['name'] }}" class="method-head">
24+
<code>{{ method['name'] }}</code>
25+
<small>
26+
{% if method['element'] %}
27+
{{ macros.tooltip_display('Element', 'Element functions can be customized with <code>set</code> and <code>show</code> rules.') }}
28+
{% endif %}
29+
{% if method['contextual'] %}
30+
{{ macros.tooltip_display('Contextual', 'Contextual functions can only be used when the context is known') }}
31+
{% endif %}
32+
</small>
33+
</h3>
2434
{{ macros.function_display(method, type2href, type2class, gen_path, prefix='definitions-' + method['name']) }}
2535
{% endfor %}
2636

0 commit comments

Comments
 (0)