minting 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +14 -1
- data/Rakefile +1 -1
- data/doc/agents/recommendations.md +1 -1
- data/doc/agents/rubocop-issues.md +332 -0
- data/lib/minting/mint/currency.rb +8 -7
- data/lib/minting/mint/currency_store.rb +68 -0
- data/lib/minting/mint/refinements.rb +3 -1
- data/lib/minting/mint/registry.rb +15 -46
- data/lib/minting/mint.rb +4 -1
- data/lib/minting/money/allocation.rb +4 -1
- data/lib/minting/money/arithmetics.rb +25 -10
- data/lib/minting/money/coercion.rb +3 -1
- data/lib/minting/money/comparable.rb +5 -6
- data/lib/minting/money/constructors.rb +66 -0
- data/lib/minting/money/conversion.rb +4 -1
- data/lib/minting/money/formatting.rb +20 -19
- data/lib/minting/money/money.rb +30 -82
- data/lib/minting/money/parse.rb +16 -19
- data/lib/minting/money.rb +3 -0
- data/lib/minting/version.rb +3 -1
- data/lib/minting.rb +2 -0
- metadata +4 -19
- data/doc/Mint/Currency.html +0 -816
- data/doc/Mint/Money.html +0 -3471
- data/doc/Mint.html +0 -953
- data/doc/Minting.html +0 -142
- data/doc/_index.html +0 -136
- data/doc/class_list.html +0 -54
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -206
- data/doc/css/style.css +0 -1089
- data/doc/file.README.html +0 -379
- data/doc/file_list.html +0 -59
- data/doc/frames.html +0 -22
- data/doc/index.html +0 -379
- data/doc/js/app.js +0 -801
- data/doc/js/full_list.js +0 -334
- data/doc/js/jquery.js +0 -4
- data/doc/method_list.html +0 -470
- data/doc/top-level-namespace.html +0 -112
data/doc/js/app.js
DELETED
|
@@ -1,801 +0,0 @@
|
|
|
1
|
-
(() => {
|
|
2
|
-
window.__yardAppState = window.__yardAppState || {
|
|
3
|
-
navigationListenerBound: false,
|
|
4
|
-
navigationChangeBound: false,
|
|
5
|
-
navResizerBound: false,
|
|
6
|
-
searchFrameGlobalsBound: false,
|
|
7
|
-
latestNavigationId: 0,
|
|
8
|
-
loadingIndicatorTimer: null,
|
|
9
|
-
loadingProgressTimer: null,
|
|
10
|
-
loadingProgressHideTimer: null,
|
|
11
|
-
navExpanderTimer: null,
|
|
12
|
-
navExpanderToken: 0,
|
|
13
|
-
currentUrl: window.location.href,
|
|
14
|
-
};
|
|
15
|
-
const appState = window.__yardAppState;
|
|
16
|
-
let safeLocalStorage = {};
|
|
17
|
-
let safeSessionStorage = {};
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
safeLocalStorage = window.localStorage;
|
|
21
|
-
} catch (_error) {}
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
safeSessionStorage = window.sessionStorage;
|
|
25
|
-
} catch (_error) {}
|
|
26
|
-
|
|
27
|
-
function query(selector, root) {
|
|
28
|
-
return (root || document).querySelector(selector);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function queryAll(selector, root) {
|
|
32
|
-
return Array.prototype.slice.call(
|
|
33
|
-
(root || document).querySelectorAll(selector),
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function isVisible(element) {
|
|
38
|
-
if (!element) return false;
|
|
39
|
-
return window.getComputedStyle(element).display !== "none";
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function toggleDisplay(element, visible, displayValue) {
|
|
43
|
-
if (!element) return;
|
|
44
|
-
element.style.display = visible ? displayValue || "" : "none";
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function setMainLoading(loading) {
|
|
48
|
-
const body = document.body;
|
|
49
|
-
const main = query("#main");
|
|
50
|
-
|
|
51
|
-
if (body) body.classList.toggle("loading", !!loading);
|
|
52
|
-
if (!main) return;
|
|
53
|
-
main.classList.toggle("loading", !!loading);
|
|
54
|
-
main.setAttribute("aria-busy", loading ? "true" : "false");
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function setLoadingProgress(progress) {
|
|
58
|
-
const indicator = query("#main_progress");
|
|
59
|
-
|
|
60
|
-
if (!indicator) return;
|
|
61
|
-
indicator.style.setProperty(
|
|
62
|
-
"--yard-progress",
|
|
63
|
-
`${Math.max(0, Math.min(100, progress))}%`,
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function clearLoadingProgressTimers() {
|
|
68
|
-
clearTimeout(appState.loadingProgressTimer);
|
|
69
|
-
clearTimeout(appState.loadingProgressHideTimer);
|
|
70
|
-
appState.loadingProgressTimer = null;
|
|
71
|
-
appState.loadingProgressHideTimer = null;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function startLoadingProgress() {
|
|
75
|
-
const startedAt = Date.now();
|
|
76
|
-
|
|
77
|
-
clearLoadingProgressTimers();
|
|
78
|
-
setLoadingProgress(0);
|
|
79
|
-
setMainLoading(true);
|
|
80
|
-
|
|
81
|
-
function tick() {
|
|
82
|
-
const elapsed = Date.now() - startedAt;
|
|
83
|
-
let progress;
|
|
84
|
-
|
|
85
|
-
if (elapsed <= 1000) {
|
|
86
|
-
progress = (elapsed / 1000) * 99;
|
|
87
|
-
} else {
|
|
88
|
-
progress = 99 + Math.min(1, (elapsed - 1000) / 10000);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
setLoadingProgress(progress);
|
|
92
|
-
|
|
93
|
-
if (progress < 100) {
|
|
94
|
-
appState.loadingProgressTimer = setTimeout(tick, 50);
|
|
95
|
-
} else {
|
|
96
|
-
appState.loadingProgressTimer = null;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
tick();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function scheduleMainLoading(navigationId) {
|
|
104
|
-
clearTimeout(appState.loadingIndicatorTimer);
|
|
105
|
-
clearTimeout(appState.loadingProgressHideTimer);
|
|
106
|
-
appState.loadingProgressHideTimer = null;
|
|
107
|
-
appState.loadingIndicatorTimer = setTimeout(() => {
|
|
108
|
-
if (navigationId === appState.latestNavigationId) {
|
|
109
|
-
startLoadingProgress();
|
|
110
|
-
}
|
|
111
|
-
appState.loadingIndicatorTimer = null;
|
|
112
|
-
}, 400);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function cancelMainLoading() {
|
|
116
|
-
clearTimeout(appState.loadingIndicatorTimer);
|
|
117
|
-
appState.loadingIndicatorTimer = null;
|
|
118
|
-
clearTimeout(appState.loadingProgressTimer);
|
|
119
|
-
appState.loadingProgressTimer = null;
|
|
120
|
-
setLoadingProgress(100);
|
|
121
|
-
appState.loadingProgressHideTimer = setTimeout(() => {
|
|
122
|
-
setMainLoading(false);
|
|
123
|
-
setLoadingProgress(0);
|
|
124
|
-
appState.loadingProgressHideTimer = null;
|
|
125
|
-
}, 120);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function firstNextMatchingSibling(element, selector) {
|
|
129
|
-
let current = element;
|
|
130
|
-
while (current) {
|
|
131
|
-
current = current.nextElementSibling;
|
|
132
|
-
if (current?.matches(selector)) return current;
|
|
133
|
-
}
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function ready(callback) {
|
|
138
|
-
if (document.readyState === "loading") {
|
|
139
|
-
document.addEventListener("DOMContentLoaded", callback, { once: true });
|
|
140
|
-
} else {
|
|
141
|
-
callback();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function createSourceLinks() {
|
|
146
|
-
queryAll(".method_details_list .source_code").forEach((sourceCode) => {
|
|
147
|
-
const toggleWrapper = document.createElement("span");
|
|
148
|
-
const link = document.createElement("a");
|
|
149
|
-
|
|
150
|
-
toggleWrapper.className = "showSource";
|
|
151
|
-
toggleWrapper.appendChild(document.createTextNode("["));
|
|
152
|
-
toggleWrapper.appendChild(link);
|
|
153
|
-
toggleWrapper.appendChild(document.createTextNode("]"));
|
|
154
|
-
|
|
155
|
-
link.href = "#";
|
|
156
|
-
link.className = "toggleSource";
|
|
157
|
-
link.textContent = "View source";
|
|
158
|
-
|
|
159
|
-
link.addEventListener("click", (event) => {
|
|
160
|
-
event.preventDefault();
|
|
161
|
-
const expanded = isVisible(sourceCode);
|
|
162
|
-
toggleDisplay(sourceCode, !expanded, "table");
|
|
163
|
-
link.textContent = expanded ? "View source" : "Hide source";
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
sourceCode.parentNode.insertBefore(toggleWrapper, sourceCode);
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function createDefineLinks() {
|
|
171
|
-
queryAll(".defines").forEach((defines) => {
|
|
172
|
-
const toggleLink = document.createElement("a");
|
|
173
|
-
const summary = defines.parentElement.previousElementSibling;
|
|
174
|
-
|
|
175
|
-
toggleLink.href = "#";
|
|
176
|
-
toggleLink.className = "toggleDefines";
|
|
177
|
-
toggleLink.textContent = "more...";
|
|
178
|
-
defines.insertAdjacentText("afterend", " ");
|
|
179
|
-
defines.insertAdjacentElement("afterend", toggleLink);
|
|
180
|
-
|
|
181
|
-
toggleLink.addEventListener("click", (event) => {
|
|
182
|
-
event.preventDefault();
|
|
183
|
-
const expanded = toggleLink.dataset.expanded === "true";
|
|
184
|
-
|
|
185
|
-
if (!expanded) {
|
|
186
|
-
toggleLink.dataset.height = String(summary.offsetHeight);
|
|
187
|
-
defines.style.display = "inline";
|
|
188
|
-
summary.style.height = `${toggleLink.parentElement.offsetHeight}px`;
|
|
189
|
-
toggleLink.textContent = "(less)";
|
|
190
|
-
toggleLink.dataset.expanded = "true";
|
|
191
|
-
} else {
|
|
192
|
-
defines.style.display = "none";
|
|
193
|
-
if (toggleLink.dataset.height) {
|
|
194
|
-
summary.style.height = `${toggleLink.dataset.height}px`;
|
|
195
|
-
}
|
|
196
|
-
toggleLink.textContent = "more...";
|
|
197
|
-
toggleLink.dataset.expanded = "false";
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
function createFullTreeLinks() {
|
|
204
|
-
queryAll(".inheritanceTree").forEach((toggleLink) => {
|
|
205
|
-
const container = toggleLink.parentElement;
|
|
206
|
-
const tree = container.previousElementSibling;
|
|
207
|
-
|
|
208
|
-
toggleLink.addEventListener("click", (event) => {
|
|
209
|
-
event.preventDefault();
|
|
210
|
-
const expanded = toggleLink.dataset.expanded === "true";
|
|
211
|
-
|
|
212
|
-
if (!expanded) {
|
|
213
|
-
toggleLink.dataset.height = String(tree.offsetHeight);
|
|
214
|
-
container.classList.add("showAll");
|
|
215
|
-
toggleLink.textContent = "(hide)";
|
|
216
|
-
tree.style.height = `${container.offsetHeight}px`;
|
|
217
|
-
toggleLink.dataset.expanded = "true";
|
|
218
|
-
} else {
|
|
219
|
-
container.classList.remove("showAll");
|
|
220
|
-
if (toggleLink.dataset.height) {
|
|
221
|
-
tree.style.height = `${toggleLink.dataset.height}px`;
|
|
222
|
-
}
|
|
223
|
-
toggleLink.textContent = "show all";
|
|
224
|
-
toggleLink.dataset.expanded = "false";
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
function resetSearchFrame() {
|
|
231
|
-
const frame = query("#nav");
|
|
232
|
-
|
|
233
|
-
if (frame) frame.removeAttribute("style");
|
|
234
|
-
queryAll("#search a").forEach((link) => {
|
|
235
|
-
link.classList.remove("active");
|
|
236
|
-
link.classList.remove("inactive");
|
|
237
|
-
});
|
|
238
|
-
window.focus();
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
function toggleSearchFrame(linkElement, link) {
|
|
242
|
-
const frame = query("#nav");
|
|
243
|
-
|
|
244
|
-
if (!frame) return;
|
|
245
|
-
|
|
246
|
-
queryAll("#search a").forEach((searchLink) => {
|
|
247
|
-
searchLink.classList.remove("active");
|
|
248
|
-
searchLink.classList.add("inactive");
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
if (frame.getAttribute("src") === link && isVisible(frame)) {
|
|
252
|
-
frame.style.display = "none";
|
|
253
|
-
queryAll("#search a").forEach((searchLink) => {
|
|
254
|
-
searchLink.classList.remove("active");
|
|
255
|
-
searchLink.classList.remove("inactive");
|
|
256
|
-
});
|
|
257
|
-
} else {
|
|
258
|
-
linkElement.classList.add("active");
|
|
259
|
-
linkElement.classList.remove("inactive");
|
|
260
|
-
if (frame.getAttribute("src") !== link) frame.setAttribute("src", link);
|
|
261
|
-
frame.style.display = "block";
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
function searchFrameButtons() {
|
|
266
|
-
queryAll(".full_list_link").forEach((link) => {
|
|
267
|
-
if (link.dataset.yardSearchFrameBound === "true") return;
|
|
268
|
-
|
|
269
|
-
link.addEventListener("click", (event) => {
|
|
270
|
-
event.preventDefault();
|
|
271
|
-
toggleSearchFrame(link, link.getAttribute("href"));
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
link.dataset.yardSearchFrameBound = "true";
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
if (appState.searchFrameGlobalsBound) return;
|
|
278
|
-
|
|
279
|
-
window.addEventListener("message", (event) => {
|
|
280
|
-
if (event.data === "navEscape") resetSearchFrame();
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
window.addEventListener("resize", () => {
|
|
284
|
-
if (!isVisible(query("#search"))) resetSearchFrame();
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
appState.searchFrameGlobalsBound = true;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function linkSummaries() {
|
|
291
|
-
queryAll(".summary_signature").forEach((signature) => {
|
|
292
|
-
signature.addEventListener("click", (event) => {
|
|
293
|
-
if (event.target.closest("a")) return;
|
|
294
|
-
const link = signature.querySelector("a");
|
|
295
|
-
if (link) document.location = link.getAttribute("href");
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
function toggleSummaryCollection(toggleSelector, listSelector, cloneBuilder) {
|
|
301
|
-
queryAll(toggleSelector).forEach((toggleLink) => {
|
|
302
|
-
toggleLink.addEventListener("click", (event) => {
|
|
303
|
-
event.preventDefault();
|
|
304
|
-
safeLocalStorage.summaryCollapsed = toggleLink.textContent;
|
|
305
|
-
|
|
306
|
-
queryAll(toggleSelector).forEach((link) => {
|
|
307
|
-
link.textContent =
|
|
308
|
-
link.textContent === "collapse" ? "expand" : "collapse";
|
|
309
|
-
|
|
310
|
-
const container = link.parentElement.parentElement;
|
|
311
|
-
const next = firstNextMatchingSibling(container, listSelector);
|
|
312
|
-
|
|
313
|
-
if (!next) return;
|
|
314
|
-
|
|
315
|
-
if (next.classList.contains("compact")) {
|
|
316
|
-
const fullList = firstNextMatchingSibling(next, listSelector);
|
|
317
|
-
toggleDisplay(next, !isVisible(next));
|
|
318
|
-
toggleDisplay(fullList, !isVisible(fullList));
|
|
319
|
-
} else {
|
|
320
|
-
const compactList = cloneBuilder(next.cloneNode(true));
|
|
321
|
-
next.parentNode.insertBefore(compactList, next);
|
|
322
|
-
toggleDisplay(next, false);
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
});
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
function buildCompactSummary(list) {
|
|
330
|
-
list.className = "summary compact";
|
|
331
|
-
|
|
332
|
-
queryAll(".summary_desc, .note", list).forEach((node) => {
|
|
333
|
-
node.remove();
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
queryAll("a", list).forEach((link) => {
|
|
337
|
-
const strong = link.querySelector("strong");
|
|
338
|
-
if (strong) link.innerHTML = strong.innerHTML;
|
|
339
|
-
if (link.parentElement) link.parentElement.outerHTML = link.outerHTML;
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
return list;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
function buildCompactConstants(list) {
|
|
346
|
-
list.className = "constants compact";
|
|
347
|
-
|
|
348
|
-
queryAll("dt", list).forEach((node) => {
|
|
349
|
-
const deprecated = !!node.querySelector(".deprecated");
|
|
350
|
-
node.classList.add("summary_signature");
|
|
351
|
-
node.textContent = node.textContent.split("=")[0];
|
|
352
|
-
if (deprecated) node.classList.add("deprecated");
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
queryAll("pre.code", list).forEach((pre) => {
|
|
356
|
-
const dtElement = pre.parentElement.previousElementSibling;
|
|
357
|
-
let tooltip = pre.textContent;
|
|
358
|
-
if (dtElement.classList.contains("deprecated")) {
|
|
359
|
-
tooltip = `Deprecated. ${tooltip}`;
|
|
360
|
-
}
|
|
361
|
-
dtElement.setAttribute("title", tooltip);
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
queryAll(".docstring, .tags, dd", list).forEach((node) => {
|
|
365
|
-
node.remove();
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
return list;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
function summaryToggle() {
|
|
372
|
-
toggleSummaryCollection(
|
|
373
|
-
".summary_toggle",
|
|
374
|
-
"ul.summary",
|
|
375
|
-
buildCompactSummary,
|
|
376
|
-
);
|
|
377
|
-
|
|
378
|
-
if (safeLocalStorage.summaryCollapsed === "collapse") {
|
|
379
|
-
const toggle = query(".summary_toggle");
|
|
380
|
-
if (toggle) toggle.click();
|
|
381
|
-
} else {
|
|
382
|
-
safeLocalStorage.summaryCollapsed = "expand";
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
function constantSummaryToggle() {
|
|
387
|
-
toggleSummaryCollection(
|
|
388
|
-
".constants_summary_toggle",
|
|
389
|
-
"dl.constants",
|
|
390
|
-
buildCompactConstants,
|
|
391
|
-
);
|
|
392
|
-
|
|
393
|
-
if (safeLocalStorage.summaryCollapsed === "collapse") {
|
|
394
|
-
const toggle = query(".constants_summary_toggle");
|
|
395
|
-
if (toggle) toggle.click();
|
|
396
|
-
} else {
|
|
397
|
-
safeLocalStorage.summaryCollapsed = "expand";
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
function generateTOC() {
|
|
402
|
-
const fileContents = query("#filecontents");
|
|
403
|
-
const content = query("#content");
|
|
404
|
-
|
|
405
|
-
if (!fileContents || !content) return;
|
|
406
|
-
if (query("#toc", content)) return;
|
|
407
|
-
|
|
408
|
-
const topLevel = document.createElement("ol");
|
|
409
|
-
let currentList = topLevel;
|
|
410
|
-
let currentItem;
|
|
411
|
-
let counter = 0;
|
|
412
|
-
const headings = ["h2", "h3", "h4", "h5", "h6"];
|
|
413
|
-
let hasEntries = false;
|
|
414
|
-
|
|
415
|
-
topLevel.className = "top";
|
|
416
|
-
|
|
417
|
-
if (queryAll("#filecontents h1").length > 1) headings.unshift("h1");
|
|
418
|
-
|
|
419
|
-
const selectors = headings.map((tagName) => `#filecontents ${tagName}`);
|
|
420
|
-
|
|
421
|
-
let lastLevel = parseInt(headings[0].substring(1), 10);
|
|
422
|
-
|
|
423
|
-
queryAll(selectors.join(", ")).forEach((heading) => {
|
|
424
|
-
let level;
|
|
425
|
-
|
|
426
|
-
if (heading.closest(".method_details .docstring")) return;
|
|
427
|
-
if (heading.id === "filecontents") return;
|
|
428
|
-
|
|
429
|
-
hasEntries = true;
|
|
430
|
-
level = parseInt(heading.tagName.substring(1), 10);
|
|
431
|
-
|
|
432
|
-
if (!heading.id) {
|
|
433
|
-
let proposedId = heading.getAttribute("toc-id");
|
|
434
|
-
if (!proposedId) {
|
|
435
|
-
proposedId = heading.textContent.replace(/[^a-z0-9-]/gi, "_");
|
|
436
|
-
if (query(`#${proposedId}`)) {
|
|
437
|
-
proposedId += counter;
|
|
438
|
-
counter += 1;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
heading.id = proposedId;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
if (level > lastLevel) {
|
|
445
|
-
while (level > lastLevel) {
|
|
446
|
-
if (!currentItem) {
|
|
447
|
-
currentItem = document.createElement("li");
|
|
448
|
-
currentList.appendChild(currentItem);
|
|
449
|
-
}
|
|
450
|
-
const nestedList = document.createElement("ol");
|
|
451
|
-
currentItem.appendChild(nestedList);
|
|
452
|
-
currentList = nestedList;
|
|
453
|
-
currentItem = null;
|
|
454
|
-
lastLevel += 1;
|
|
455
|
-
}
|
|
456
|
-
} else if (level < lastLevel) {
|
|
457
|
-
while (level < lastLevel && currentList.parentElement) {
|
|
458
|
-
currentList = currentList.parentElement.parentElement;
|
|
459
|
-
lastLevel -= 1;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
const title = heading.getAttribute("toc-title") || heading.textContent;
|
|
464
|
-
const item = document.createElement("li");
|
|
465
|
-
item.innerHTML = `<a href="#${heading.id}">${title}</a>`;
|
|
466
|
-
currentList.appendChild(item);
|
|
467
|
-
currentItem = item;
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
if (!hasEntries) return;
|
|
471
|
-
|
|
472
|
-
const toc = document.createElement("div");
|
|
473
|
-
toc.id = "toc";
|
|
474
|
-
toc.innerHTML =
|
|
475
|
-
'<p class="title hide_toc"><a href="#"><strong>Table of Contents</strong></a></p>';
|
|
476
|
-
content.insertBefore(toc, content.firstChild);
|
|
477
|
-
toc.appendChild(topLevel);
|
|
478
|
-
|
|
479
|
-
const hideLink = query("#toc .hide_toc");
|
|
480
|
-
if (hideLink) {
|
|
481
|
-
hideLink.addEventListener("click", (event) => {
|
|
482
|
-
event.preventDefault();
|
|
483
|
-
const list = query("#toc .top");
|
|
484
|
-
const hidden = query("#toc").classList.toggle("hidden");
|
|
485
|
-
toggleDisplay(list, !hidden);
|
|
486
|
-
queryAll("#toc .title small").forEach((node) => {
|
|
487
|
-
toggleDisplay(node, hidden);
|
|
488
|
-
});
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
function navResizer() {
|
|
494
|
-
const resizer = document.getElementById("resizer");
|
|
495
|
-
|
|
496
|
-
if (!resizer) return;
|
|
497
|
-
|
|
498
|
-
if (!appState.navResizerBound) {
|
|
499
|
-
resizer.addEventListener(
|
|
500
|
-
"pointerdown",
|
|
501
|
-
(event) => {
|
|
502
|
-
resizer.setPointerCapture(event.pointerId);
|
|
503
|
-
event.preventDefault();
|
|
504
|
-
event.stopPropagation();
|
|
505
|
-
},
|
|
506
|
-
false,
|
|
507
|
-
);
|
|
508
|
-
resizer.addEventListener(
|
|
509
|
-
"pointerup",
|
|
510
|
-
(event) => {
|
|
511
|
-
resizer.releasePointerCapture(event.pointerId);
|
|
512
|
-
event.preventDefault();
|
|
513
|
-
event.stopPropagation();
|
|
514
|
-
},
|
|
515
|
-
false,
|
|
516
|
-
);
|
|
517
|
-
resizer.addEventListener(
|
|
518
|
-
"pointermove",
|
|
519
|
-
(event) => {
|
|
520
|
-
if ((event.buttons & 1) === 0) return;
|
|
521
|
-
|
|
522
|
-
safeSessionStorage.navWidth = String(event.pageX);
|
|
523
|
-
queryAll(".nav_wrap").forEach((node) => {
|
|
524
|
-
node.style.width = `${Math.max(200, event.pageX)}px`;
|
|
525
|
-
});
|
|
526
|
-
event.preventDefault();
|
|
527
|
-
event.stopPropagation();
|
|
528
|
-
},
|
|
529
|
-
false,
|
|
530
|
-
);
|
|
531
|
-
|
|
532
|
-
appState.navResizerBound = true;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
if (safeSessionStorage.navWidth) {
|
|
536
|
-
queryAll(".nav_wrap").forEach((node) => {
|
|
537
|
-
node.style.width = `${Math.max(200, parseInt(safeSessionStorage.navWidth, 10))}px`;
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
function navExpander(enabled) {
|
|
543
|
-
if (enabled === false) return;
|
|
544
|
-
if (typeof pathId === "undefined") return;
|
|
545
|
-
|
|
546
|
-
const frame = document.getElementById("nav");
|
|
547
|
-
const token = ++appState.navExpanderToken;
|
|
548
|
-
|
|
549
|
-
function postMessage() {
|
|
550
|
-
if (token !== appState.navExpanderToken) return;
|
|
551
|
-
expandNavPath(pathId);
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
clearTimeout(appState.navExpanderTimer);
|
|
555
|
-
if (frame) frame.addEventListener("load", postMessage, { once: true });
|
|
556
|
-
appState.navExpanderTimer = setTimeout(postMessage, 50);
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
function expandNavPath(path) {
|
|
560
|
-
const frame = document.getElementById("nav");
|
|
561
|
-
|
|
562
|
-
if (path == null || !frame || !frame.contentWindow) return;
|
|
563
|
-
frame.contentWindow.postMessage({ action: "expand", path: path }, "*");
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
function focusHashTarget(hashOverride) {
|
|
567
|
-
const hash =
|
|
568
|
-
typeof hashOverride === "string" ? hashOverride : window.location.hash;
|
|
569
|
-
if (!hash) return false;
|
|
570
|
-
|
|
571
|
-
const targetId = hash.slice(1);
|
|
572
|
-
let decodedTargetId = targetId;
|
|
573
|
-
|
|
574
|
-
try {
|
|
575
|
-
decodedTargetId = decodeURIComponent(targetId);
|
|
576
|
-
} catch (_error) {}
|
|
577
|
-
|
|
578
|
-
const target =
|
|
579
|
-
document.getElementById(decodedTargetId) ||
|
|
580
|
-
document.getElementById(targetId);
|
|
581
|
-
|
|
582
|
-
if (!target) return false;
|
|
583
|
-
|
|
584
|
-
target.scrollIntoView();
|
|
585
|
-
return true;
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
function resetMainScroll() {
|
|
589
|
-
const main = query("#main");
|
|
590
|
-
|
|
591
|
-
if (main) {
|
|
592
|
-
main.scrollTop = 0;
|
|
593
|
-
main.scrollLeft = 0;
|
|
594
|
-
}
|
|
595
|
-
window.scrollTo(0, 0);
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
function mainFocus() {
|
|
599
|
-
if (!focusHashTarget()) {
|
|
600
|
-
resetMainScroll();
|
|
601
|
-
}
|
|
602
|
-
setTimeout(() => {
|
|
603
|
-
const main = query("#main");
|
|
604
|
-
if (main) main.focus();
|
|
605
|
-
}, 10);
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
function navigationChange() {
|
|
609
|
-
if (appState.navigationChangeBound) return;
|
|
610
|
-
|
|
611
|
-
window.addEventListener("popstate", () => {
|
|
612
|
-
navigateTo(window.location.href, {
|
|
613
|
-
pushHistory: false,
|
|
614
|
-
syncNav: true,
|
|
615
|
-
});
|
|
616
|
-
});
|
|
617
|
-
appState.navigationChangeBound = true;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
function sameDocumentUrl(left, right) {
|
|
621
|
-
const leftUrl = new URL(left, window.location.href);
|
|
622
|
-
const rightUrl = new URL(right, window.location.href);
|
|
623
|
-
|
|
624
|
-
return (
|
|
625
|
-
leftUrl.origin === rightUrl.origin &&
|
|
626
|
-
leftUrl.pathname === rightUrl.pathname &&
|
|
627
|
-
leftUrl.search === rightUrl.search
|
|
628
|
-
);
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
function contentPageUrl(url) {
|
|
632
|
-
const pageUrl = new URL(url, window.location.href);
|
|
633
|
-
|
|
634
|
-
pageUrl.hash = "";
|
|
635
|
-
return pageUrl.href;
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
function updatePageState(doc, pageWindow) {
|
|
639
|
-
const nextMain = doc.querySelector("#main");
|
|
640
|
-
const currentMain = query("#main");
|
|
641
|
-
const currentClassListLink = query("#class_list_link");
|
|
642
|
-
const currentClassListClassName = currentClassListLink
|
|
643
|
-
? currentClassListLink.className
|
|
644
|
-
: null;
|
|
645
|
-
|
|
646
|
-
if (!nextMain || !currentMain) return false;
|
|
647
|
-
|
|
648
|
-
currentMain.innerHTML = nextMain.innerHTML;
|
|
649
|
-
document.title = doc.title;
|
|
650
|
-
|
|
651
|
-
if (currentClassListClassName && query("#class_list_link")) {
|
|
652
|
-
query("#class_list_link").className = currentClassListClassName;
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
if (pageWindow && typeof pageWindow.pathId !== "undefined") {
|
|
656
|
-
pathId = pageWindow.pathId;
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
if (pageWindow && typeof pageWindow.relpath !== "undefined") {
|
|
660
|
-
relpath = pageWindow.relpath;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
return true;
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
function pageLoaderFrame() {
|
|
667
|
-
let frame = query("#page_loader");
|
|
668
|
-
|
|
669
|
-
if (frame) return frame;
|
|
670
|
-
|
|
671
|
-
frame = document.createElement("iframe");
|
|
672
|
-
frame.id = "page_loader";
|
|
673
|
-
frame.setAttribute("aria-hidden", "true");
|
|
674
|
-
frame.setAttribute("tabindex", "-1");
|
|
675
|
-
frame.style.display = "none";
|
|
676
|
-
document.body.appendChild(frame);
|
|
677
|
-
return frame;
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
function completeNavigation(url, options, pageWindow, pageDocument) {
|
|
681
|
-
const targetUrl = new URL(url, window.location.href);
|
|
682
|
-
|
|
683
|
-
if (!updatePageState(pageDocument, pageWindow)) return false;
|
|
684
|
-
|
|
685
|
-
window.__app({ rehydrateNav: false });
|
|
686
|
-
|
|
687
|
-
if (options.syncNav && typeof pathId !== "undefined") {
|
|
688
|
-
expandNavPath(pathId);
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
if (targetUrl.hash) {
|
|
692
|
-
focusHashTarget(targetUrl.hash);
|
|
693
|
-
} else {
|
|
694
|
-
resetMainScroll();
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
if (options.pushHistory) {
|
|
698
|
-
history.pushState({}, document.title, targetUrl.href);
|
|
699
|
-
}
|
|
700
|
-
appState.currentUrl = targetUrl.href;
|
|
701
|
-
|
|
702
|
-
return true;
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
function navigateTo(url, options) {
|
|
706
|
-
const navigationOptions = Object.assign(
|
|
707
|
-
{ pushHistory: true, syncNav: false },
|
|
708
|
-
options || {},
|
|
709
|
-
);
|
|
710
|
-
const navigationId = ++appState.latestNavigationId;
|
|
711
|
-
const loader = pageLoaderFrame();
|
|
712
|
-
const resolvedUrl = new URL(url, window.location.href).href;
|
|
713
|
-
const loaderUrl = contentPageUrl(resolvedUrl);
|
|
714
|
-
|
|
715
|
-
if (sameDocumentUrl(appState.currentUrl, resolvedUrl)) {
|
|
716
|
-
const resolvedTargetUrl = new URL(resolvedUrl);
|
|
717
|
-
|
|
718
|
-
if (navigationOptions.pushHistory) {
|
|
719
|
-
history.pushState({}, document.title, resolvedUrl);
|
|
720
|
-
}
|
|
721
|
-
appState.currentUrl = resolvedUrl;
|
|
722
|
-
if (resolvedTargetUrl.hash) {
|
|
723
|
-
focusHashTarget(resolvedTargetUrl.hash);
|
|
724
|
-
} else {
|
|
725
|
-
resetMainScroll();
|
|
726
|
-
}
|
|
727
|
-
return;
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
scheduleMainLoading(navigationId);
|
|
731
|
-
|
|
732
|
-
loader.onload = () => {
|
|
733
|
-
let pageWindow;
|
|
734
|
-
let pageDocument;
|
|
735
|
-
let completed = false;
|
|
736
|
-
|
|
737
|
-
if (navigationId !== appState.latestNavigationId) return;
|
|
738
|
-
|
|
739
|
-
try {
|
|
740
|
-
pageWindow = loader.contentWindow;
|
|
741
|
-
pageDocument = loader.contentDocument || pageWindow.document;
|
|
742
|
-
completed = completeNavigation(
|
|
743
|
-
resolvedUrl,
|
|
744
|
-
navigationOptions,
|
|
745
|
-
pageWindow,
|
|
746
|
-
pageDocument,
|
|
747
|
-
);
|
|
748
|
-
} catch (_error) {
|
|
749
|
-
window.location.href = resolvedUrl;
|
|
750
|
-
return;
|
|
751
|
-
} finally {
|
|
752
|
-
if (navigationId === appState.latestNavigationId) {
|
|
753
|
-
cancelMainLoading();
|
|
754
|
-
}
|
|
755
|
-
if (completed) {
|
|
756
|
-
loader.onload = null;
|
|
757
|
-
loader.removeAttribute("src");
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
};
|
|
761
|
-
|
|
762
|
-
loader.src = loaderUrl;
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
window.__app = (options) => {
|
|
766
|
-
const appOptions = options || {};
|
|
767
|
-
ready(() => {
|
|
768
|
-
navResizer();
|
|
769
|
-
navExpander(appOptions.rehydrateNav !== false);
|
|
770
|
-
createSourceLinks();
|
|
771
|
-
createDefineLinks();
|
|
772
|
-
createFullTreeLinks();
|
|
773
|
-
searchFrameButtons();
|
|
774
|
-
linkSummaries();
|
|
775
|
-
summaryToggle();
|
|
776
|
-
constantSummaryToggle();
|
|
777
|
-
generateTOC();
|
|
778
|
-
mainFocus();
|
|
779
|
-
navigationChange();
|
|
780
|
-
});
|
|
781
|
-
};
|
|
782
|
-
|
|
783
|
-
window.__app();
|
|
784
|
-
|
|
785
|
-
if (!appState.navigationListenerBound) {
|
|
786
|
-
window.addEventListener(
|
|
787
|
-
"message",
|
|
788
|
-
(event) => {
|
|
789
|
-
if (!event.data || event.data.action !== "navigate") return;
|
|
790
|
-
|
|
791
|
-
navigateTo(event.data.url, {
|
|
792
|
-
pushHistory: true,
|
|
793
|
-
syncNav: false,
|
|
794
|
-
});
|
|
795
|
-
},
|
|
796
|
-
false,
|
|
797
|
-
);
|
|
798
|
-
|
|
799
|
-
appState.navigationListenerBound = true;
|
|
800
|
-
}
|
|
801
|
-
})();
|