Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Optimize search by building index locally. #1061
This builds an actual lunr.js search index via Node.js in addition to a JSON
If Node fails (not installed or errors out), then fallback to old behavior
Partially addresses #859.
I've decided that there is no reason to not commit this part of the solution outlined in #859 (see this comment). The rest can come when we do the refactor later (webworkers will require a refactor anyway, so we might as well do that with the move to a plugin). For most users (who won't have Node.js installed) nothing will change. But for those who have Node.js installed (and/or need this feature), they can start using/testing it now and it can even be better in the next release.
This builds an actual lunr.js search index via Node.js in addition to a JSON array of page objects previously used to build the index client side. Note that both are needed as the array of page objects is used to display search results. If Node fails (not installed or errors out), then fallback to old behavior by creating an empty index. If the client (browser) receives an empty index, then it builds the index from the array of pages as previously, which is fine for most (small) sites. Large sites will want to make sure Node is installed to avoid the browser from hanging during index creation. Partially addresses #859.
Oh, I forgot PyExecJS doesn't work on Python 2.6. Unless we want to drop Py26 now, this will have to wait till the next release.
Regardless, this PR packages the feature up in a nice diff for users to manually merge if they desire. Or you can always just install MkDocs from this branch:
Any feedback is always welcome.
Work on search was delayed until the Plugin API was put in place. The Plugin API is now available in the 1.0.dev branch and the existing search feature has been broken out into a plugin . We intend to refactor search in that (or a new) plugin in the near future. Of course, as it is now a plugin, third parties could create their own plugin which offers a different set of defaults. The 1.0.dev branch will be available in the next major release; however feedback on the new API now would help move move development along.
* Use a web worker in the browser with a fallback (fixes #859 & closes #1396). * Optionally pre-build search index (fixes #859 & closes #1061). * Upgrade to lunr.js 2.x (fixes #1319). * Support search in languages other than English (fixes #826). * Allow the user to define the word separators (fixes #867). * Only run searches for queries of length > 2 (fixes #1127). * Remove dependency on require.js, mustache, etc. (fixes #1218). * Compress the search index (fixes #1128).