This website was created with Docusaurus.
- Get Started in 5 Minutes
- Directory Structure
- Editing Content
- Adding Content
- Updating the Documentation Following Changes in react-native-windows
- FAQ
- Full Documentation
- Make sure all the dependencies for the website are installed:
# Install dependencies
$ yarn install- Run your dev server:
# Start the site
$ yarn startAny changes you make to the markdown files under docs will be visible in the next version of the docs, i.e. http://localhost:3000/react-native-windows/docs/next/getting-started
Your project file structure should look something like this
my-docusaurus/
docs/
doc-1.md
doc-2.md
doc-3.md
website/
core/
node_modules/
pages/
static/
css/
img/
package.json
sidebar.json
siteConfig.js
Edit docs by navigating to docs/ and editing the corresponding document:
docs/doc-to-be-edited.md
---
id: page-needs-edit
title: This Doc Needs To Be Edited
---
Edit me...For more information about docs, click here
Refer to the dedicated react-native-devblog (microsoft/react-native-devblog) repository for it - Microsoft internal only.
- Create the doc as a new markdown file in
/docs, exampledocs/newly-created-doc.md:
---
id: newly-created-doc
title: This Doc Needs To Be Edited
---
My new content here..- Refer to that doc's ID in an existing sidebar in
website/sidebars.json:
// Add newly-created-doc to the Getting Started category of docs
{
"docs": {
"Getting Started": [
"quick-start",
"newly-created-doc" // new doc here
],
...
},
...
}For more information about adding new docs, click here
Refer to the dedicated react-native-devblog (microsoft/react-native-devblog) repository for it - Microsoft internal only.
- Add links to docs, custom pages or external links by editing the headerLinks field of
website/siteConfig.js:
website/siteConfig.js
{
headerLinks: [
...
/* you can add docs */
{ doc: 'my-examples', label: 'Examples' },
/* you can add custom pages */
{ page: 'help', label: 'Help' },
/* you can add external links */
{ href: 'https://github.com/facebook/docusaurus', label: 'GitHub' },
...
],
...
}For more information about the navigation bar, click here
- Docusaurus uses React components to build pages. The components are saved as .js files in
website/pages/en: - If you want your page to show up in your navigation header, you will need to update
website/siteConfig.jsto add to theheaderLinkselement:
website/siteConfig.js
{
headerLinks: [
...
{ page: 'my-new-custom-page', label: 'My New Custom Page' },
...
],
...
}For more information about custom pages, click here.
- Submit code updates to react-native-windows
mainbranch. - Submit documentation updates to this repo's
mainbranch.
- Submit code updates to react-native-windows
0.XX-stablebranch. - Submit documentation updates to this repo's
mainbranch.- Documents should be added/updated in version-0.XX folder under /website/versioned_docs.
- Update sidebar contents in version-0.XX-sidebars.json in /website/versioned_sidebars.
Complete the documentation updates for both main and stable version 0.XX above.
-
Update necessary version references in docs.
getting-started.md- make sure to update from "nightly" to "latest" and change the previous stable version from "latest" to "0.XX-stable" in react-native init.
-
Follow the Integration into the react-native-windows-samples-repo steps to add the latest API documentation.
-
If
win10-compat.mdhas changed since the last version cut, copy contents ofdocs/win10-compat.md:- The oldest version of
win10-compat.mdin versioned_docs should be replaced with the one fromdocs. Make sure to adjust the page id to match the older version. - Confirm all other old versions of
win10-compat.mdshould be deleted.
- The oldest version of
-
Snapshot the website for version 0.XX:
cd websiteyarn run version 0.XXyarn run fix-unbroken
This will create a new directory of versioned docs,
version-0.XX, inwebsite/versioned_docs. This will preserve all documents currently in thedocsdirectory and make them available as documentation for version 0.XX. For more information on versioning, click here. -
Edit
website/.unbroken_exclusionsand add the line!versioned_docs/version-0.XX/native-api/*-api-windows*.mdunderneath the other versioned doc exclusions listed at the top of the file. -
Update
support.jsand add/update the entry for the new version of React Native Windows with the correct release and Active Support Start Date X (ex: 6/27/22). Then make sure to edit the previous version's:- Maintenance Start Date (set to the last day of the month that's 1 month out from X, ex: 7/31/22)
- End of Support Date (set to the last day of the month that's 2 months out from X, ex: 9/30/22)
-
When you are ready for your new docs to be the default documentation on the website, edit
website/siteConfig.jsto point to 0.XX for itsdefaultVersionShownconstant.
When Docusaurus creates a versioned "snapshot" folder under versioned_docs, only the docs that have been created/modified since the last "snapshot" are copied in. Asset files are not copied, and relative links are not updated. When building the website, the tool has its own fallback for building all of the correct pages and resolving the relative links.
Basically, assets are not versioned and must be kept in the repo root's docs/assets folder, and for the docs, if a doc is not present for a specific version, the tool looks back to the previous snapshots until it finds it.
For more details, see Docusaurus Fallback Functionality.
First, make sure to read How do the versioned snapshots work?.
Now, if you need to update an existing doc, look through the previous snapshots (in descending order) until you find the previously versioned doc.
If the changes you need to make are relevant to all versions >= that previous version, then simply modify that doc so all versioned snapshots >= that previous version will see the same changes when the website is rebuilt.
However, let's say that the information in that doc was correct for that previous version, but the behavior has changed for later versions. You'll need to copy that doc into the first snapshot where the change is relevant, update its id at the top of the file, and make your changes there. Again, now all versioned snapshots >= that previous version will see the same changes when the website is rebuilt.
Furthermore, if the updates are still relevant for the next unreleased version, be sure to make those changes to the docs in the root docs folder as well.
First, make sure to read How do the versioned snapshots work?.
Now, unaware of how the snapshots are used, unbroken will just see missing files. To fix that, we have a fix-unbroken.js script in the website folder. Running it will update the .unbroken_exclusions file to ignore the "broken" links that will actually be working when the website is built.
You can run the script from the website folder with yarn run fix-unbroken.
If you're still seeing "File not found" errors (not warnings) after you've updated the .unbroken_exclusions file, then you have an actual missing file to resolve.
The most common problem are with asset files. Make sure that all asset files are present in the repo root's docs/assets folder, and that you use links relative to the root docs folder, i.e.: exactly assets/image.png, not ./assets/image.png, /docs/assets/image.png, etc.
Full documentation can be found on the website.