Skip to content

Commit 02825a7

Browse files
added cliboard button
1 parent 108b60a commit 02825a7

File tree

1 file changed

+61
-19
lines changed

1 file changed

+61
-19
lines changed

docs/main.mako

Lines changed: 61 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
77
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
88

9+
<%def name="clip_button(clip_text)">
10+
<button class="btn" onclick="navigator.clipboard.writeText('${clip_text}');">
11+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-clipboard" viewBox="0 0 16 16">
12+
<path d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1v-1z"/>
13+
<path d="M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5h3zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3z"/>
14+
</svg>
15+
</button>
16+
</%def>
17+
918
<%def name="render_pointer(pointer_name)">
1019
${make_rules(rs = ijson.rules_from_pointer(pointer_name))}
1120
</%def>
@@ -15,6 +24,14 @@
1524
attributes['count'] = attributes['count'] + 1
1625
local_count = attributes['count']
1726
%>
27+
<%
28+
if len(rs) > 0:
29+
rs[0]['pointer_last'] = rs[0]['pointer'].rsplit('/', 1)[-1]
30+
if rs[0]['pointer_last'] == '*':
31+
tmp = rs[0]['pointer'].replace('/*','')
32+
rs[0]['pointer_last'] = tmp.rsplit('/', 1)[-1]
33+
%>
34+
1835
% if len(rs) == 1: ## single rules for a pointer use a cell
1936
${make_rule(r=rs[0])}
2037
% endif
@@ -23,6 +40,7 @@
2340
<div class="card">
2441
<div class="card-header" id="heading${local_count}">
2542
<h5 class="mb-0">
43+
${clip_button(clip_text=rs[0]['pointer_last'])}
2644
<button class="btn btn-link" data-toggle="collapse" data-target="#collapse${local_count}" aria-expanded="true" aria-controls="collapse${local_count}">
2745
<h4>${rs[0]['pointer']}</h4>
2846
</button>
@@ -45,35 +63,38 @@
4563
local_count = attributes['count']
4664
if not 'doc' in r:
4765
r['doc'] = 'FIXME: Missing documentation in the specification'
48-
r['pointer_short'] = '/' + r['pointer'].rsplit('/', 1)[-1] or s
49-
if r['pointer_short'] == '/*':
66+
r['pointer_last'] = r['pointer'].rsplit('/', 1)[-1]
67+
if r['pointer_last'] == '*':
5068
tmp = r['pointer'].replace('/*','')
51-
r['pointer_short'] = ('/' + tmp.rsplit('/', 1)[-1] or s) + '/*'
69+
r['pointer_last'] = tmp.rsplit('/', 1)[-1]
5270
r['pointer_short'] = r['pointer']
5371
%>
5472
% if r['type'] == "object": ## Object
5573
<div id="accordion${local_count}">
5674
<div class="card">
5775
<div class="card-header" id="heading${local_count}">
5876
<h5 class="mb-0">
77+
${clip_button(clip_text=r['pointer_last'])}
5978
<button class="btn btn-link" data-toggle="collapse" data-target="#collapse${local_count}" aria-expanded="true" aria-controls="collapse${local_count}">
6079
<h4>${r['pointer_short']}</h4>
6180
</button>
62-
Object
81+
<code>Object</code>
6382
${"(Type: " + r["type_name"] + ")" if "type_name" in r else ""}
6483
% if "default" in r:
65-
[${r["default"]}]
84+
= ${r["default"]}
6685
% endif
6786
</h5>
6887
${r['doc']}
6988
</div>
7089
<div id="collapse${local_count}" class="collapse hide" aria-labelledby="heading${local_count}" data-parent="#accordion${local_count}">
7190
7291
% if 'required' in r:
92+
7393
<div class="container">
94+
7495
<div class="row">
96+
<h5 class=".text-success">Required</h5>
7597
<div class="col-1">
76-
<p class=".text-success">Required</p>
7798
</div>
7899
<div class="col-11">
79100
% for fname in r['required']:
@@ -85,9 +106,11 @@
85106
% endif
86107
% if 'optional' in r:
87108
<div class="container">
109+
88110
<div class="row">
111+
<h5>Optional</h5>
89112
<div class="col-1">
90-
<p class=".text-success">Optional</p>
113+
91114
</div>
92115
<div class="col-11">
93116
% for fname in r['optional']:
@@ -115,14 +138,17 @@
115138
<p class="text-primary">${r['pointer_short']}</p>
116139
</div>
117140
<div class="col-sm">
118-
Float
141+
<code>Float</code>
119142
% if "min" in r or "max" in r:
120143
(${r["min"] if "min" in r else "-inf"}, ${r["max"] if "max" in r else "inf"})
121144
% endif
122145
% if "default" in r:
123-
[${r["default"]}]
146+
= ${r["default"]}
124147
% endif
125148
</div>
149+
<div class="auto">
150+
${clip_button(clip_text=r['pointer_last'])}
151+
</div>
126152
</div>
127153
</h5>
128154
</div>
@@ -142,14 +168,17 @@
142168
<p class="text-primary">${r['pointer_short']}</p>
143169
</div>
144170
<div class="col-sm">
145-
Integer
171+
<code>Integer</code>
146172
% if "min" in r or "max" in r:
147173
(${r["min"] if "min" in r else "-inf"}, ${r["max"] if "max" in r else "inf"})
148174
% endif
149175
% if "default" in r:
150-
[${r["default"]}]
176+
= ${r["default"]}
151177
% endif
152178
</div>
179+
<div class="auto">
180+
${clip_button(clip_text=r['pointer_last'])}
181+
</div>
153182
</div>
154183
</h5>
155184
</div>
@@ -169,14 +198,18 @@
169198
<p class="text-primary">${r['pointer_short']}</p>
170199
</div>
171200
<div class="col-sm">
172-
File
201+
<code>File</code>
173202
% if "extensions" in r:
174203
(${r["extensions"]})
175204
% endif
176205
% if "default" in r:
177-
[${r["default"]}]
206+
= "${r["default"]}"
178207
% endif
179208
</div>
209+
<div class="auto">
210+
${clip_button(clip_text=r['pointer_last'])}
211+
</div>
212+
180213
</div>
181214
</h5>
182215
</div>
@@ -196,11 +229,14 @@
196229
<p class="text-primary">${r['pointer_short']}</p>
197230
</div>
198231
<div class="col-sm">
199-
Folder
232+
<code>Folder</code>
200233
% if "default" in r:
201-
[${r["default"]}]
234+
= "${r["default"]}"
202235
% endif
203236
</div>
237+
<div class="auto">
238+
${clip_button(clip_text=r['pointer_last'])}
239+
</div>
204240
</div>
205241
</h5>
206242
</div>
@@ -220,11 +256,14 @@
220256
<p class="text-primary">${r['pointer_short']}</p>
221257
</div>
222258
<div class="col-sm">
223-
Boolean
259+
<code>Boolean</code>
224260
% if "default" in r:
225-
[${r["default"]}]
261+
= ${r["default"]}
226262
% endif
227263
</div>
264+
<div class="auto">
265+
${clip_button(clip_text=r['pointer_last'])}
266+
</div>
228267
</div>
229268
</h5>
230269
</div>
@@ -244,14 +283,17 @@
244283
<p class="text-primary">${r['pointer_short']}</p>
245284
</div>
246285
<div class="col-sm">
247-
String
286+
<code>String</code>
248287
% if "options" in r:
249288
(${r["options"]})
250289
% endif
251290
% if "default" in r:
252-
[${r["default"]}]
291+
= "${r["default"]}"
253292
% endif
254293
</div>
294+
<div class="auto">
295+
${clip_button(clip_text=r['pointer_last'])}
296+
</div>
255297
</div>
256298
</h5>
257299
</div>

0 commit comments

Comments
 (0)