-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Devdocs: serve the content of README.md files from the search index module #38784
Conversation
… use it to serve their content
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This has a much smaller footprint than mine!
Unfortunately, none of the docs in devdocs/docs/
are currently working (The Calypso Guide, Accessibility, Color, Icons); same for Contributing (.github/CONTRIBUTING.md
-- maybe see #36167?)
(Typography, which is in devdocs/
, does work, as doe component and blocks docs -- except for the ones that we've moved into packages/components
, but that's a known and pre-existing issue.)
Oh, I misunderstood what
Files in Displaying their content now works, too -- I don't see any regressions or bugs for All issues from the review should be addressed now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jsnajdr, this is working great now!
While working on #38190 and updating the devdocs/bin/generate-devdocs-index script, I discovered that in addition to the search index, we also store the text content of the indexed files in the generated
search-index.js
module. It's used to generate snippets (that contain the searched term) for the search results. This text content is plain text with all markup stripped.If we stored the raw Markdown content to this module, too, we could use it to serve the README.md files content in the
/devdocs/service/content
endpoint. This PR implements exactly that. Currently it's served from the Calypso source tree that needs to be present at runtime.I think this is a better and more elegant solution than moving the Markdown content to the client webpack bundle that @ockham proposes in #35833. Mainly because it doesn't inflate the webpack manifest with 800+ new chunks.
It also makes the Calypso server more self-contained: soon we'll need only the
build/
andpublic/
directory to run the Calypso server, and not the whole source tree.Changes proposed in this Pull Request
/bin
directory and give it a.js
suffix. That's a better location and the.js
extension will make it Prettier-ed and ESLint-ed.package.json
, make sure that thebuild-devdocs:*
tasks are finished beforebuild-server
starts.build-server
uses the files generated bybuild-devdocs:*
. Until now, they were running in parallel and there was a race condition present.package.json
, simplify and rename thebuild-devdocs:index
task. The script doesn't need any special environment variables and can be run with a simplenode
command.generate-devdocs-index.js
script, format it with Prettier and fix ESLint errors. And also store the raw content as acontent
property of the generated document records./devdocs/service/endpoint
, usesearchIndex.documents[ idx ].content
to serve the raw content. And remove the FS access.Testing instructions
/devdocs
works correctly<ReadmeViewer>
component that's used across devdocs shows the README documents as expected.