Refactor + add more tests (Part 2) #854
Merged
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