Improve the search bar in the html documentation#4417
Open
d-torrance wants to merge 5 commits into
Open
Conversation
Add lunr ^2.3.9 as an npm dependency with a copy rule in package.json, and check in the resulting lunr.min.js alongside prism.js and katex. The MIT license is embedded in the file header. Run `npm install` in M2/Macaulay2/packages/Style to update. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- search.js: builds a lunr index on page load from window.M2SearchData, wires up #search-input to show a paginated dropdown (10 results at a time, "Show N more..." button, smooth scroll, "No results found." message, closes on outside click). Appends * to each search term for prefix matching as you type. - doc.css: styles for the search container, results dropdown, result rows (name / package / tagline), "show more" button, no-results message - html.m2: load lunr.min.js, search-data.js, and search.js in defaultHEAD - installPackage.m2: replace the Google search form in the button bar with a local #search-input / #search-results container Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add installSearchData(), called at the end of installHTML(), which
appends an Object.assign block to {Style}/search-data.js for every
non-undocumented, non-secondary tag in the package. Each record
stores id, name, package, tagline, and path (relative to the Style
directory so it resolves correctly from any page depth).
Style is always the first package installed in a full docs build, so
its install clears any existing search-data.js to ensure each build
starts fresh without duplicates — no build system cooperation needed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a workflow_dispatch workflow that builds M2 from source, then regenerates and commits the two sets of generated files in the Style package: - prism.js / prism.js.LICENSE.txt via make -C Macaulay2/editors prism/prism.js - search-data.js / search-data.json via make (install-packages) Run via Actions → "Update generated Style assets" → Run workflow, selecting the branch to update. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move ignore-words and skip options out of lint.yml into a .codespellrc config file so the lint command stays clean. Also skip lunr.min.js, whose minified variable names trigger false positives. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
I tested this a bit via the link in the description. The UX is very nice and e.g. searching for "modules" turned up all the nodes I know of that I wanted to see (within a page or two). |
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.
We use lunr.js to power the search bar in the html documentation, which currently just sends folks to Google.
We add a couple new JavaScript files to the Style package, one to power the search and one containing an index constructed by the calls to
installPackageduring the build.In addition, there's a new workflow that I'll plan on running close to each release to update the search index file in the repository (and also the prism.js highlighting symbols while we're at it).,
Here it is in action: https://d-torrance.github.io/M2
AI Disclosure
The code was almost completely written by Claude with lots of human oversight.