yard 0.9.38 → 0.9.42

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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +44 -1
  3. data/README.md +18 -21
  4. data/docs/GettingStarted.md +41 -15
  5. data/docs/Parser.md +17 -42
  6. data/docs/Tags.md +5 -5
  7. data/docs/WhatsNew.md +59 -7
  8. data/docs/templates/default/yard_tags/html/setup.rb +1 -1
  9. data/lib/yard/autoload.rb +17 -0
  10. data/lib/yard/cli/diff.rb +7 -2
  11. data/lib/yard/code_objects/proxy.rb +1 -1
  12. data/lib/yard/handlers/processor.rb +1 -0
  13. data/lib/yard/handlers/rbs/attribute_handler.rb +43 -0
  14. data/lib/yard/handlers/rbs/base.rb +38 -0
  15. data/lib/yard/handlers/rbs/constant_handler.rb +18 -0
  16. data/lib/yard/handlers/rbs/method_handler.rb +327 -0
  17. data/lib/yard/handlers/rbs/mixin_handler.rb +20 -0
  18. data/lib/yard/handlers/rbs/namespace_handler.rb +26 -0
  19. data/lib/yard/handlers/ruby/attribute_handler.rb +7 -4
  20. data/lib/yard/handlers/ruby/constant_handler.rb +1 -0
  21. data/lib/yard/i18n/locale.rb +1 -1
  22. data/lib/yard/i18n/pot_generator.rb +1 -1
  23. data/lib/yard/parser/rbs/rbs_parser.rb +325 -0
  24. data/lib/yard/parser/rbs/statement.rb +75 -0
  25. data/lib/yard/parser/ruby/legacy/irb/slex.rb +19 -1
  26. data/lib/yard/parser/ruby/ruby_parser.rb +55 -3
  27. data/lib/yard/parser/source_parser.rb +3 -2
  28. data/lib/yard/registry_resolver.rb +7 -0
  29. data/lib/yard/rubygems/specification.rb +1 -1
  30. data/lib/yard/server/commands/base.rb +1 -1
  31. data/lib/yard/server/library_version.rb +1 -1
  32. data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +168 -88
  33. data/lib/yard/server/templates/default/fulldoc/html/js/autocomplete.js +203 -12
  34. data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +1 -17
  35. data/lib/yard/server/templates/default/method_details/html/permalink.erb +4 -2
  36. data/lib/yard/server/templates/doc_server/library_list/html/headers.erb +3 -3
  37. data/lib/yard/server/templates/doc_server/library_list/html/library_list.erb +2 -3
  38. data/lib/yard/server/templates/doc_server/processing/html/processing.erb +22 -16
  39. data/lib/yard/tags/directives.rb +7 -0
  40. data/lib/yard/tags/library.rb +3 -3
  41. data/lib/yard/tags/types_explainer.rb +2 -1
  42. data/lib/yard/templates/helpers/base_helper.rb +1 -1
  43. data/lib/yard/templates/helpers/html_helper.rb +16 -5
  44. data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +6 -1
  45. data/lib/yard/templates/helpers/markup/hybrid_markdown.rb +2147 -0
  46. data/lib/yard/templates/helpers/markup_helper.rb +4 -2
  47. data/lib/yard/version.rb +1 -1
  48. data/po/ja.po +82 -82
  49. data/templates/default/fulldoc/html/css/common.css +1 -1
  50. data/templates/default/fulldoc/html/css/full_list.css +201 -53
  51. data/templates/default/fulldoc/html/css/style.css +988 -389
  52. data/templates/default/fulldoc/html/full_list.erb +4 -4
  53. data/templates/default/fulldoc/html/js/app.js +801 -395
  54. data/templates/default/fulldoc/html/js/full_list.js +332 -242
  55. data/templates/default/layout/html/headers.erb +1 -1
  56. data/templates/default/layout/html/layout.erb +3 -1
  57. data/templates/default/method/html/header.erb +3 -3
  58. data/templates/default/module/html/defines.erb +3 -3
  59. data/templates/default/module/html/inherited_methods.erb +1 -0
  60. data/templates/default/module/html/method_summary.erb +8 -0
  61. data/templates/default/module/setup.rb +20 -0
  62. data/templates/default/onefile/html/layout.erb +3 -4
  63. data/templates/guide/fulldoc/html/css/style.css +347 -97
  64. data/templates/guide/fulldoc/html/js/app.js +61 -33
  65. data/templates/guide/layout/html/layout.erb +69 -72
  66. metadata +14 -4
@@ -1,395 +1,801 @@
1
- window.__app = function () {
2
- var localStorage = {},
3
- sessionStorage = {};
4
- try {
5
- localStorage = window.localStorage;
6
- } catch (e) {}
7
- try {
8
- sessionStorage = window.sessionStorage;
9
- } catch (e) {}
10
-
11
- function createSourceLinks() {
12
- $(".method_details_list .source_code").before(
13
- "<span class='showSource'>[<a href='#' class='toggleSource'>View source</a>]</span>"
14
- );
15
- $(".toggleSource").toggle(
16
- function () {
17
- $(this).parent().nextAll(".source_code").slideDown(100);
18
- $(this).text("Hide source");
19
- },
20
- function () {
21
- $(this).parent().nextAll(".source_code").slideUp(100);
22
- $(this).text("View source");
23
- }
24
- );
25
- }
26
-
27
- function createDefineLinks() {
28
- var tHeight = 0;
29
- $(".defines").after(" <a href='#' class='toggleDefines'>more...</a>");
30
- $(".toggleDefines").toggle(
31
- function () {
32
- tHeight = $(this).parent().prev().height();
33
- $(this).prev().css("display", "inline");
34
- $(this).parent().prev().height($(this).parent().height());
35
- $(this).text("(less)");
36
- },
37
- function () {
38
- $(this).prev().hide();
39
- $(this).parent().prev().height(tHeight);
40
- $(this).text("more...");
41
- }
42
- );
43
- }
44
-
45
- function createFullTreeLinks() {
46
- var tHeight = 0;
47
- $(".inheritanceTree").toggle(
48
- function () {
49
- tHeight = $(this).parent().prev().height();
50
- $(this).parent().toggleClass("showAll");
51
- $(this).text("(hide)");
52
- $(this).parent().prev().height($(this).parent().height());
53
- },
54
- function () {
55
- $(this).parent().toggleClass("showAll");
56
- $(this).parent().prev().height(tHeight);
57
- $(this).text("show all");
58
- }
59
- );
60
- }
61
-
62
- function searchFrameButtons() {
63
- $(".full_list_link").click(function () {
64
- toggleSearchFrame(this, $(this).attr("href"));
65
- return false;
66
- });
67
- window.addEventListener("message", function (e) {
68
- if (e.data === "navEscape") {
69
- $("#nav").slideUp(100);
70
- $("#search a").removeClass("active inactive");
71
- $(window).focus();
72
- }
73
- });
74
-
75
- $(window).resize(function () {
76
- if ($("#search:visible").length === 0) {
77
- $("#nav").removeAttr("style");
78
- $("#search a").removeClass("active inactive");
79
- $(window).focus();
80
- }
81
- });
82
- }
83
-
84
- function toggleSearchFrame(id, link) {
85
- var frame = $("#nav");
86
- $("#search a").removeClass("active").addClass("inactive");
87
- if (frame.attr("src") === link && frame.css("display") !== "none") {
88
- frame.slideUp(100);
89
- $("#search a").removeClass("active inactive");
90
- } else {
91
- $(id).addClass("active").removeClass("inactive");
92
- if (frame.attr("src") !== link) frame.attr("src", link);
93
- frame.slideDown(100);
94
- }
95
- }
96
-
97
- function linkSummaries() {
98
- $(".summary_signature").click(function () {
99
- document.location = $(this).find("a").attr("href");
100
- });
101
- }
102
-
103
- function summaryToggle() {
104
- $(".summary_toggle").click(function (e) {
105
- e.preventDefault();
106
- localStorage.summaryCollapsed = $(this).text();
107
- $(".summary_toggle").each(function () {
108
- $(this).text($(this).text() == "collapse" ? "expand" : "collapse");
109
- var next = $(this).parent().parent().nextAll("ul.summary").first();
110
- if (next.hasClass("compact")) {
111
- next.toggle();
112
- next.nextAll("ul.summary").first().toggle();
113
- } else if (next.hasClass("summary")) {
114
- var list = $('<ul class="summary compact" />');
115
- list.html(next.html());
116
- list.find(".summary_desc, .note").remove();
117
- list.find("a").each(function () {
118
- $(this).html($(this).find("strong").html());
119
- $(this).parent().html($(this)[0].outerHTML);
120
- });
121
- next.before(list);
122
- next.toggle();
123
- }
124
- });
125
- return false;
126
- });
127
- if (localStorage.summaryCollapsed == "collapse") {
128
- $(".summary_toggle").first().click();
129
- } else {
130
- localStorage.summaryCollapsed = "expand";
131
- }
132
- }
133
-
134
- function constantSummaryToggle() {
135
- $(".constants_summary_toggle").click(function (e) {
136
- e.preventDefault();
137
- localStorage.summaryCollapsed = $(this).text();
138
- $(".constants_summary_toggle").each(function () {
139
- $(this).text($(this).text() == "collapse" ? "expand" : "collapse");
140
- var next = $(this).parent().parent().nextAll("dl.constants").first();
141
- if (next.hasClass("compact")) {
142
- next.toggle();
143
- next.nextAll("dl.constants").first().toggle();
144
- } else if (next.hasClass("constants")) {
145
- var list = $('<dl class="constants compact" />');
146
- list.html(next.html());
147
- list.find("dt").each(function () {
148
- $(this).addClass("summary_signature");
149
- $(this).text($(this).text().split("=")[0]);
150
- if ($(this).has(".deprecated").length) {
151
- $(this).addClass("deprecated");
152
- }
153
- });
154
- // Add the value of the constant as "Tooltip" to the summary object
155
- list.find("pre.code").each(function () {
156
- var dt_element = $(this).parent().prev();
157
- var tooltip = $(this).text();
158
- if (dt_element.hasClass("deprecated")) {
159
- tooltip = "Deprecated. " + tooltip;
160
- }
161
- dt_element.attr("title", tooltip);
162
- });
163
- list.find(".docstring, .tags, dd").remove();
164
- next.before(list);
165
- next.toggle();
166
- }
167
- });
168
- return false;
169
- });
170
- if (localStorage.summaryCollapsed == "collapse") {
171
- $(".constants_summary_toggle").first().click();
172
- } else {
173
- localStorage.summaryCollapsed = "expand";
174
- }
175
- }
176
-
177
- function generateTOC() {
178
- if ($("#filecontents").length === 0) return;
179
- var _toc = $('<ol class="top"></ol>');
180
- var show = false;
181
- var toc = _toc;
182
- var counter = 0;
183
- var tags = ["h2", "h3", "h4", "h5", "h6"];
184
- var i;
185
- var curli;
186
- if ($("#filecontents h1").length > 1) tags.unshift("h1");
187
- for (i = 0; i < tags.length; i++) {
188
- tags[i] = "#filecontents " + tags[i];
189
- }
190
- var lastTag = parseInt(tags[0][1], 10);
191
- $(tags.join(", ")).each(function () {
192
- if ($(this).parents(".method_details .docstring").length != 0) return;
193
- if (this.id == "filecontents") return;
194
- show = true;
195
- var thisTag = parseInt(this.tagName[1], 10);
196
- if (this.id.length === 0) {
197
- var proposedId = $(this).attr("toc-id");
198
- if (typeof proposedId != "undefined") this.id = proposedId;
199
- else {
200
- var proposedId = $(this)
201
- .text()
202
- .replace(/[^a-z0-9-]/gi, "_");
203
- if ($("#" + proposedId).length > 0) {
204
- proposedId += counter;
205
- counter++;
206
- }
207
- this.id = proposedId;
208
- }
209
- }
210
- if (thisTag > lastTag) {
211
- for (i = 0; i < thisTag - lastTag; i++) {
212
- if (typeof curli == "undefined") {
213
- curli = $("<li/>");
214
- toc.append(curli);
215
- }
216
- toc = $("<ol/>");
217
- curli.append(toc);
218
- curli = undefined;
219
- }
220
- }
221
- if (thisTag < lastTag) {
222
- for (i = 0; i < lastTag - thisTag; i++) {
223
- toc = toc.parent();
224
- toc = toc.parent();
225
- }
226
- }
227
- var title = $(this).attr("toc-title");
228
- if (typeof title == "undefined") title = $(this).text();
229
- curli = $('<li><a href="#' + this.id + '">' + title + "</a></li>");
230
- toc.append(curli);
231
- lastTag = thisTag;
232
- });
233
- if (!show) return;
234
- html =
235
- '<div id="toc"><p class="title hide_toc"><a href="#"><strong>Table of Contents</strong></a></p></div>';
236
- $("#content").prepend(html);
237
- $("#toc").append(_toc);
238
- $("#toc .hide_toc").toggle(
239
- function () {
240
- $("#toc .top").slideUp("fast");
241
- $("#toc").toggleClass("hidden");
242
- $("#toc .title small").toggle();
243
- },
244
- function () {
245
- $("#toc .top").slideDown("fast");
246
- $("#toc").toggleClass("hidden");
247
- $("#toc .title small").toggle();
248
- }
249
- );
250
- }
251
-
252
- function navResizer() {
253
- const resizer = document.getElementById("resizer");
254
- resizer.addEventListener(
255
- "pointerdown",
256
- function (e) {
257
- resizer.setPointerCapture(e.pointerId);
258
- e.preventDefault();
259
- e.stopPropagation();
260
- },
261
- false
262
- );
263
- resizer.addEventListener(
264
- "pointerup",
265
- function (e) {
266
- resizer.releasePointerCapture(e.pointerId);
267
- e.preventDefault();
268
- e.stopPropagation();
269
- },
270
- false
271
- );
272
- resizer.addEventListener(
273
- "pointermove",
274
- function (e) {
275
- if ((e.buttons & 1) === 0) {
276
- return;
277
- }
278
-
279
- sessionStorage.navWidth = e.pageX.toString();
280
- $(".nav_wrap").css("width", Math.max(200, e.pageX));
281
- e.preventDefault();
282
- e.stopPropagation();
283
- },
284
- false
285
- );
286
-
287
- if (sessionStorage.navWidth) {
288
- $(".nav_wrap").css(
289
- "width",
290
- Math.max(200, parseInt(sessionStorage.navWidth, 10))
291
- );
292
- }
293
- }
294
-
295
- function navExpander() {
296
- if (typeof pathId === "undefined") return;
297
- var done = false,
298
- timer = setTimeout(postMessage, 500);
299
- function postMessage() {
300
- if (done) return;
301
- clearTimeout(timer);
302
- var opts = { action: "expand", path: pathId };
303
- document.getElementById("nav").contentWindow.postMessage(opts, "*");
304
- done = true;
305
- }
306
- }
307
-
308
- function mainFocus() {
309
- var hash = window.location.hash;
310
- if (hash !== "" && $(hash)[0]) {
311
- $(hash)[0].scrollIntoView();
312
- }
313
-
314
- setTimeout(function () {
315
- $("#main").focus();
316
- }, 10);
317
- }
318
-
319
- function navigationChange() {
320
- // This works around the broken anchor navigation with the YARD template.
321
- window.onpopstate = function () {
322
- var hash = window.location.hash;
323
- if (hash !== "" && $(hash)[0]) {
324
- $(hash)[0].scrollIntoView();
325
- }
326
- };
327
- }
328
-
329
- $(document).ready(function () {
330
- navResizer();
331
- navExpander();
332
- createSourceLinks();
333
- createDefineLinks();
334
- createFullTreeLinks();
335
- searchFrameButtons();
336
- linkSummaries();
337
- summaryToggle();
338
- constantSummaryToggle();
339
- generateTOC();
340
- mainFocus();
341
- navigationChange();
342
- });
343
- };
344
- window.__app();
345
-
346
- window.addEventListener(
347
- "message",
348
- async (e) => {
349
- if (e.data.action === "navigate") {
350
- const response = await fetch(e.data.url);
351
- const text = await response.text();
352
- const parser = new DOMParser();
353
- const doc = parser.parseFromString(text, "text/html");
354
-
355
- const classListLink =
356
- document.getElementById("class_list_link").classList;
357
-
358
- const content = doc.querySelector("#main").innerHTML;
359
- document.querySelector("#main").innerHTML = content;
360
- document.title = doc.head.querySelector("title").innerText;
361
- document.head.querySelectorAll("script").forEach((script) => {
362
- if (
363
- !script.type ||
364
- (script.type.includes("text/javascript") && !script.src)
365
- ) {
366
- script.remove();
367
- }
368
- });
369
-
370
- doc.head.querySelectorAll("script").forEach((script) => {
371
- if (
372
- !script.type ||
373
- (script.type.includes("text/javascript") && !script.src)
374
- ) {
375
- const newScript = document.createElement("script");
376
- newScript.type = "text/javascript";
377
- newScript.textContent = script.textContent;
378
- document.head.appendChild(newScript);
379
- }
380
- });
381
-
382
- window.__app();
383
-
384
- document.getElementById("class_list_link").classList = classListLink;
385
-
386
- const url = new URL(e.data.url, "https://localhost");
387
- const hash = decodeURIComponent(url.hash ?? "");
388
- if (hash) {
389
- document.getElementById(hash.substring(1)).scrollIntoView();
390
- }
391
- history.pushState({}, document.title, e.data.url);
392
- }
393
- },
394
- false
395
- );
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
+ })();