diff --git a/.buildinfo b/.buildinfo index e1b3c29..4388de6 100644 --- a/.buildinfo +++ b/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: afa1397ce429906958a6e793f2ea2b11 +config: 250b8e0972b8428191589f1e169e4c9a tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/.doctrees/api/mobase.BSAInvalidation.doctree b/.doctrees/api/mobase.BSAInvalidation.doctree index 7aba286..20d82b2 100644 Binary files a/.doctrees/api/mobase.BSAInvalidation.doctree and b/.doctrees/api/mobase.BSAInvalidation.doctree differ diff --git a/.doctrees/api/mobase.DataArchives.doctree b/.doctrees/api/mobase.DataArchives.doctree index 5a3bcbd..b91b3be 100644 Binary files a/.doctrees/api/mobase.DataArchives.doctree and b/.doctrees/api/mobase.DataArchives.doctree differ diff --git a/.doctrees/api/mobase.EndorsedState.doctree b/.doctrees/api/mobase.EndorsedState.doctree index 22b47f3..b58990d 100644 Binary files a/.doctrees/api/mobase.EndorsedState.doctree and b/.doctrees/api/mobase.EndorsedState.doctree differ diff --git a/.doctrees/api/mobase.ExecutableForcedLoadSetting.doctree b/.doctrees/api/mobase.ExecutableForcedLoadSetting.doctree index 8d84fc8..bebe533 100644 Binary files a/.doctrees/api/mobase.ExecutableForcedLoadSetting.doctree and b/.doctrees/api/mobase.ExecutableForcedLoadSetting.doctree differ diff --git a/.doctrees/api/mobase.ExecutableInfo.doctree b/.doctrees/api/mobase.ExecutableInfo.doctree index 1ad8ae9..a96116c 100644 Binary files a/.doctrees/api/mobase.ExecutableInfo.doctree and b/.doctrees/api/mobase.ExecutableInfo.doctree differ diff --git a/.doctrees/api/mobase.FileInfo.doctree b/.doctrees/api/mobase.FileInfo.doctree index 3659c4b..ffdb238 100644 Binary files a/.doctrees/api/mobase.FileInfo.doctree and b/.doctrees/api/mobase.FileInfo.doctree differ diff --git a/.doctrees/api/mobase.FileTreeEntry.doctree b/.doctrees/api/mobase.FileTreeEntry.doctree index 601cce9..f2e466d 100644 Binary files a/.doctrees/api/mobase.FileTreeEntry.doctree and b/.doctrees/api/mobase.FileTreeEntry.doctree differ diff --git a/.doctrees/api/mobase.GamePlugins.doctree b/.doctrees/api/mobase.GamePlugins.doctree index 43dd097..2f60db2 100644 Binary files a/.doctrees/api/mobase.GamePlugins.doctree and b/.doctrees/api/mobase.GamePlugins.doctree differ diff --git a/.doctrees/api/mobase.GuessQuality.doctree b/.doctrees/api/mobase.GuessQuality.doctree index f767d35..2b15f29 100644 Binary files a/.doctrees/api/mobase.GuessQuality.doctree and b/.doctrees/api/mobase.GuessQuality.doctree differ diff --git a/.doctrees/api/mobase.GuessedString.doctree b/.doctrees/api/mobase.GuessedString.doctree index e672c88..e424965 100644 Binary files a/.doctrees/api/mobase.GuessedString.doctree and b/.doctrees/api/mobase.GuessedString.doctree differ diff --git a/.doctrees/api/mobase.IDownloadManager.doctree b/.doctrees/api/mobase.IDownloadManager.doctree index 6d75b75..46ff972 100644 Binary files a/.doctrees/api/mobase.IDownloadManager.doctree and b/.doctrees/api/mobase.IDownloadManager.doctree differ diff --git a/.doctrees/api/mobase.IFileTree.doctree b/.doctrees/api/mobase.IFileTree.doctree index 4182f4b..1e55c32 100644 Binary files a/.doctrees/api/mobase.IFileTree.doctree and b/.doctrees/api/mobase.IFileTree.doctree differ diff --git a/.doctrees/api/mobase.IInstallationManager.doctree b/.doctrees/api/mobase.IInstallationManager.doctree index ec6820b..e165eb2 100644 Binary files a/.doctrees/api/mobase.IInstallationManager.doctree and b/.doctrees/api/mobase.IInstallationManager.doctree differ diff --git a/.doctrees/api/mobase.IModInterface.doctree b/.doctrees/api/mobase.IModInterface.doctree index c803bc1..919a8de 100644 Binary files a/.doctrees/api/mobase.IModInterface.doctree and b/.doctrees/api/mobase.IModInterface.doctree differ diff --git a/.doctrees/api/mobase.IModList.doctree b/.doctrees/api/mobase.IModList.doctree index 564d229..b612692 100644 Binary files a/.doctrees/api/mobase.IModList.doctree and b/.doctrees/api/mobase.IModList.doctree differ diff --git a/.doctrees/api/mobase.IModRepositoryBridge.doctree b/.doctrees/api/mobase.IModRepositoryBridge.doctree index 87f2843..2c0ead5 100644 Binary files a/.doctrees/api/mobase.IModRepositoryBridge.doctree and b/.doctrees/api/mobase.IModRepositoryBridge.doctree differ diff --git a/.doctrees/api/mobase.IOrganizer.doctree b/.doctrees/api/mobase.IOrganizer.doctree index aa8fe96..2fd0a3c 100644 Binary files a/.doctrees/api/mobase.IOrganizer.doctree and b/.doctrees/api/mobase.IOrganizer.doctree differ diff --git a/.doctrees/api/mobase.IPlugin.doctree b/.doctrees/api/mobase.IPlugin.doctree index c38ee5b..ad28f2a 100644 Binary files a/.doctrees/api/mobase.IPlugin.doctree and b/.doctrees/api/mobase.IPlugin.doctree differ diff --git a/.doctrees/api/mobase.IPluginDiagnose.doctree b/.doctrees/api/mobase.IPluginDiagnose.doctree index 54ad5ee..39fee55 100644 Binary files a/.doctrees/api/mobase.IPluginDiagnose.doctree and b/.doctrees/api/mobase.IPluginDiagnose.doctree differ diff --git a/.doctrees/api/mobase.IPluginFileMapper.doctree b/.doctrees/api/mobase.IPluginFileMapper.doctree index 0fd0202..9516eec 100644 Binary files a/.doctrees/api/mobase.IPluginFileMapper.doctree and b/.doctrees/api/mobase.IPluginFileMapper.doctree differ diff --git a/.doctrees/api/mobase.IPluginGame.doctree b/.doctrees/api/mobase.IPluginGame.doctree index 1aa151b..afe10a2 100644 Binary files a/.doctrees/api/mobase.IPluginGame.doctree and b/.doctrees/api/mobase.IPluginGame.doctree differ diff --git a/.doctrees/api/mobase.IPluginInstaller.doctree b/.doctrees/api/mobase.IPluginInstaller.doctree index 8f42160..0f58aab 100644 Binary files a/.doctrees/api/mobase.IPluginInstaller.doctree and b/.doctrees/api/mobase.IPluginInstaller.doctree differ diff --git a/.doctrees/api/mobase.IPluginInstallerCustom.doctree b/.doctrees/api/mobase.IPluginInstallerCustom.doctree index b51121c..26ae647 100644 Binary files a/.doctrees/api/mobase.IPluginInstallerCustom.doctree and b/.doctrees/api/mobase.IPluginInstallerCustom.doctree differ diff --git a/.doctrees/api/mobase.IPluginInstallerSimple.doctree b/.doctrees/api/mobase.IPluginInstallerSimple.doctree index 9e7e0e2..b641936 100644 Binary files a/.doctrees/api/mobase.IPluginInstallerSimple.doctree and b/.doctrees/api/mobase.IPluginInstallerSimple.doctree differ diff --git a/.doctrees/api/mobase.IPluginList.doctree b/.doctrees/api/mobase.IPluginList.doctree index 1cce6a9..0833e09 100644 Binary files a/.doctrees/api/mobase.IPluginList.doctree and b/.doctrees/api/mobase.IPluginList.doctree differ diff --git a/.doctrees/api/mobase.IPluginModPage.doctree b/.doctrees/api/mobase.IPluginModPage.doctree index dfb9cfb..330b646 100644 Binary files a/.doctrees/api/mobase.IPluginModPage.doctree and b/.doctrees/api/mobase.IPluginModPage.doctree differ diff --git a/.doctrees/api/mobase.IPluginPreview.doctree b/.doctrees/api/mobase.IPluginPreview.doctree index dfdd6ed..35a37f6 100644 Binary files a/.doctrees/api/mobase.IPluginPreview.doctree and b/.doctrees/api/mobase.IPluginPreview.doctree differ diff --git a/.doctrees/api/mobase.IPluginRequirement.doctree b/.doctrees/api/mobase.IPluginRequirement.doctree index 5a4aa6b..1fcf98f 100644 Binary files a/.doctrees/api/mobase.IPluginRequirement.doctree and b/.doctrees/api/mobase.IPluginRequirement.doctree differ diff --git a/.doctrees/api/mobase.IPluginTool.doctree b/.doctrees/api/mobase.IPluginTool.doctree index dad1e07..89dff81 100644 Binary files a/.doctrees/api/mobase.IPluginTool.doctree and b/.doctrees/api/mobase.IPluginTool.doctree differ diff --git a/.doctrees/api/mobase.IProfile.doctree b/.doctrees/api/mobase.IProfile.doctree index 830d81d..3885234 100644 Binary files a/.doctrees/api/mobase.IProfile.doctree and b/.doctrees/api/mobase.IProfile.doctree differ diff --git a/.doctrees/api/mobase.ISaveGame.doctree b/.doctrees/api/mobase.ISaveGame.doctree index 52e90f9..f4be3d9 100644 Binary files a/.doctrees/api/mobase.ISaveGame.doctree and b/.doctrees/api/mobase.ISaveGame.doctree differ diff --git a/.doctrees/api/mobase.ISaveGameInfoWidget.doctree b/.doctrees/api/mobase.ISaveGameInfoWidget.doctree index 4d77427..91c1fa8 100644 Binary files a/.doctrees/api/mobase.ISaveGameInfoWidget.doctree and b/.doctrees/api/mobase.ISaveGameInfoWidget.doctree differ diff --git a/.doctrees/api/mobase.InstallResult.doctree b/.doctrees/api/mobase.InstallResult.doctree index 5cae8c0..24deadc 100644 Binary files a/.doctrees/api/mobase.InstallResult.doctree and b/.doctrees/api/mobase.InstallResult.doctree differ diff --git a/.doctrees/api/mobase.LoadOrderMechanism.doctree b/.doctrees/api/mobase.LoadOrderMechanism.doctree index f4d4498..d16a5af 100644 Binary files a/.doctrees/api/mobase.LoadOrderMechanism.doctree and b/.doctrees/api/mobase.LoadOrderMechanism.doctree differ diff --git a/.doctrees/api/mobase.LocalSavegames.doctree b/.doctrees/api/mobase.LocalSavegames.doctree index 9486b3d..236d6fc 100644 Binary files a/.doctrees/api/mobase.LocalSavegames.doctree and b/.doctrees/api/mobase.LocalSavegames.doctree differ diff --git a/.doctrees/api/mobase.Mapping.doctree b/.doctrees/api/mobase.Mapping.doctree index 1f96ffd..3ff05ba 100644 Binary files a/.doctrees/api/mobase.Mapping.doctree and b/.doctrees/api/mobase.Mapping.doctree differ diff --git a/.doctrees/api/mobase.ModDataChecker.doctree b/.doctrees/api/mobase.ModDataChecker.doctree index 1004e7c..5fcd0db 100644 Binary files a/.doctrees/api/mobase.ModDataChecker.doctree and b/.doctrees/api/mobase.ModDataChecker.doctree differ diff --git a/.doctrees/api/mobase.ModDataContent.doctree b/.doctrees/api/mobase.ModDataContent.doctree index 9de63a9..55f01a8 100644 Binary files a/.doctrees/api/mobase.ModDataContent.doctree and b/.doctrees/api/mobase.ModDataContent.doctree differ diff --git a/.doctrees/api/mobase.ModRepositoryFileInfo.doctree b/.doctrees/api/mobase.ModRepositoryFileInfo.doctree index 9424c89..feef164 100644 Binary files a/.doctrees/api/mobase.ModRepositoryFileInfo.doctree and b/.doctrees/api/mobase.ModRepositoryFileInfo.doctree differ diff --git a/.doctrees/api/mobase.ModState.doctree b/.doctrees/api/mobase.ModState.doctree index 3bd0a21..9a4c188 100644 Binary files a/.doctrees/api/mobase.ModState.doctree and b/.doctrees/api/mobase.ModState.doctree differ diff --git a/.doctrees/api/mobase.PluginRequirementFactory.doctree b/.doctrees/api/mobase.PluginRequirementFactory.doctree index e778602..b814621 100644 Binary files a/.doctrees/api/mobase.PluginRequirementFactory.doctree and b/.doctrees/api/mobase.PluginRequirementFactory.doctree differ diff --git a/.doctrees/api/mobase.PluginSetting.doctree b/.doctrees/api/mobase.PluginSetting.doctree index 56deccf..3876a12 100644 Binary files a/.doctrees/api/mobase.PluginSetting.doctree and b/.doctrees/api/mobase.PluginSetting.doctree differ diff --git a/.doctrees/api/mobase.PluginState.doctree b/.doctrees/api/mobase.PluginState.doctree index 45fa9ab..be89c6f 100644 Binary files a/.doctrees/api/mobase.PluginState.doctree and b/.doctrees/api/mobase.PluginState.doctree differ diff --git a/.doctrees/api/mobase.ProfileSetting.doctree b/.doctrees/api/mobase.ProfileSetting.doctree index 8dfdf49..1212bee 100644 Binary files a/.doctrees/api/mobase.ProfileSetting.doctree and b/.doctrees/api/mobase.ProfileSetting.doctree differ diff --git a/.doctrees/api/mobase.ReleaseType.doctree b/.doctrees/api/mobase.ReleaseType.doctree index 8ce2382..a7671cc 100644 Binary files a/.doctrees/api/mobase.ReleaseType.doctree and b/.doctrees/api/mobase.ReleaseType.doctree differ diff --git a/.doctrees/api/mobase.SaveGameInfo.doctree b/.doctrees/api/mobase.SaveGameInfo.doctree index 011deaa..79e82b8 100644 Binary files a/.doctrees/api/mobase.SaveGameInfo.doctree and b/.doctrees/api/mobase.SaveGameInfo.doctree differ diff --git a/.doctrees/api/mobase.ScriptExtender.doctree b/.doctrees/api/mobase.ScriptExtender.doctree index ca48080..c83fcf9 100644 Binary files a/.doctrees/api/mobase.ScriptExtender.doctree and b/.doctrees/api/mobase.ScriptExtender.doctree differ diff --git a/.doctrees/api/mobase.SortMechanism.doctree b/.doctrees/api/mobase.SortMechanism.doctree index 8dbe164..6c1db1a 100644 Binary files a/.doctrees/api/mobase.SortMechanism.doctree and b/.doctrees/api/mobase.SortMechanism.doctree differ diff --git a/.doctrees/api/mobase.TrackedState.doctree b/.doctrees/api/mobase.TrackedState.doctree index 835418f..83e0e29 100644 Binary files a/.doctrees/api/mobase.TrackedState.doctree and b/.doctrees/api/mobase.TrackedState.doctree differ diff --git a/.doctrees/api/mobase.UnmanagedMods.doctree b/.doctrees/api/mobase.UnmanagedMods.doctree index 0cdc1d9..4d6500b 100644 Binary files a/.doctrees/api/mobase.UnmanagedMods.doctree and b/.doctrees/api/mobase.UnmanagedMods.doctree differ diff --git a/.doctrees/api/mobase.VersionInfo.doctree b/.doctrees/api/mobase.VersionInfo.doctree index a27a3aa..7f0f544 100644 Binary files a/.doctrees/api/mobase.VersionInfo.doctree and b/.doctrees/api/mobase.VersionInfo.doctree differ diff --git a/.doctrees/api/mobase.VersionScheme.doctree b/.doctrees/api/mobase.VersionScheme.doctree index d92484f..22cd28f 100644 Binary files a/.doctrees/api/mobase.VersionScheme.doctree and b/.doctrees/api/mobase.VersionScheme.doctree differ diff --git a/.doctrees/api/mobase.getFileVersion.doctree b/.doctrees/api/mobase.getFileVersion.doctree index 5beeb77..64a0003 100644 Binary files a/.doctrees/api/mobase.getFileVersion.doctree and b/.doctrees/api/mobase.getFileVersion.doctree differ diff --git a/.doctrees/api/mobase.getIconForExecutable.doctree b/.doctrees/api/mobase.getIconForExecutable.doctree index f457e39..182a69a 100644 Binary files a/.doctrees/api/mobase.getIconForExecutable.doctree and b/.doctrees/api/mobase.getIconForExecutable.doctree differ diff --git a/.doctrees/api/mobase.getProductVersion.doctree b/.doctrees/api/mobase.getProductVersion.doctree index 4e50e34..bfe44bd 100644 Binary files a/.doctrees/api/mobase.getProductVersion.doctree and b/.doctrees/api/mobase.getProductVersion.doctree differ diff --git a/.doctrees/environment.pickle b/.doctrees/environment.pickle index 7d95c18..e688a09 100644 Binary files a/.doctrees/environment.pickle and b/.doctrees/environment.pickle differ diff --git a/.doctrees/faq.doctree b/.doctrees/faq.doctree index 923410c..730ab56 100644 Binary files a/.doctrees/faq.doctree and b/.doctrees/faq.doctree differ diff --git a/.doctrees/index.doctree b/.doctrees/index.doctree index 369275e..edc7b22 100644 Binary files a/.doctrees/index.doctree and b/.doctrees/index.doctree differ diff --git a/.doctrees/mobase.doctree b/.doctrees/mobase.doctree index c238e0c..a685e7a 100644 Binary files a/.doctrees/mobase.doctree and b/.doctrees/mobase.doctree differ diff --git a/.doctrees/modules.doctree b/.doctrees/modules.doctree index 919621a..7916e71 100644 Binary files a/.doctrees/modules.doctree and b/.doctrees/modules.doctree differ diff --git a/.doctrees/plugin-types.doctree b/.doctrees/plugin-types.doctree index 57a9e2c..63894ae 100644 Binary files a/.doctrees/plugin-types.doctree and b/.doctrees/plugin-types.doctree differ diff --git a/.doctrees/setup-tools.doctree b/.doctrees/setup-tools.doctree index 5e26688..b57ce56 100644 Binary files a/.doctrees/setup-tools.doctree and b/.doctrees/setup-tools.doctree differ diff --git a/.doctrees/writing-plugins.doctree b/.doctrees/writing-plugins.doctree index 6ea0310..d494adb 100644 Binary files a/.doctrees/writing-plugins.doctree and b/.doctrees/writing-plugins.doctree differ diff --git a/_static/basic.css b/_static/basic.css index 30fee9d..f316efc 100644 --- a/_static/basic.css +++ b/_static/basic.css @@ -4,7 +4,7 @@ * * Sphinx stylesheet -- basic theme. * - * :copyright: Copyright 2007-2023 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ diff --git a/_static/doctools.js b/_static/doctools.js index d06a71d..4d67807 100644 --- a/_static/doctools.js +++ b/_static/doctools.js @@ -4,7 +4,7 @@ * * Base JavaScript utilities for all Sphinx HTML documentation. * - * :copyright: Copyright 2007-2023 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ diff --git a/_static/graphviz.css b/_static/graphviz.css index 8d81c02..027576e 100644 --- a/_static/graphviz.css +++ b/_static/graphviz.css @@ -4,7 +4,7 @@ * * Sphinx stylesheet -- graphviz extension. * - * :copyright: Copyright 2007-2023 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ diff --git a/_static/language_data.js b/_static/language_data.js index 250f566..367b8ed 100644 --- a/_static/language_data.js +++ b/_static/language_data.js @@ -5,7 +5,7 @@ * This script contains the language-specific data used by searchtools.js, * namely the list of stopwords, stemmer, scorer and splitter. * - * :copyright: Copyright 2007-2023 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ @@ -13,7 +13,7 @@ var stopwords = ["a", "and", "are", "as", "at", "be", "but", "by", "for", "if", "in", "into", "is", "it", "near", "no", "not", "of", "on", "or", "such", "that", "the", "their", "then", "there", "these", "they", "this", "to", "was", "will", "with"]; -/* Non-minified version is copied as a separate JS file, is available */ +/* Non-minified version is copied as a separate JS file, if available */ /** * Porter Stemmer diff --git a/_static/searchtools.js b/_static/searchtools.js index 7918c3f..92da3f8 100644 --- a/_static/searchtools.js +++ b/_static/searchtools.js @@ -4,7 +4,7 @@ * * Sphinx JavaScript utilities for the full-text search. * - * :copyright: Copyright 2007-2023 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ @@ -99,7 +99,7 @@ const _displayItem = (item, searchTerms, highlightTerms) => { .then((data) => { if (data) listItem.appendChild( - Search.makeSearchSummary(data, searchTerms) + Search.makeSearchSummary(data, searchTerms, anchor) ); // highlight search terms in the summary if (SPHINX_HIGHLIGHT_ENABLED) // set in sphinx_highlight.js @@ -116,8 +116,8 @@ const _finishSearch = (resultCount) => { ); else Search.status.innerText = _( - `Search finished, found ${resultCount} page(s) matching the search query.` - ); + "Search finished, found ${resultCount} page(s) matching the search query." + ).replace('${resultCount}', resultCount); }; const _displayNextItem = ( results, @@ -137,6 +137,22 @@ const _displayNextItem = ( // search finished, update title and status message else _finishSearch(resultCount); }; +// Helper function used by query() to order search results. +// Each input is an array of [docname, title, anchor, descr, score, filename]. +// Order the results by score (in opposite order of appearance, since the +// `_displayNextItem` function uses pop() to retrieve items) and then alphabetically. +const _orderResultsByScoreThenName = (a, b) => { + const leftScore = a[4]; + const rightScore = b[4]; + if (leftScore === rightScore) { + // same score: sort alphabetically + const leftTitle = a[1].toLowerCase(); + const rightTitle = b[1].toLowerCase(); + if (leftTitle === rightTitle) return 0; + return leftTitle > rightTitle ? -1 : 1; // inverted is intentional + } + return leftScore > rightScore ? 1 : -1; +}; /** * Default splitQuery function. Can be overridden in ``sphinx.search`` with a @@ -160,13 +176,26 @@ const Search = { _queued_query: null, _pulse_status: -1, - htmlToText: (htmlString) => { + htmlToText: (htmlString, anchor) => { const htmlElement = new DOMParser().parseFromString(htmlString, 'text/html'); - htmlElement.querySelectorAll(".headerlink").forEach((el) => { el.remove() }); + for (const removalQuery of [".headerlinks", "script", "style"]) { + htmlElement.querySelectorAll(removalQuery).forEach((el) => { el.remove() }); + } + if (anchor) { + const anchorContent = htmlElement.querySelector(`[role="main"] ${anchor}`); + if (anchorContent) return anchorContent.textContent; + + console.warn( + `Anchored content block not found. Sphinx search tries to obtain it via DOM query '[role=main] ${anchor}'. Check your theme or template.` + ); + } + + // if anchor not specified or not found, fall back to main content const docContent = htmlElement.querySelector('[role="main"]'); - if (docContent !== undefined) return docContent.textContent; + if (docContent) return docContent.textContent; + console.warn( - "Content block not found. Sphinx search tries to obtain it via '[role=main]'. Could you check your theme or template." + "Content block not found. Sphinx search tries to obtain it via DOM query '[role=main]'. Check your theme or template." ); return ""; }, @@ -239,16 +268,7 @@ const Search = { else Search.deferQuery(query); }, - /** - * execute search (requires search index to be loaded) - */ - query: (query) => { - const filenames = Search._index.filenames; - const docNames = Search._index.docnames; - const titles = Search._index.titles; - const allTitles = Search._index.alltitles; - const indexEntries = Search._index.indexentries; - + _parseQuery: (query) => { // stem the search terms and add them to the correct list const stemmer = new Stemmer(); const searchTerms = new Set(); @@ -284,16 +304,32 @@ const Search = { // console.info("required: ", [...searchTerms]); // console.info("excluded: ", [...excludedTerms]); - // array of [docname, title, anchor, descr, score, filename] - let results = []; + return [query, searchTerms, excludedTerms, highlightTerms, objectTerms]; + }, + + /** + * execute search (requires search index to be loaded) + */ + _performSearch: (query, searchTerms, excludedTerms, highlightTerms, objectTerms) => { + const filenames = Search._index.filenames; + const docNames = Search._index.docnames; + const titles = Search._index.titles; + const allTitles = Search._index.alltitles; + const indexEntries = Search._index.indexentries; + + // Collect multiple result groups to be sorted separately and then ordered. + // Each is an array of [docname, title, anchor, descr, score, filename]. + const normalResults = []; + const nonMainIndexResults = []; + _removeChildren(document.getElementById("search-progress")); - const queryLower = query.toLowerCase(); + const queryLower = query.toLowerCase().trim(); for (const [title, foundTitles] of Object.entries(allTitles)) { - if (title.toLowerCase().includes(queryLower) && (queryLower.length >= title.length/2)) { + if (title.toLowerCase().trim().includes(queryLower) && (queryLower.length >= title.length/2)) { for (const [file, id] of foundTitles) { let score = Math.round(100 * queryLower.length / title.length) - results.push([ + normalResults.push([ docNames[file], titles[file] !== title ? `${titles[file]} > ${title}` : title, id !== null ? "#" + id : "", @@ -308,46 +344,47 @@ const Search = { // search for explicit entries in index directives for (const [entry, foundEntries] of Object.entries(indexEntries)) { if (entry.includes(queryLower) && (queryLower.length >= entry.length/2)) { - for (const [file, id] of foundEntries) { - let score = Math.round(100 * queryLower.length / entry.length) - results.push([ + for (const [file, id, isMain] of foundEntries) { + const score = Math.round(100 * queryLower.length / entry.length); + const result = [ docNames[file], titles[file], id ? "#" + id : "", null, score, filenames[file], - ]); + ]; + if (isMain) { + normalResults.push(result); + } else { + nonMainIndexResults.push(result); + } } } } // lookup as object objectTerms.forEach((term) => - results.push(...Search.performObjectSearch(term, objectTerms)) + normalResults.push(...Search.performObjectSearch(term, objectTerms)) ); // lookup as search terms in fulltext - results.push(...Search.performTermsSearch(searchTerms, excludedTerms)); + normalResults.push(...Search.performTermsSearch(searchTerms, excludedTerms)); // let the scorer override scores with a custom scoring function - if (Scorer.score) results.forEach((item) => (item[4] = Scorer.score(item))); + if (Scorer.score) { + normalResults.forEach((item) => (item[4] = Scorer.score(item))); + nonMainIndexResults.forEach((item) => (item[4] = Scorer.score(item))); + } - // now sort the results by score (in opposite order of appearance, since the - // display function below uses pop() to retrieve items) and then - // alphabetically - results.sort((a, b) => { - const leftScore = a[4]; - const rightScore = b[4]; - if (leftScore === rightScore) { - // same score: sort alphabetically - const leftTitle = a[1].toLowerCase(); - const rightTitle = b[1].toLowerCase(); - if (leftTitle === rightTitle) return 0; - return leftTitle > rightTitle ? -1 : 1; // inverted is intentional - } - return leftScore > rightScore ? 1 : -1; - }); + // Sort each group of results by score and then alphabetically by name. + normalResults.sort(_orderResultsByScoreThenName); + nonMainIndexResults.sort(_orderResultsByScoreThenName); + + // Combine the result groups in (reverse) order. + // Non-main index entries are typically arbitrary cross-references, + // so display them after other results. + let results = [...nonMainIndexResults, ...normalResults]; // remove duplicate search results // note the reversing of results, so that in the case of duplicates, the highest-scoring entry is kept @@ -361,7 +398,12 @@ const Search = { return acc; }, []); - results = results.reverse(); + return results.reverse(); + }, + + query: (query) => { + const [searchQuery, searchTerms, excludedTerms, highlightTerms, objectTerms] = Search._parseQuery(query); + const results = Search._performSearch(searchQuery, searchTerms, excludedTerms, highlightTerms, objectTerms); // for debugging //Search.lastresults = results.slice(); // a copy @@ -466,14 +508,18 @@ const Search = { // add support for partial matches if (word.length > 2) { const escapedWord = _escapeRegExp(word); - Object.keys(terms).forEach((term) => { - if (term.match(escapedWord) && !terms[word]) - arr.push({ files: terms[term], score: Scorer.partialTerm }); - }); - Object.keys(titleTerms).forEach((term) => { - if (term.match(escapedWord) && !titleTerms[word]) - arr.push({ files: titleTerms[word], score: Scorer.partialTitle }); - }); + if (!terms.hasOwnProperty(word)) { + Object.keys(terms).forEach((term) => { + if (term.match(escapedWord)) + arr.push({ files: terms[term], score: Scorer.partialTerm }); + }); + } + if (!titleTerms.hasOwnProperty(word)) { + Object.keys(titleTerms).forEach((term) => { + if (term.match(escapedWord)) + arr.push({ files: titleTerms[term], score: Scorer.partialTitle }); + }); + } } // no match but word was a required one @@ -496,9 +542,8 @@ const Search = { // create the mapping files.forEach((file) => { - if (fileMap.has(file) && fileMap.get(file).indexOf(word) === -1) - fileMap.get(file).push(word); - else fileMap.set(file, [word]); + if (!fileMap.has(file)) fileMap.set(file, [word]); + else if (fileMap.get(file).indexOf(word) === -1) fileMap.get(file).push(word); }); }); @@ -549,8 +594,8 @@ const Search = { * search summary for a given text. keywords is a list * of stemmed words. */ - makeSearchSummary: (htmlText, keywords) => { - const text = Search.htmlToText(htmlText); + makeSearchSummary: (htmlText, keywords, anchor) => { + const text = Search.htmlToText(htmlText, anchor); if (text === "") return null; const textLower = text.toLowerCase(); diff --git a/api/mobase.BSAInvalidation.html b/api/mobase.BSAInvalidation.html index d5bc3f2..2891858 100644 --- a/api/mobase.BSAInvalidation.html +++ b/api/mobase.BSAInvalidation.html @@ -1,13 +1,15 @@ - + - + BSAInvalidation — MO2 Python Plugin API documentation - - - + + + + +