Cut an MkDocs query into words the way titles and bodies are - #112
Merged
Merged
Conversation
'oc astral uv pyproject.toml' answered that nothing in the docs' own index matches, though uv has a section titled "The pyproject.toml". The query was split on spaces only, and titles and bodies at every character outside [a-z0-9_], so a query word holding a dot or a dash (pyproject.toml, uv.lock, --group) could never equal a word of the index, and a question's closing "?" left its last word unmatched, which dropped "how do I add a dependency?" to the partial-match list. An accented word was cut apart on both sides and matched nothing. The query, titles, and bodies now go through one wordsOf, which cuts at any character that is not a letter, digit, or underscore in any script, and drops a contraction's tail first so "what's" is "what" rather than "what" and a stray "s" every section would have to match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
oc astral uv pyproject.tomlanswers that nothing matches, though uv's docs have two sections titled "The pyproject.toml". The MkDocs ranker split the query on spaces only, and titles and bodies at every character outside[a-z0-9_], so a query word holding a dot or a dash could never equal a word of the index.Before, on the live uv index:
After:
The same happened to
uv.lock,--group, and any question ending in?, whose last word never matched. An accented word was cut apart on both sides and matched no title.The fix is one
wordsOfused for the query, titles, and bodies. It cuts at any character that is not a letter, digit, or underscore, in any script, and drops a contraction's tail first, so "what's" reads as "what" (a stop word) instead of "what" plus a stray "s" every section would have to match.Test.
tests/mkdocs.test.jsgains one test over a small index:pyproject.toml,what is uv.lock?,--group, anddémarrageeach lead with the section that holds them, and "what's a dependency group?" keeps exactlydependencyandgroupwith no partial flag. Onmainit fails at the first assertion (undefinedwhere'The pyproject.toml'is expected). Full suite: 311 tests, 308 pass, 3 skipped, 0 fail.Left alone. Stop words, stemming, and scores are unchanged. The shared ranker in
nodedocs.js(Node and RDoc) is not touched: it falls back to a substring match, sofs.readFilealready works there. No CHANGELOG line, since the MkDocs backend itself is still under Unreleased.🤖 Generated with Claude Code