-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
feat(v2): docs versioning ❄️🔥 #1983
Conversation
…zation, fix typing
Deploy preview for docusaurus-2 ready! Built with commit 5f88f8d |
Deploy preview for docusaurus-preview ready! Built with commit 5f88f8d |
} from './constants'; | ||
|
||
export default function(siteDir: string): Env { | ||
const versioning: VersioningEnv = { |
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.
In future, i'll add translation
to this env
. So this PR is like a building block for translated docs already
title: 'Hello, World !', | ||
description: `Hi, Endilie here :)`, | ||
}); | ||
}); | ||
|
||
test('docs with custom permalink', async () => { |
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.
Deleted because actually frontmatter permalink
feature has never been working nor is documented at v2 docs. This is remnant of munseo
when docs functionality still generate flat route config..
bd66096
to
2568db0
Compare
I think this should be eligible for first round of review. This PR is getting big already. What's left is quite isolated from current PR. I think better to do it in separate PR for ez review
|
break; | ||
default: |
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.
This is a never
, All errors checking has been done in loadSidebars
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.
I'll just leave this here - https://twitter.com/iamdevloper/status/397664295875805184
Let's ship it without the cut docs for now. To make this PR smaller and easy to look in the future |
Motivation
This is pretty much a WIP, but putting it here first since the nature of this PR is very big and its just easier to let people peek into it 😢. Up until 13/11 this is still the NodeJS part of the code though. and it is able to generate all the correct route and pages. You won't be able to check it in netlify preview yet because I haven't cut the docs lolTry it here: https://deploy-preview-1983--docusaurus-2.netlify.com/ with alpha.36 docs cutI try to make the folder structure as similar as v1 as possible for ease of migration and because directory structure is very related to CI. Changing versioned docs structure could reset Jest's translation back to 0 because crowdin don't understand if
website/versioned_docs/version-1.0.0/hello.md
is the same aswebsite/<new_versioned_docs_directory_name>/hello.md
Overview
Directory structure
docs/guides/hello.md
http://mysite.com/docs/next/hello
versioned_docs/version-1.1.0/hello.md
http://mysite.com/docs/hello
versioned_docs/version-1.0.0/hello.md
http://mysite.com/docs/1.0.0/hello
Tagging a new version
docs
. A version always should be based from master.When tagging a new version, the document versioning mechanism will:
docs/
folder contents into a newversioned_docs/version-<version>/
folder.versioned_sidebars/version-<version>-sidebars.json
.versions.json
Files
Creating new files
Master docs
Older docs
Linking files
.md
extension.Versions
Each subfolder in
versioned_docs/
will represent a documentation versionUpdating a existent version
You can update multiples docs versions at the same time. Because each
docs/
subfolder represents specifics routes when published.Example: When you change any file from
versioned_docs/version-2.6/
, it will publish changes only for2.6
docs version.Changes from v1
foo.md
inversion-1.0.0
but it doesn't exist inversion-1.2.0
. This is not possible in previous version due to Docusaurus v1 fallback functionality (https://docusaurus.io/docs/en/versioning#fallback-functionality )version-${version}-${original_id}
as the value for the actual id field. See scenario below for better explanation.Example, you have a
docs/hello.md
.When you cut a new version 1.0.0
In Docusaurus v1,
website/versioned_docs/version-1.0.0/hello.md
looks like thisIn comparison, Docusaurus 2
website/versioned_docs/version-1.0.0/hello.md
looks like this (exactly same as original)Since we're going for snapshot and allows people to move (and edit) docs easily inside version. The id frontmatter is no longer altered, it's gonna be keep as it is. But internally it is set as
version-${version}/${id}
version-${version}/${id}
(v2) instead ofversion-${version}-${original_id}
(v1).Why ? because in v1 there is a good chance someone created a new file with front matter id
"version-${version}-${id}"
that can conflict with versioned_docs idExample, docusaurus 1 can't differentiate
docs/xxx.md
and
website/versioned_docs/version-1.0.0/hello.md
Since we don't allow
/
in v1 & v2 for frontmatter, conflict is less likely.So v1 users need to migrate their versioned_sidebars file
Example:
Have you read the Contributing Guidelines on pull requests?
yes
TODO (will keep updated)
(i will do in separate PR i think)Blockers
Syntax
Test Plan
All codes added is unit tested. We still maintain 100% docs plugin test coverage so regression from this PR in functionality is less likely.
I added lot of tests to ensure everything works perfectly
TBD
Related PRs
(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)