diff --git a/.gitignore b/.gitignore index 7d8994e232..f4273b5808 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ *.jl.*.cov *.jl.mem Manifest.toml +node_modules/ + test/doctests/builds/ test/examples/builds/ diff --git a/.prettierrc b/.prettierrc index 75fa134123..6098a5c36c 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,3 +1,11 @@ { - "tabWidth": 2 + "tabWidth": 2, + "semi": true, + "singleQuote": true, + "trailingComma": "es5", + "bracketSpacing": true, + "arrowParens": "always", + "useTabs": false, + "printWidth": 80, + "endOfLine": "lf" } diff --git a/CHANGELOG.md b/CHANGELOG.md index d9bcc7e9c8..abb8acf7b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed * `deploydocs` now ignores any global GPG signing Git settings (i.e. `commit.gpgSign = false`). ([#2592]) +## [Unreleased] + +### Fixed +- Fixed an issue where the cursor would be removed from the search box after applying filters. ### Fixed diff --git a/assets/html/js/collapse.js b/assets/html/js/collapse.js index a8365dea02..4831108ef7 100644 --- a/assets/html/js/collapse.js +++ b/assets/html/js/collapse.js @@ -5,65 +5,65 @@ let timer = 0; var isExpanded = true; $(document).on( - "click", - ".docstring .docstring-article-toggle-button", + 'click', + '.docstring .docstring-article-toggle-button', function () { - let articleToggleTitle = "Expand docstring"; + let articleToggleTitle = 'Expand docstring'; const parent = $(this).parent(); debounce(() => { - if (parent.siblings("section").is(":visible")) { + if (parent.siblings('section').is(':visible')) { parent - .find("a.docstring-article-toggle-button") - .removeClass("fa-chevron-down") - .addClass("fa-chevron-right"); + .find('a.docstring-article-toggle-button') + .removeClass('fa-chevron-down') + .addClass('fa-chevron-right'); } else { parent - .find("a.docstring-article-toggle-button") - .removeClass("fa-chevron-right") - .addClass("fa-chevron-down"); + .find('a.docstring-article-toggle-button') + .removeClass('fa-chevron-right') + .addClass('fa-chevron-down'); - articleToggleTitle = "Collapse docstring"; + articleToggleTitle = 'Collapse docstring'; } parent - .children(".docstring-article-toggle-button") - .prop("title", articleToggleTitle); - parent.siblings("section").slideToggle(); + .children('.docstring-article-toggle-button') + .prop('title', articleToggleTitle); + parent.siblings('section').slideToggle(); }); } ); -$(document).on("click", ".docs-article-toggle-button", function (event) { - let articleToggleTitle = "Expand docstring"; - let navArticleToggleTitle = "Expand all docstrings"; +$(document).on('click', '.docs-article-toggle-button', function (event) { + let articleToggleTitle = 'Expand docstring'; + let navArticleToggleTitle = 'Expand all docstrings'; let animationSpeed = event.noToggleAnimation ? 0 : 400; debounce(() => { if (isExpanded) { - $(this).removeClass("fa-chevron-up").addClass("fa-chevron-down"); - $("a.docstring-article-toggle-button") - .removeClass("fa-chevron-down") - .addClass("fa-chevron-right"); + $(this).removeClass('fa-chevron-up').addClass('fa-chevron-down'); + $('a.docstring-article-toggle-button') + .removeClass('fa-chevron-down') + .addClass('fa-chevron-right'); isExpanded = false; - $(".docstring section").slideUp(animationSpeed); + $('.docstring section').slideUp(animationSpeed); } else { - $(this).removeClass("fa-chevron-down").addClass("fa-chevron-up"); - $("a.docstring-article-toggle-button") - .removeClass("fa-chevron-right") - .addClass("fa-chevron-down"); + $(this).removeClass('fa-chevron-down').addClass('fa-chevron-up'); + $('a.docstring-article-toggle-button') + .removeClass('fa-chevron-right') + .addClass('fa-chevron-down'); isExpanded = true; - articleToggleTitle = "Collapse docstring"; - navArticleToggleTitle = "Collapse all docstrings"; + articleToggleTitle = 'Collapse docstring'; + navArticleToggleTitle = 'Collapse all docstrings'; - $(".docstring section").slideDown(animationSpeed); + $('.docstring section').slideDown(animationSpeed); } - $(this).prop("title", navArticleToggleTitle); - $(".docstring-article-toggle-button").prop("title", articleToggleTitle); + $(this).prop('title', navArticleToggleTitle); + $('.docstring-article-toggle-button').prop('title', articleToggleTitle); }); }); diff --git a/assets/html/js/copy.js b/assets/html/js/copy.js index b89fab819b..5a2755ee49 100644 --- a/assets/html/js/copy.js +++ b/assets/html/js/copy.js @@ -1,28 +1,28 @@ function addCopyButtonCallbacks() { - for (const el of document.getElementsByTagName("pre")) { - const button = document.createElement("button"); - button.classList.add("copy-button", "fa-solid", "fa-copy"); - button.setAttribute("aria-label", "Copy this code block"); - button.setAttribute("title", "Copy"); + for (const el of document.getElementsByTagName('pre')) { + const button = document.createElement('button'); + button.classList.add('copy-button', 'fa-solid', 'fa-copy'); + button.setAttribute('aria-label', 'Copy this code block'); + button.setAttribute('title', 'Copy'); el.appendChild(button); const success = function () { - button.classList.add("success", "fa-check"); - button.classList.remove("fa-copy"); + button.classList.add('success', 'fa-check'); + button.classList.remove('fa-copy'); }; const failure = function () { - button.classList.add("error", "fa-xmark"); - button.classList.remove("fa-copy"); + button.classList.add('error', 'fa-xmark'); + button.classList.remove('fa-copy'); }; - button.addEventListener("click", function () { + button.addEventListener('click', function () { copyToClipboard(el.innerText).then(success, failure); setTimeout(function () { - button.classList.add("fa-copy"); - button.classList.remove("success", "fa-check", "fa-xmark"); + button.classList.add('fa-copy'); + button.classList.remove('success', 'fa-check', 'fa-xmark'); }, 5000); }); } @@ -35,13 +35,13 @@ function copyToClipboard(text) { } else { return new Promise(function (resolve, reject) { try { - const el = document.createElement("textarea"); + const el = document.createElement('textarea'); el.textContent = text; - el.style.position = "fixed"; + el.style.position = 'fixed'; el.style.opacity = 0; document.body.appendChild(el); el.select(); - document.execCommand("copy"); + document.execCommand('copy'); resolve(); } catch (err) { @@ -53,8 +53,8 @@ function copyToClipboard(text) { } } -if (document.readyState === "loading") { - document.addEventListener("DOMContentLoaded", addCopyButtonCallbacks); +if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', addCopyButtonCallbacks); } else { addCopyButtonCallbacks(); } diff --git a/assets/html/js/headroom.js b/assets/html/js/headroom.js index 3bbf71a9de..dd05d839b4 100644 --- a/assets/html/js/headroom.js +++ b/assets/html/js/headroom.js @@ -5,7 +5,7 @@ // mobile). window.Headroom = Headroom; // work around buggy module loading? $(document).ready(function () { - $("#documenter .docs-navbar").headroom({ + $('#documenter .docs-navbar').headroom({ tolerance: { up: 10, down: 10 }, }); }); diff --git a/assets/html/js/metadata.js b/assets/html/js/metadata.js index 2756d84ed9..98f2931cd6 100644 --- a/assets/html/js/metadata.js +++ b/assets/html/js/metadata.js @@ -2,11 +2,11 @@ // arguments: $ $(document).ready(function () { - let meta = $("div[data-docstringscollapsed]").data(); + let meta = $('div[data-docstringscollapsed]').data(); if (meta?.docstringscollapsed) { - $("#documenter-article-toggle-button").trigger({ - type: "click", + $('#documenter-article-toggle-button').trigger({ + type: 'click', noToggleAnimation: true, }); } diff --git a/assets/html/js/package-lock.json b/assets/html/js/package-lock.json new file mode 100644 index 0000000000..a2e6a7778f --- /dev/null +++ b/assets/html/js/package-lock.json @@ -0,0 +1,28 @@ +{ + "name": "js", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "prettier": "^3.3.3" + } + }, + "node_modules/prettier": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + } + } +} diff --git a/assets/html/js/package.json b/assets/html/js/package.json new file mode 100644 index 0000000000..c2436a9f75 --- /dev/null +++ b/assets/html/js/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "prettier": "^3.3.3" + } +} diff --git a/assets/html/js/search.js b/assets/html/js/search.js index 038095cb40..bb24cbe7a1 100644 --- a/assets/html/js/search.js +++ b/assets/html/js/search.js @@ -67,11 +67,11 @@ update_search function worker_function(documenterSearchIndex, documenterBaseURL, filters) { importScripts( - "https://cdn.jsdelivr.net/npm/minisearch@6.1.0/dist/umd/index.min.js" + 'https://cdn.jsdelivr.net/npm/minisearch@6.1.0/dist/umd/index.min.js' ); let data = documenterSearchIndex.map((x, key) => { - x["id"] = key; // minisearch requires a unique for each object + x['id'] = key; // minisearch requires a unique for each object return x; }); @@ -79,123 +79,123 @@ function worker_function(documenterSearchIndex, documenterBaseURL, filters) { // (all, any, get, in, is, only, which) and (do, else, for, let, where, while, with) // ideally we'd just filter the original list but it's not available as a variable const stopWords = new Set([ - "a", - "able", - "about", - "across", - "after", - "almost", - "also", - "am", - "among", - "an", - "and", - "are", - "as", - "at", - "be", - "because", - "been", - "but", - "by", - "can", - "cannot", - "could", - "dear", - "did", - "does", - "either", - "ever", - "every", - "from", - "got", - "had", - "has", - "have", - "he", - "her", - "hers", - "him", - "his", - "how", - "however", - "i", - "if", - "into", - "it", - "its", - "just", - "least", - "like", - "likely", - "may", - "me", - "might", - "most", - "must", - "my", - "neither", - "no", - "nor", - "not", - "of", - "off", - "often", - "on", - "or", - "other", - "our", - "own", - "rather", - "said", - "say", - "says", - "she", - "should", - "since", - "so", - "some", - "than", - "that", - "the", - "their", - "them", - "then", - "there", - "these", - "they", - "this", - "tis", - "to", - "too", - "twas", - "us", - "wants", - "was", - "we", - "were", - "what", - "when", - "who", - "whom", - "why", - "will", - "would", - "yet", - "you", - "your", + 'a', + 'able', + 'about', + 'across', + 'after', + 'almost', + 'also', + 'am', + 'among', + 'an', + 'and', + 'are', + 'as', + 'at', + 'be', + 'because', + 'been', + 'but', + 'by', + 'can', + 'cannot', + 'could', + 'dear', + 'did', + 'does', + 'either', + 'ever', + 'every', + 'from', + 'got', + 'had', + 'has', + 'have', + 'he', + 'her', + 'hers', + 'him', + 'his', + 'how', + 'however', + 'i', + 'if', + 'into', + 'it', + 'its', + 'just', + 'least', + 'like', + 'likely', + 'may', + 'me', + 'might', + 'most', + 'must', + 'my', + 'neither', + 'no', + 'nor', + 'not', + 'of', + 'off', + 'often', + 'on', + 'or', + 'other', + 'our', + 'own', + 'rather', + 'said', + 'say', + 'says', + 'she', + 'should', + 'since', + 'so', + 'some', + 'than', + 'that', + 'the', + 'their', + 'them', + 'then', + 'there', + 'these', + 'they', + 'this', + 'tis', + 'to', + 'too', + 'twas', + 'us', + 'wants', + 'was', + 'we', + 'were', + 'what', + 'when', + 'who', + 'whom', + 'why', + 'will', + 'would', + 'yet', + 'you', + 'your', ]); let index = new MiniSearch({ - fields: ["title", "text"], // fields to index for full-text search - storeFields: ["location", "title", "text", "category", "page"], // fields to return with results + fields: ['title', 'text'], // fields to index for full-text search + storeFields: ['location', 'title', 'text', 'category', 'page'], // fields to return with results processTerm: (term) => { let word = stopWords.has(term) ? null : term; if (word) { // custom trimmer that doesn't strip @ and !, which are used in julia macro and function names word = word - .replace(/^[^a-zA-Z0-9@!]+/, "") - .replace(/[^a-zA-Z0-9@!]+$/, ""); + .replace(/^[^a-zA-Z0-9@!]+/, '') + .replace(/[^a-zA-Z0-9@!]+$/, ''); word = word.toLowerCase(); } @@ -220,11 +220,11 @@ function worker_function(documenterSearchIndex, documenterBaseURL, filters) { * Refer: https://github.com/lodash/lodash/blob/main/src/escape.ts */ const htmlEscapes = { - "&": "&", - "<": "<", - ">": ">", - '"': """, - "'": "'", + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', }; /** @@ -241,7 +241,7 @@ function worker_function(documenterSearchIndex, documenterBaseURL, filters) { function escape(string) { return string && reHasUnescapedHtml.test(string) ? string.replace(reUnescapedHtml, (chr) => htmlEscapes[chr]) - : string || ""; + : string || ''; } /** @@ -249,7 +249,7 @@ function worker_function(documenterSearchIndex, documenterBaseURL, filters) { * Refer: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping */ function escapeRegExp(string) { - return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string + return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string } /** @@ -265,13 +265,13 @@ function worker_function(documenterSearchIndex, documenterBaseURL, filters) { let search_divider = `
`; let display_link = result.location.slice(Math.max(0), Math.min(50, result.location.length)) + - (result.location.length > 30 ? "..." : ""); // To cut-off the link because it messes with the overflow of the whole div + (result.location.length > 30 ? '...' : ''); // To cut-off the link because it messes with the overflow of the whole div - if (result.page !== "") { + if (result.page !== '') { display_link += ` (${result.page})`; } searchstring = escapeRegExp(querystring); - let textindex = new RegExp(`${searchstring}`, "i").exec(result.text); + let textindex = new RegExp(`${searchstring}`, 'i').exec(result.text); let text = textindex !== null ? result.text.slice( @@ -281,32 +281,32 @@ function worker_function(documenterSearchIndex, documenterBaseURL, filters) { result.text.length ) ) - : ""; // cut-off text before and after from the match + : ''; // cut-off text before and after from the match - text = text.length ? escape(text) : ""; + text = text.length ? escape(text) : ''; let display_result = text.length - ? "..." + + ? '...' + text.replace( - new RegExp(`${escape(searchstring)}`, "i"), // For first occurrence + new RegExp(`${escape(searchstring)}`, 'i'), // For first occurrence '$&' ) + - "..." - : ""; // highlights the match + '...' + : ''; // highlights the match let in_code = false; - if (!["page", "section"].includes(result.category.toLowerCase())) { + if (!['page', 'section'].includes(result.category.toLowerCase())) { in_code = true; } // We encode the full url to escape some special characters which can lead to broken links let result_div = `
${escape(result.title)}
${result.category}
@@ -334,7 +334,7 @@ function worker_function(documenterSearchIndex, documenterBaseURL, filters) { // Only return relevant results return result.score >= 1; }, - combineWith: "AND", + combineWith: 'AND', }); // Pre-filter to deduplicate and limit to 200 per category to the extent @@ -350,7 +350,7 @@ function worker_function(documenterSearchIndex, documenterBaseURL, filters) { cat = result.category; cnt = counts[cat]; if (cnt < 200) { - id = cat + "---" + result.location; + id = cat + '---' + result.location; if (present[id]) { continue; } @@ -372,19 +372,19 @@ function worker_function(documenterSearchIndex, documenterBaseURL, filters) { function runSearchMainCode() { // `worker = Threads.@spawn worker_function(documenterSearchIndex)`, but in JavaScript! const filters = [ - ...new Set(documenterSearchIndex["docs"].map((x) => x.category)), + ...new Set(documenterSearchIndex['docs'].map((x) => x.category)), ]; const worker_str = - "(" + + '(' + worker_function.toString() + - ")(" + - JSON.stringify(documenterSearchIndex["docs"]) + - "," + + ')(' + + JSON.stringify(documenterSearchIndex['docs']) + + ',' + JSON.stringify(documenterBaseURL) + - "," + + ',' + JSON.stringify(filters) + - ")"; - const worker_blob = new Blob([worker_str], { type: "text/javascript" }); + ')'; + const worker_blob = new Blob([worker_str], { type: 'text/javascript' }); const worker = new Worker(URL.createObjectURL(worker_blob)); // Whether the worker is currently handling a search. This is a boolean @@ -393,16 +393,16 @@ function runSearchMainCode() { // The last search text that was sent to the worker. This is used to determine // if the worker should be launched again when it reports back results. - var last_search_text = ""; + var last_search_text = ''; // The results of the last search. This, in combination with the state of the filters // in the DOM, is used compute the results to display on calls to update_search. var unfiltered_results = []; // Which filter is currently selected - var selected_filter = ""; + var selected_filter = ''; - $(document).on("input", ".documenter-search-input", function (event) { + $(document).on('input', '.documenter-search-input', function (event) { if (!worker_is_running) { launch_search(); } @@ -410,12 +410,12 @@ function runSearchMainCode() { function launch_search() { worker_is_running = true; - last_search_text = $(".documenter-search-input").val(); + last_search_text = $('.documenter-search-input').val(); worker.postMessage(last_search_text); } worker.onmessage = function (e) { - if (last_search_text !== $(".documenter-search-input").val()) { + if (last_search_text !== $('.documenter-search-input').val()) { launch_search(); } else { worker_is_running = false; @@ -425,9 +425,9 @@ function runSearchMainCode() { update_search(); }; - $(document).on("click", ".search-filter", function () { - if ($(this).hasClass("search-filter-selected")) { - selected_filter = ""; + $(document).on('click', '.search-filter', function () { + if ($(this).hasClass('search-filter-selected')) { + selected_filter = ''; } else { selected_filter = $(this).text().toLowerCase(); } @@ -440,10 +440,10 @@ function runSearchMainCode() { * Make/Update the search component */ function update_search() { - let querystring = $(".documenter-search-input").val(); + let querystring = $('.documenter-search-input').val(); if (querystring.trim()) { - if (selected_filter == "") { + if (selected_filter == '') { results = unfiltered_results; } else { results = unfiltered_results.filter((result) => { @@ -458,7 +458,7 @@ function runSearchMainCode() { if (results.length) { let links = []; let count = 0; - let search_results = ""; + let search_results = ''; for (var i = 0, n = results.length; i < n && count < 200; ++i) { let result = results[i]; @@ -470,11 +470,11 @@ function runSearchMainCode() { } if (count == 1) { - count_str = "1 result"; + count_str = '1 result'; } else if (count == 200) { - count_str = "200+ results"; + count_str = '200+ results'; } else { - count_str = count + " results"; + count_str = count + ' results'; } let result_count = `
${count_str}
`; @@ -499,19 +499,23 @@ function runSearchMainCode() { `; } - if ($(".search-modal-card-body").hasClass("is-justify-content-center")) { - $(".search-modal-card-body").removeClass("is-justify-content-center"); + if ($('.search-modal-card-body').hasClass('is-justify-content-center')) { + $('.search-modal-card-body').removeClass('is-justify-content-center'); } - $(".search-modal-card-body").html(search_result_container); + $('.search-modal-card-body').html(search_result_container); + // Refocus the search input field when there's no search query + $('.documenter-search-input').focus(); } else { - if (!$(".search-modal-card-body").hasClass("is-justify-content-center")) { - $(".search-modal-card-body").addClass("is-justify-content-center"); + if (!$('.search-modal-card-body').hasClass('is-justify-content-center')) { + $('.search-modal-card-body').addClass('is-justify-content-center'); } - $(".search-modal-card-body").html(` + $('.search-modal-card-body').html(`
Type something to get started!
`); + // Refocus the search input field when there's no search query + $('.documenter-search-input').focus(); } } @@ -529,7 +533,7 @@ function runSearchMainCode() { return `
${val}`; } }) - .join(""); + .join(''); return `
@@ -544,10 +548,10 @@ function waitUntilSearchIndexAvailable() { // has finished loading and documenterSearchIndex gets defined. // So we need to wait until the search index actually loads before setting // up all the search-related stuff. - if (typeof documenterSearchIndex !== "undefined") { + if (typeof documenterSearchIndex !== 'undefined') { runSearchMainCode(); } else { - console.warn("Search Index not available, waiting"); + console.warn('Search Index not available, waiting'); setTimeout(waitUntilSearchIndexAvailable, 1000); } } diff --git a/assets/html/js/settings.js b/assets/html/js/settings.js index 068e98efdf..53fbba9e15 100644 --- a/assets/html/js/settings.js +++ b/assets/html/js/settings.js @@ -3,16 +3,16 @@ // Modal settings dialog $(document).ready(function () { - var settings = $("#documenter-settings"); - $("#documenter-settings-button").click(function () { - settings.toggleClass("is-active"); + var settings = $('#documenter-settings'); + $('#documenter-settings-button').click(function () { + settings.toggleClass('is-active'); }); // Close the dialog if X is clicked - $("#documenter-settings button.delete").click(function () { - settings.removeClass("is-active"); + $('#documenter-settings button.delete').click(function () { + settings.removeClass('is-active'); }); // Close dialog if ESC is pressed $(document).keyup(function (e) { - if (e.keyCode == 27) settings.removeClass("is-active"); + if (e.keyCode == 27) settings.removeClass('is-active'); }); }); diff --git a/assets/html/js/shortcut.js b/assets/html/js/shortcut.js index 55bdc6f9c5..d45c44573c 100644 --- a/assets/html/js/shortcut.js +++ b/assets/html/js/shortcut.js @@ -47,24 +47,24 @@ $(document).ready(function () { ` ); - document.querySelector(".docs-search-query").addEventListener("click", () => { + document.querySelector('.docs-search-query').addEventListener('click', () => { openModal(); }); document - .querySelector(".close-search-modal") - .addEventListener("click", () => { + .querySelector('.close-search-modal') + .addEventListener('click', () => { closeModal(); }); - $(document).on("click", ".search-result-link", function () { + $(document).on('click', '.search-result-link', function () { closeModal(); }); - document.addEventListener("keydown", (event) => { - if ((event.ctrlKey || event.metaKey) && event.key === "/") { + document.addEventListener('keydown', (event) => { + if ((event.ctrlKey || event.metaKey) && event.key === '/') { openModal(); - } else if (event.key === "Escape") { + } else if (event.key === 'Escape') { closeModal(); } @@ -73,32 +73,32 @@ $(document).ready(function () { // Functions to open and close a modal function openModal() { - let searchModal = document.querySelector("#search-modal"); + let searchModal = document.querySelector('#search-modal'); - searchModal.classList.add("is-active"); - document.querySelector(".documenter-search-input").focus(); + searchModal.classList.add('is-active'); + document.querySelector('.documenter-search-input').focus(); } function closeModal() { - let searchModal = document.querySelector("#search-modal"); + let searchModal = document.querySelector('#search-modal'); let initial_search_body = `
Type something to get started!
`; - searchModal.classList.remove("is-active"); - document.querySelector(".documenter-search-input").blur(); + searchModal.classList.remove('is-active'); + document.querySelector('.documenter-search-input').blur(); - if (!$(".search-modal-card-body").hasClass("is-justify-content-center")) { - $(".search-modal-card-body").addClass("is-justify-content-center"); + if (!$('.search-modal-card-body').hasClass('is-justify-content-center')) { + $('.search-modal-card-body').addClass('is-justify-content-center'); } - $(".documenter-search-input").val(""); - $(".search-modal-card-body").html(initial_search_body); + $('.documenter-search-input').val(''); + $('.search-modal-card-body').html(initial_search_body); } document - .querySelector("#search-modal .modal-background") - .addEventListener("click", () => { + .querySelector('#search-modal .modal-background') + .addEventListener('click', () => { closeModal(); }); }); diff --git a/assets/html/js/sidebar.js b/assets/html/js/sidebar.js index 6e01092d0a..459cbaab86 100644 --- a/assets/html/js/sidebar.js +++ b/assets/html/js/sidebar.js @@ -3,22 +3,22 @@ // Manages the showing and hiding of the sidebar. $(document).ready(function () { - var sidebar = $("#documenter > .docs-sidebar"); - var sidebar_button = $("#documenter-sidebar-button"); + var sidebar = $('#documenter > .docs-sidebar'); + var sidebar_button = $('#documenter-sidebar-button'); sidebar_button.click(function (ev) { ev.preventDefault(); - sidebar.toggleClass("visible"); - if (sidebar.hasClass("visible")) { + sidebar.toggleClass('visible'); + if (sidebar.hasClass('visible')) { // Makes sure that the current menu item is visible in the sidebar. - $("#documenter .docs-menu a.is-active").focus(); + $('#documenter .docs-menu a.is-active').focus(); } }); - $("#documenter > .docs-main").bind("click", function (ev) { + $('#documenter > .docs-main').bind('click', function (ev) { if ($(ev.target).is(sidebar_button)) { return; } - if (sidebar.hasClass("visible")) { - sidebar.removeClass("visible"); + if (sidebar.hasClass('visible')) { + sidebar.removeClass('visible'); } }); }); @@ -26,27 +26,27 @@ $(document).ready(function () { // Resizes the package name / sitename in the sidebar if it is too wide. // Inspired by: https://github.com/davatron5000/FitText.js $(document).ready(function () { - e = $("#documenter .docs-autofit"); + e = $('#documenter .docs-autofit'); function resize() { - var L = parseInt(e.css("max-width"), 10); + var L = parseInt(e.css('max-width'), 10); var L0 = e.width(); if (L0 > L) { - var h0 = parseInt(e.css("font-size"), 10); - e.css("font-size", (L * h0) / L0); + var h0 = parseInt(e.css('font-size'), 10); + e.css('font-size', (L * h0) / L0); // TODO: make sure it survives resizes? } } // call once and then register events resize(); $(window).resize(resize); - $(window).on("orientationchange", resize); + $(window).on('orientationchange', resize); }); // Scroll the navigation bar to the currently selected menu item $(document).ready(function () { - var sidebar = $("#documenter .docs-menu").get(0); - var active = $("#documenter .docs-menu .is-active").get(0); - if (typeof active !== "undefined") { + var sidebar = $('#documenter .docs-menu').get(0); + var active = $('#documenter .docs-menu .is-active').get(0); + if (typeof active !== 'undefined') { sidebar.scrollTop = active.offsetTop - sidebar.offsetTop - 15; } }); diff --git a/assets/html/js/themes.js b/assets/html/js/themes.js index 7ecd649552..3647f568e2 100644 --- a/assets/html/js/themes.js +++ b/assets/html/js/themes.js @@ -4,14 +4,14 @@ // Theme picker setup $(document).ready(function () { // onchange callback - $("#documenter-themepicker").change(function themepick_callback(ev) { - var themename = $("#documenter-themepicker option:selected").attr("value"); - if (themename === "auto") { + $('#documenter-themepicker').change(function themepick_callback(ev) { + var themename = $('#documenter-themepicker option:selected').attr('value'); + if (themename === 'auto') { // set_theme(window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'); - window.localStorage.removeItem("documenter-theme"); + window.localStorage.removeItem('documenter-theme'); } else { // set_theme(themename); - window.localStorage.setItem("documenter-theme", themename); + window.localStorage.setItem('documenter-theme', themename); } // We re-use the global function from themeswap.js to actually do the swapping. set_theme_from_local_storage(); @@ -19,10 +19,10 @@ $(document).ready(function () { // Make sure that the themepicker displays the correct theme when the theme is retrieved // from localStorage - if (typeof window.localStorage !== "undefined") { - var theme = window.localStorage.getItem("documenter-theme"); + if (typeof window.localStorage !== 'undefined') { + var theme = window.localStorage.getItem('documenter-theme'); if (theme !== null) { - $("#documenter-themepicker option").each(function (i, e) { + $('#documenter-themepicker option').each(function (i, e) { e.selected = e.value === theme; }); } diff --git a/assets/html/js/versions.js b/assets/html/js/versions.js index 40cbb37f21..c068d34e04 100644 --- a/assets/html/js/versions.js +++ b/assets/html/js/versions.js @@ -6,48 +6,48 @@ $(document).ready(function () { // If the version selector is disabled with DOCUMENTER_VERSION_SELECTOR_DISABLED in the // siteinfo.js file, we just return immediately and not display the version selector. if ( - typeof DOCUMENTER_VERSION_SELECTOR_DISABLED === "boolean" && + typeof DOCUMENTER_VERSION_SELECTOR_DISABLED === 'boolean' && DOCUMENTER_VERSION_SELECTOR_DISABLED ) { return; } - var version_selector = $("#documenter .docs-version-selector"); - var version_selector_select = $("#documenter .docs-version-selector select"); + var version_selector = $('#documenter .docs-version-selector'); + var version_selector_select = $('#documenter .docs-version-selector select'); version_selector_select.change(function (x) { target_href = version_selector_select - .children("option:selected") + .children('option:selected') .get(0).value; window.location.href = target_href; }); // add the current version to the selector based on siteinfo.js, but only if the selector is empty if ( - typeof DOCUMENTER_CURRENT_VERSION !== "undefined" && - $("#version-selector > option").length == 0 + typeof DOCUMENTER_CURRENT_VERSION !== 'undefined' && + $('#version-selector > option').length == 0 ) { var option = $( "" + '' ); version_selector_select.append(option); } - if (typeof DOC_VERSIONS !== "undefined") { - var existing_versions = version_selector_select.children("option"); + if (typeof DOC_VERSIONS !== 'undefined') { + var existing_versions = version_selector_select.children('option'); var existing_versions_texts = existing_versions.map(function (i, x) { return x.text; }); DOC_VERSIONS.forEach(function (each) { - var version_url = documenterBaseURL + "/../" + each + "/"; + var version_url = documenterBaseURL + '/../' + each + '/'; var existing_id = $.inArray(each, existing_versions_texts); // if not already in the version selector, add it as a new option, // otherwise update the old option with the URL and enable it if (existing_id == -1) { var option = $( - "" + "' ); version_selector_select.append(option); } else { @@ -59,7 +59,7 @@ $(document).ready(function () { } // only show the version selector if the selector has been populated - if (version_selector_select.children("option").length > 0) { - version_selector.toggleClass("visible"); + if (version_selector_select.children('option').length > 0) { + version_selector.toggleClass('visible'); } }); diff --git a/assets/html/themeswap.js b/assets/html/themeswap.js index 9f5eebe6aa..2096a8bf2f 100644 --- a/assets/html/themeswap.js +++ b/assets/html/themeswap.js @@ -7,11 +7,11 @@ function set_theme_from_local_storage() { if (window.localStorage != null) { // Get the user-picked theme from localStorage. May be `null`, which means the default // theme. - theme = window.localStorage.getItem("documenter-theme"); + theme = window.localStorage.getItem('documenter-theme'); } // Check if the users preference is for dark color scheme var darkPreference = - window.matchMedia("(prefers-color-scheme: dark)").matches === true; + window.matchMedia('(prefers-color-scheme: dark)').matches === true; // Initialize a few variables for the loop: // // - active: will contain the index of the theme that should be active. Note that there @@ -29,16 +29,16 @@ function set_theme_from_local_storage() { var ss = document.styleSheets[i]; // The tag of each style sheet is expected to have a data-theme-name attribute // which must contain the name of the theme. The names in localStorage much match this. - var themename = ss.ownerNode.getAttribute("data-theme-name"); + var themename = ss.ownerNode.getAttribute('data-theme-name'); // attribute not set => non-theme stylesheet => ignore if (themename === null) continue; // To distinguish the default (primary) theme, it needs to have the data-theme-primary // attribute set. - if (ss.ownerNode.getAttribute("data-theme-primary") !== null) { + if (ss.ownerNode.getAttribute('data-theme-primary') !== null) { primaryLightTheme = themename; } // Check if the theme is primary dark theme so that we could store its name in darkTheme - if (ss.ownerNode.getAttribute("data-theme-primary-dark") !== null) { + if (ss.ownerNode.getAttribute('data-theme-primary-dark') !== null) { primaryDarkTheme = themename; } // If we find a matching theme (and it's not the default), we'll set active to non-null @@ -49,7 +49,7 @@ function set_theme_from_local_storage() { var activeTheme = null; if (active !== null) { // If we did find an active theme, we'll (1) add the theme--$(theme) class to - document.getElementsByTagName("html")[0].className = "theme--" + theme; + document.getElementsByTagName('html')[0].className = 'theme--' + theme; activeTheme = theme; } else { // If we did _not_ find an active theme, then we need to fall back to the primary theme @@ -58,23 +58,23 @@ function set_theme_from_local_storage() { // In case it somehow happens that the relevant primary theme was not found in the // preceding loop, we abort without doing anything. if (activeTheme === null) { - console.error("Unable to determine primary theme."); + console.error('Unable to determine primary theme.'); return; } // When switching to the primary light theme, then we must not have a class name // for the tag. That's only for non-primary or the primary dark theme. if (darkPreference) { - document.getElementsByTagName("html")[0].className = - "theme--" + activeTheme; + document.getElementsByTagName('html')[0].className = + 'theme--' + activeTheme; } else { - document.getElementsByTagName("html")[0].className = ""; + document.getElementsByTagName('html')[0].className = ''; } } for (var i = 0; i < document.styleSheets.length; i++) { var ss = document.styleSheets[i]; // The tag of each style sheet is expected to have a data-theme-name attribute // which must contain the name of the theme. The names in localStorage much match this. - var themename = ss.ownerNode.getAttribute("data-theme-name"); + var themename = ss.ownerNode.getAttribute('data-theme-name'); // attribute not set => non-theme stylesheet => ignore if (themename === null) continue; // we'll disable all the stylesheets, except for the active one diff --git a/assets/html/warner.js b/assets/html/warner.js index 3f6f5d0083..2f4a2ec760 100644 --- a/assets/html/warner.js +++ b/assets/html/warner.js @@ -22,21 +22,21 @@ function maybeAddWarning() { // Add a noindex meta tag (unless one exists) so that search engines don't index this version of the docs. if (document.body.querySelector('meta[name="robots"]') === null) { - const meta = document.createElement("meta"); - meta.name = "robots"; - meta.content = "noindex"; + const meta = document.createElement('meta'); + meta.name = 'robots'; + meta.content = 'noindex'; - document.getElementsByTagName("head")[0].appendChild(meta); + document.getElementsByTagName('head')[0].appendChild(meta); } - const div = document.createElement("div"); - div.classList.add("outdated-warning-overlay"); - const closer = document.createElement("button"); - closer.classList.add("outdated-warning-closer", "delete"); - closer.addEventListener("click", function () { + const div = document.createElement('div'); + div.classList.add('outdated-warning-overlay'); + const closer = document.createElement('button'); + closer.classList.add('outdated-warning-closer', 'delete'); + closer.addEventListener('click', function () { document.body.removeChild(div); }); - const href = window.documenterBaseURL + "/../" + window.DOCUMENTER_STABLE; + const href = window.documenterBaseURL + '/../' + window.DOCUMENTER_STABLE; div.innerHTML = 'This documentation is not for the latest stable release, but for either the development version or an older release.
=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000000..c2436a9f75 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "prettier": "^3.3.3" + } +}