diff --git a/.config/typedoc.json b/.config/typedoc.json index 8c5fa9b53..7c97d4b06 100644 --- a/.config/typedoc.json +++ b/.config/typedoc.json @@ -28,5 +28,12 @@ "external": false, "@internal": false }, + "searchGroupBoosts": { + "Classes": 2.0, + "Interfaces": 2.0, + "Enumerations": 2.0, + "Type Aliases": 2.0 + }, + "searchInComments": true, "logLevel": "Verbose" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 154fa05ee..5308eda78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Unreleased +### Features + +- The `DEBUG_SEARCH_WEIGHTS` global variable can now be set on `window` to add search scoring information in the search results. + ## v0.23.4 (2022-07-02) ### Bug Fixes diff --git a/src/lib/output/themes/default/assets/typedoc/components/Search.ts b/src/lib/output/themes/default/assets/typedoc/components/Search.ts index caa845163..0fcc1a6e5 100644 --- a/src/lib/output/themes/default/assets/typedoc/components/Search.ts +++ b/src/lib/output/themes/default/assets/typedoc/components/Search.ts @@ -169,7 +169,7 @@ function updateResults( // boost by exact match on name if (row.name.toLowerCase().startsWith(searchText.toLowerCase())) { boost *= - 1 + 1 / (Math.abs(row.name.length - searchText.length) * 10); + 1 + 1 / (1 + Math.abs(row.name.length - searchText.length)); } item.score *= boost; @@ -182,6 +182,9 @@ function updateResults( // Bold the matched part of the query in the search results let name = boldMatches(row.name, searchText); + if (globalThis.DEBUG_SEARCH_WEIGHTS) { + name += ` (score: ${res[i].score.toFixed(2)})`; + } if (row.parent) { name = `${boldMatches( row.parent,