rdoc 6.15.0 → 7.0.2

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 (79) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +187 -0
  3. data/History.rdoc +1 -1
  4. data/LEGAL.rdoc +6 -0
  5. data/README.md +20 -3
  6. data/lib/rdoc/code_object/any_method.rb +15 -7
  7. data/lib/rdoc/code_object/class_module.rb +18 -3
  8. data/lib/rdoc/code_object/constant.rb +9 -0
  9. data/lib/rdoc/code_object/method_attr.rb +13 -1
  10. data/lib/rdoc/code_object/top_level.rb +31 -18
  11. data/lib/rdoc/comment.rb +190 -8
  12. data/lib/rdoc/generator/aliki.rb +183 -0
  13. data/lib/rdoc/generator/darkfish.rb +8 -2
  14. data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
  15. data/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
  16. data/lib/rdoc/generator/template/aliki/_head.rhtml +158 -0
  17. data/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
  18. data/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
  19. data/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
  20. data/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
  21. data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +25 -0
  22. data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +25 -0
  23. data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
  24. data/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
  25. data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
  26. data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
  27. data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
  28. data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
  29. data/lib/rdoc/generator/template/aliki/class.rhtml +218 -0
  30. data/lib/rdoc/generator/template/aliki/css/rdoc.css +1943 -0
  31. data/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
  32. data/lib/rdoc/generator/template/aliki/js/aliki.js +505 -0
  33. data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
  34. data/lib/rdoc/generator/template/aliki/js/search_controller.js +129 -0
  35. data/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
  36. data/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
  37. data/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
  38. data/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
  39. data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
  40. data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
  41. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +3 -3
  42. data/lib/rdoc/generator/template/darkfish/_head.rhtml +14 -19
  43. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +8 -8
  44. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +8 -8
  45. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +7 -6
  46. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +6 -6
  47. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +19 -19
  48. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +2 -2
  49. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -0
  50. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +3 -3
  51. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +14 -14
  52. data/lib/rdoc/generator/template/darkfish/class.rhtml +68 -68
  53. data/lib/rdoc/generator/template/darkfish/index.rhtml +4 -3
  54. data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -1
  55. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +2 -1
  56. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +19 -19
  57. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +19 -17
  58. data/lib/rdoc/generator/template/json_index/js/searcher.js +43 -6
  59. data/lib/rdoc/generator.rb +1 -0
  60. data/lib/rdoc/markup/pre_process.rb +34 -10
  61. data/lib/rdoc/markup/to_ansi.rb +4 -0
  62. data/lib/rdoc/markup/to_bs.rb +4 -0
  63. data/lib/rdoc/markup/to_html.rb +6 -4
  64. data/lib/rdoc/markup/to_rdoc.rb +11 -3
  65. data/lib/rdoc/options.rb +21 -10
  66. data/lib/rdoc/parser/c.rb +15 -46
  67. data/lib/rdoc/parser/prism_ruby.rb +121 -113
  68. data/lib/rdoc/parser/ruby.rb +8 -8
  69. data/lib/rdoc/parser/ruby_tools.rb +5 -7
  70. data/lib/rdoc/parser/simple.rb +4 -21
  71. data/lib/rdoc/rdoc.rb +1 -0
  72. data/lib/rdoc/rubygems_hook.rb +3 -3
  73. data/lib/rdoc/text.rb +1 -1
  74. data/lib/rdoc/token_stream.rb +13 -1
  75. data/lib/rdoc/tom_doc.rb +1 -1
  76. data/lib/rdoc/version.rb +1 -1
  77. data/rdoc.gemspec +1 -1
  78. metadata +33 -5
  79. data/CONTRIBUTING.rdoc +0 -219
@@ -0,0 +1,22 @@
1
+ <body role="document" class="file has-toc">
2
+ <%= render '_icons.rhtml' %>
3
+ <%= render '_header.rhtml' %>
4
+ <%= render '_sidebar_toggle.rhtml' %>
5
+
6
+ <nav id="navigation" role="navigation" hidden>
7
+ <%= render '_sidebar_pages.rhtml' %>
8
+ <%= render '_sidebar_classes.rhtml' %>
9
+ </nav>
10
+
11
+ <main role="main">
12
+ <%- if @main_page %>
13
+ <%= @main_page.description %>
14
+ <%- else %>
15
+ <p>This is the API documentation for <%= h @title %>.</p>
16
+ <%- end %>
17
+ </main>
18
+
19
+ <%= render '_aside_toc.rhtml' %>
20
+
21
+ <%= render '_footer.rhtml' %>
22
+ </body>
@@ -0,0 +1,505 @@
1
+ 'use strict';
2
+
3
+ /* ===== Method Source Code Toggling ===== */
4
+
5
+ function showSource(e) {
6
+ let target = e.target;
7
+ while (!target.classList.contains('method-detail')) {
8
+ target = target.parentNode;
9
+ }
10
+ if (typeof target !== "undefined" && target !== null) {
11
+ target = target.querySelector('.method-source-code');
12
+ }
13
+ if (typeof target !== "undefined" && target !== null) {
14
+ target.classList.toggle('active-menu')
15
+ }
16
+ }
17
+
18
+ function hookSourceViews() {
19
+ document.querySelectorAll('.method-source-toggle').forEach((codeObject) => {
20
+ codeObject.addEventListener('click', showSource);
21
+ });
22
+ }
23
+
24
+ /* ===== Search Functionality ===== */
25
+
26
+ function createSearchInstance(input, result) {
27
+ if (!input || !result) return null;
28
+
29
+ result.classList.remove("initially-hidden");
30
+
31
+ const search = new SearchController(search_data, input, result);
32
+
33
+ search.renderItem = function(result) {
34
+ const li = document.createElement('li');
35
+ let html = '';
36
+
37
+ // TODO add relative path to <script> per-page
38
+ html += `<p class="search-match"><a href="${index_rel_prefix}${this.escapeHTML(result.path)}">${this.hlt(result.title)}`;
39
+ if (result.params)
40
+ html += `<span class="params">${result.params}</span>`;
41
+ html += '</a>';
42
+
43
+ // Add type indicator
44
+ if (result.type) {
45
+ const typeLabel = this.formatType(result.type);
46
+ const typeClass = result.type.replace(/_/g, '-');
47
+ html += `<span class="search-type search-type-${this.escapeHTML(typeClass)}">${typeLabel}</span>`;
48
+ }
49
+
50
+ if (result.snippet)
51
+ html += `<div class="search-snippet">${result.snippet}</div>`;
52
+
53
+ li.innerHTML = html;
54
+
55
+ return li;
56
+ }
57
+
58
+ search.formatType = function(type) {
59
+ const typeLabels = {
60
+ 'class': 'class',
61
+ 'module': 'module',
62
+ 'constant': 'const',
63
+ 'instance_method': 'method',
64
+ 'class_method': 'method'
65
+ };
66
+ return typeLabels[type] || type;
67
+ }
68
+
69
+ search.select = function(result) {
70
+ window.location.href = result.firstChild.firstChild.href;
71
+ }
72
+
73
+ search.scrollIntoView = search.scrollInWindow;
74
+
75
+ return search;
76
+ }
77
+
78
+ function hookSearch() {
79
+ const input = document.querySelector('#search-field');
80
+ const result = document.querySelector('#search-results-desktop');
81
+
82
+ if (!input || !result) return; // Exit if search elements not found
83
+
84
+ const search_section = document.querySelector('#search-section');
85
+ if (search_section) {
86
+ search_section.classList.remove("initially-hidden");
87
+ }
88
+
89
+ const search = createSearchInstance(input, result);
90
+ if (!search) return;
91
+
92
+ // Hide search results when clicking outside the search area
93
+ document.addEventListener('click', (e) => {
94
+ if (!e.target.closest('.navbar-search-desktop')) {
95
+ search.hide();
96
+ }
97
+ });
98
+
99
+ // Show search results when focusing on input (if there's a query)
100
+ input.addEventListener('focus', () => {
101
+ if (input.value.trim()) {
102
+ search.show();
103
+ }
104
+ });
105
+
106
+ // Check for ?q= URL parameter and trigger search automatically
107
+ if (typeof URLSearchParams !== 'undefined') {
108
+ const urlParams = new URLSearchParams(window.location.search);
109
+ const queryParam = urlParams.get('q');
110
+ if (queryParam) {
111
+ input.value = queryParam;
112
+ search.search(queryParam, false);
113
+ }
114
+ }
115
+ }
116
+
117
+ /* ===== Keyboard Shortcuts ===== */
118
+
119
+ function hookFocus() {
120
+ document.addEventListener("keydown", (event) => {
121
+ if (document.activeElement.tagName === 'INPUT') {
122
+ return;
123
+ }
124
+ if (event.key === "/") {
125
+ event.preventDefault();
126
+ document.querySelector('#search-field').focus();
127
+ }
128
+ });
129
+ }
130
+
131
+ /* ===== Mobile Navigation ===== */
132
+
133
+ function hookSidebar() {
134
+ const navigation = document.querySelector('#navigation');
135
+ const navigationToggle = document.querySelector('#navigation-toggle');
136
+
137
+ if (!navigation || !navigationToggle) return;
138
+
139
+ const closeNav = () => {
140
+ navigation.hidden = true;
141
+ navigationToggle.ariaExpanded = 'false';
142
+ document.body.classList.remove('nav-open');
143
+ };
144
+
145
+ const openNav = () => {
146
+ navigation.hidden = false;
147
+ navigationToggle.ariaExpanded = 'true';
148
+ document.body.classList.add('nav-open');
149
+ };
150
+
151
+ const toggleNav = () => {
152
+ if (navigation.hidden) {
153
+ openNav();
154
+ } else {
155
+ closeNav();
156
+ }
157
+ };
158
+
159
+ navigationToggle.addEventListener('click', (e) => {
160
+ e.stopPropagation();
161
+ toggleNav();
162
+ });
163
+
164
+ const isSmallViewport = window.matchMedia("(max-width: 1023px)").matches;
165
+
166
+ // The sidebar is hidden by default with the `hidden` attribute
167
+ // On large viewports, we display the sidebar with JavaScript
168
+ // This is better than the opposite approach of hiding it with JavaScript
169
+ // because it avoids flickering the sidebar when the page is loaded, especially on mobile devices
170
+ if (isSmallViewport) {
171
+ // Close nav when clicking links inside it
172
+ document.addEventListener('click', (e) => {
173
+ if (e.target.closest('#navigation a')) {
174
+ closeNav();
175
+ }
176
+ });
177
+
178
+ // Close nav when clicking backdrop
179
+ document.addEventListener('click', (e) => {
180
+ if (!navigation.hidden &&
181
+ !e.target.closest('#navigation') &&
182
+ !e.target.closest('#navigation-toggle')) {
183
+ closeNav();
184
+ }
185
+ });
186
+ } else {
187
+ openNav();
188
+ }
189
+ }
190
+
191
+ /* ===== Right Sidebar Table of Contents ===== */
192
+
193
+ function generateToc() {
194
+ const tocNav = document.querySelector('#toc-nav');
195
+ if (!tocNav) return; // Exit if TOC nav doesn't exist
196
+
197
+ const main = document.querySelector('main');
198
+ if (!main) return;
199
+
200
+ // Find all h2 and h3 headings in the main content
201
+ const headings = main.querySelectorAll('h1, h2, h3');
202
+ if (headings.length === 0) return;
203
+
204
+ const tocList = document.createElement('ul');
205
+ tocList.className = 'toc-list';
206
+
207
+ headings.forEach((heading) => {
208
+ // Skip if heading doesn't have an id
209
+ if (!heading.id) return;
210
+
211
+ const li = document.createElement('li');
212
+ const level = heading.tagName.toLowerCase();
213
+ li.className = `toc-item toc-${level}`;
214
+
215
+ const link = document.createElement('a');
216
+ link.href = `#${heading.id}`;
217
+ link.className = 'toc-link';
218
+ link.textContent = heading.textContent.trim();
219
+ link.setAttribute('data-target', heading.id);
220
+
221
+ li.appendChild(link);
222
+ setHeadingScrollHandler(heading, link);
223
+ tocList.appendChild(li);
224
+ });
225
+
226
+ if (tocList.children.length > 0) {
227
+ tocNav.appendChild(tocList);
228
+ } else {
229
+ // Hide TOC if no headings found
230
+ const tocContainer = document.querySelector('.table-of-contents');
231
+ if (tocContainer) {
232
+ tocContainer.style.display = 'none';
233
+ }
234
+ }
235
+ }
236
+
237
+ function hookTocActiveHighlighting() {
238
+ const tocLinks = document.querySelectorAll('.toc-link');
239
+ const targetHeadings = [];
240
+ tocLinks.forEach((link) => {
241
+ const targetId = link.getAttribute('data-target');
242
+ const heading = document.getElementById(targetId);
243
+ if (heading) {
244
+ targetHeadings.push(heading);
245
+ }
246
+ });
247
+
248
+ if (targetHeadings.length === 0) return;
249
+
250
+ const observerOptions = {
251
+ root: null,
252
+ rootMargin: '0% 0px -35% 0px',
253
+ threshold: 0
254
+ };
255
+
256
+ const intersectingHeadings = new Set();
257
+ const update = () => {
258
+ const firstIntersectingHeading = targetHeadings.find((heading) => {
259
+ return intersectingHeadings.has(heading);
260
+ });
261
+ if (!firstIntersectingHeading) return;
262
+ const correspondingLink = document.querySelector(`.toc-link[data-target="${firstIntersectingHeading.id}"]`);
263
+ if (!correspondingLink) return;
264
+
265
+ // Remove active class from all links
266
+ tocLinks.forEach((link) => {
267
+ link.classList.remove('active');
268
+ });
269
+
270
+ // Add active class to current link
271
+ correspondingLink.classList.add('active');
272
+
273
+ // Scroll link into view if needed
274
+ const tocNav = document.querySelector('#toc-nav');
275
+ if (tocNav) {
276
+ const linkRect = correspondingLink.getBoundingClientRect();
277
+ const navRect = tocNav.getBoundingClientRect();
278
+
279
+ if (linkRect.top < navRect.top || linkRect.bottom > navRect.bottom) {
280
+ correspondingLink.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
281
+ }
282
+ }
283
+ };
284
+ const observer = new IntersectionObserver((entries) => {
285
+ entries.forEach((entry) => {
286
+ if (entry.isIntersecting) {
287
+ intersectingHeadings.add(entry.target);
288
+ } else {
289
+ intersectingHeadings.delete(entry.target);
290
+ }
291
+ });
292
+ update();
293
+ }, observerOptions);
294
+
295
+ // Observe all headings that have corresponding TOC links
296
+ targetHeadings.forEach((heading) => {
297
+ observer.observe(heading);
298
+ });
299
+ }
300
+
301
+ function setHeadingScrollHandler(heading, link) {
302
+ // Smooth scroll to heading when clicking link
303
+ if (!heading.id) return;
304
+
305
+ link.addEventListener('click', (e) => {
306
+ e.preventDefault();
307
+ heading.scrollIntoView({ behavior: 'smooth', block: 'start' });
308
+ history.pushState(null, '', `#${heading.id}`);
309
+ });
310
+ }
311
+
312
+ function setHeadingSelfLinkScrollHandlers() {
313
+ // Clicking link inside heading scrolls smoothly to heading itself
314
+ const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6');
315
+ headings.forEach((heading) => {
316
+ if (!heading.id) return;
317
+
318
+ const link = heading.querySelector(`a[href^="#${heading.id}"]`);
319
+ if (link) setHeadingScrollHandler(heading, link);
320
+ })
321
+ }
322
+
323
+ /* ===== Mobile Search Modal ===== */
324
+
325
+ function hookSearchModal() {
326
+ const searchToggle = document.querySelector('#search-toggle');
327
+ const searchModal = document.querySelector('#search-modal');
328
+ const searchModalClose = document.querySelector('#search-modal-close');
329
+ const searchModalBackdrop = document.querySelector('.search-modal-backdrop');
330
+ const searchInput = document.querySelector('#search-field-mobile');
331
+ const searchResults = document.querySelector('#search-results-mobile');
332
+ const searchEmpty = document.querySelector('.search-modal-empty');
333
+
334
+ if (!searchToggle || !searchModal) return;
335
+
336
+ // Initialize search for mobile modal
337
+ const mobileSearch = createSearchInstance(searchInput, searchResults);
338
+ if (!mobileSearch) return;
339
+
340
+ // Hide empty state when there are results
341
+ const originalRenderItem = mobileSearch.renderItem;
342
+ mobileSearch.renderItem = function(result) {
343
+ if (searchEmpty) searchEmpty.style.display = 'none';
344
+ return originalRenderItem.call(this, result);
345
+ };
346
+
347
+ const openSearchModal = () => {
348
+ searchModal.hidden = false;
349
+ document.body.style.overflow = 'hidden';
350
+ // Focus input after animation
351
+ setTimeout(() => {
352
+ if (searchInput) searchInput.focus();
353
+ }, 100);
354
+ };
355
+
356
+ const closeSearchModal = () => {
357
+ searchModal.hidden = true;
358
+ document.body.style.overflow = '';
359
+ };
360
+
361
+ // Open on button click
362
+ searchToggle.addEventListener('click', openSearchModal);
363
+
364
+ // Close on close button click
365
+ if (searchModalClose) {
366
+ searchModalClose.addEventListener('click', closeSearchModal);
367
+ }
368
+
369
+ // Close on backdrop click
370
+ if (searchModalBackdrop) {
371
+ searchModalBackdrop.addEventListener('click', closeSearchModal);
372
+ }
373
+
374
+ // Close on Escape key
375
+ document.addEventListener('keydown', (e) => {
376
+ if (e.key === 'Escape' && !searchModal.hidden) {
377
+ closeSearchModal();
378
+ }
379
+ });
380
+
381
+ // Check for ?q= URL parameter on mobile and open modal
382
+ if (typeof URLSearchParams !== 'undefined') {
383
+ const urlParams = new URLSearchParams(window.location.search);
384
+ const queryParam = urlParams.get('q');
385
+ const isSmallViewport = window.matchMedia("(max-width: 1023px)").matches;
386
+
387
+ if (queryParam && isSmallViewport) {
388
+ openSearchModal();
389
+ searchInput.value = queryParam;
390
+ mobileSearch.search(queryParam, false);
391
+ }
392
+ }
393
+ }
394
+
395
+ /* ===== Code Block Copy Functionality ===== */
396
+
397
+ function createCopyButton() {
398
+ const button = document.createElement('button');
399
+ button.className = 'copy-code-button';
400
+ button.type = 'button';
401
+ button.setAttribute('aria-label', 'Copy code to clipboard');
402
+ button.setAttribute('title', 'Copy code');
403
+
404
+ // Create clipboard icon SVG
405
+ const clipboardIcon = `
406
+ <svg viewBox="0 0 24 24">
407
+ <rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
408
+ <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
409
+ </svg>
410
+ `;
411
+
412
+ // Create checkmark icon SVG (for copied state)
413
+ const checkIcon = `
414
+ <svg viewBox="0 0 24 24">
415
+ <polyline points="20 6 9 17 4 12"></polyline>
416
+ </svg>
417
+ `;
418
+
419
+ button.innerHTML = clipboardIcon;
420
+ button.dataset.clipboardIcon = clipboardIcon;
421
+ button.dataset.checkIcon = checkIcon;
422
+
423
+ return button;
424
+ }
425
+
426
+ function wrapCodeBlocksWithCopyButton() {
427
+ // Copy buttons are generated dynamically rather than statically in rhtml templates because:
428
+ // - Code blocks are generated by RDoc's markup formatter (RDoc::Markup::ToHtml),
429
+ // not directly in rhtml templates
430
+ // - Modifying the formatter would require extending RDoc's core internals
431
+
432
+ // Find all pre elements that are not already wrapped
433
+ const preElements = document.querySelectorAll('main pre:not(.code-block-wrapper pre)');
434
+
435
+ preElements.forEach((pre) => {
436
+ // Skip if already wrapped
437
+ if (pre.parentElement.classList.contains('code-block-wrapper')) {
438
+ return;
439
+ }
440
+
441
+ // Create wrapper
442
+ const wrapper = document.createElement('div');
443
+ wrapper.className = 'code-block-wrapper';
444
+
445
+ // Insert wrapper before pre
446
+ pre.parentNode.insertBefore(wrapper, pre);
447
+
448
+ // Move pre into wrapper
449
+ wrapper.appendChild(pre);
450
+
451
+ // Create and add copy button
452
+ const copyButton = createCopyButton();
453
+ wrapper.appendChild(copyButton);
454
+
455
+ // Add click handler
456
+ copyButton.addEventListener('click', () => {
457
+ copyCodeToClipboard(pre, copyButton);
458
+ });
459
+ });
460
+ }
461
+
462
+ function copyCodeToClipboard(preElement, button) {
463
+ const code = preElement.textContent;
464
+
465
+ // Use the Clipboard API (supported by all modern browsers)
466
+ if (navigator.clipboard && navigator.clipboard.writeText) {
467
+ navigator.clipboard.writeText(code).then(() => {
468
+ showCopySuccess(button);
469
+ }).catch(() => {
470
+ alert('Failed to copy code.');
471
+ });
472
+ } else {
473
+ alert('Failed to copy code.');
474
+ }
475
+ }
476
+
477
+ function showCopySuccess(button) {
478
+ // Change icon to checkmark
479
+ button.innerHTML = button.dataset.checkIcon;
480
+ button.classList.add('copied');
481
+ button.setAttribute('aria-label', 'Copied!');
482
+ button.setAttribute('title', 'Copied!');
483
+
484
+ // Revert back after 2 seconds
485
+ setTimeout(() => {
486
+ button.innerHTML = button.dataset.clipboardIcon;
487
+ button.classList.remove('copied');
488
+ button.setAttribute('aria-label', 'Copy code to clipboard');
489
+ button.setAttribute('title', 'Copy code');
490
+ }, 2000);
491
+ }
492
+
493
+ /* ===== Initialization ===== */
494
+
495
+ document.addEventListener('DOMContentLoaded', () => {
496
+ hookSourceViews();
497
+ hookSearch();
498
+ hookFocus();
499
+ hookSidebar();
500
+ generateToc();
501
+ setHeadingSelfLinkScrollHandlers();
502
+ hookTocActiveHighlighting();
503
+ hookSearchModal();
504
+ wrapCodeBlocksWithCopyButton();
505
+ });