-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Refactor + add more tests (Part 2) #854
Merged
Merged
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
Deploy preview for docusaurus-preview ready! Built with commit 64cb4f3 |
endiliey
force-pushed
the
refactor
branch
2 times, most recently
from
July 15, 2018 17:23
b906093
to
532586c
Compare
yangshun
approved these changes
Jul 16, 2018
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.
@endiliey You deserve a medal 🏅
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
Changes
Add
babel-register
onversions.js
andwrite-translations.js
to enable transpiling ES6Fix #851
Refactor duplicate finding docs file logic in
server.js
andgenerate.js
as functiongetFile
+ add test for ithttps://github.com/facebook/Docusaurus/blob/03e237abda0600768d29be9d1cb50c6fb7ddd31b/lib/server/generate.js#L86-L102
https://github.com/facebook/Docusaurus/blob/03e237abda0600768d29be9d1cb50c6fb7ddd31b/lib/server/server.js#L172-L189
Refactor the logic to find metadata to be more declarative & efficient
Before
https://github.com/facebook/Docusaurus/blob/03e237abda0600768d29be9d1cb50c6fb7ddd31b/lib/server/server.js#L156-L161
https://github.com/facebook/Docusaurus/blob/03e237abda0600768d29be9d1cb50c6fb7ddd31b/lib/server/server.js#L165
After
Refactor duplicate getting docs component logic in
server.js
andgenerate.js
to a new filedocs.js
as functiongetComponent
https://github.com/facebook/Docusaurus/blob/03e237abda0600768d29be9d1cb50c6fb7ddd31b/lib/server/server.js#L195-L247
https://github.com/facebook/Docusaurus/blob/03e237abda0600768d29be9d1cb50c6fb7ddd31b/lib/server/generate.js#L110-L143
Changed the way we replace any links to markdown files to their website html links + ADD TEST
Note that
mdToHtml
is the mapping of a markdown to it's respective html link.mdToHtml
keys ~ number of docsBefore
It will try every possible mdToHtml key and try to replace that key with the corresponding website html links. Lot of time wasted building htmlLink from mdLink that might not exist on that file as well
Time Complexity ~ O(number of mdHtml keys)
https://github.com/facebook/Docusaurus/blob/03e237abda0600768d29be9d1cb50c6fb7ddd31b/lib/server/generate.js#L115-L131
After
It will try to find all the markdown links in a file and try to replace it with the corresponding website html links.
Time Complexity ~ O(number of unique markdown links in a file)
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Links still work as per normal
https://deploy-preview-854--docusaurus-preview.netlify.com/
Related PRs
#847