-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create the backend search index generation for documentation pages #459
Merged
caendesilva
merged 29 commits into
master
from
447-add-simple-optional-search-feature-to-documentation-pages
May 29, 2022
Merged
Create the backend search index generation for documentation pages #459
caendesilva
merged 29 commits into
master
from
447-add-simple-optional-search-feature-to-documentation-pages
May 29, 2022
Conversation
This file contains 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
Apply fixes from StyleCI
…-pages' of github.com:hydephp/framework into 447-add-simple-optional-search-feature-to-documentation-pages
Apply fixes from StyleCI
5 tasks
From a PHPDoc I wrote while working on the search content generation:
|
Codecov Report
@@ Coverage Diff @@
## master #459 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 11 11
=========================================
Hits 11 11 Continue to review full report at Codecov.
|
5 tasks
caendesilva
pushed a commit
that referenced
this pull request
Sep 1, 2022
Rename build hooks to build tasks hydephp/develop@1100a10
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.
About
Adds an action which generates a search index for documentation pages used for the HydeSearch plugin
How it works
The way it currently works is that it takes a plain-text representation of all Markdown documentation pages and adds them paired with metadata such as the page title and URI path.
It is pretty slow to generate, so I have not yet added it to the
hyde build
command. Instead, it's generated usingphp hyde build:search
.The reason it's slow, is that each Markdown page needs to be parsed into a Page model, then the Markdown body is compiled to HTML as I found that to be the easiest way to convert it to plain text (using regex).
Benchmarks
Generating a search index for the entire Hyde documentation took around 930ms and the resulting JSON is about 80KB.
Generating a search index for the entire Alice's Adventures in Wonderland book (where each chapter is a Markdown file) took around 1300ms. The JSON is around 148kB. When testing in production, only 55.2 kB is sent over the air, which is then cacheable resulting in a browser load time of about 2ms.
Try it out
Try a live demo of the frontend implementation using the entire Wonderland book:
https://demos.desilva.se/gist/github/hydephp/experiments/hydesearch/