chore: prepare docs for Docusaurus v3 upgrade - 1st iteration#3807
chore: prepare docs for Docusaurus v3 upgrade - 1st iteration#3807Simek merged 44 commits intofacebook:mainfrom
Conversation
✅ Deploy Preview for react-native ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
slorber
left a comment
There was a problem hiding this comment.
Please find my update comments, hope it helps to review the PR
|
|
||
| While you can browse the source code for React Native on [GitHub](https://github.com/facebook/react-native), we recommend you set up a fork on your local machine. | ||
|
|
||
| 1. Go to <https://github.com/facebook/react-native>. |
There was a problem hiding this comment.
MDX v2 doesn't like it so it's better to remove it.
< is not necessary here, both MDX v1 and v2 will autolink (cf playgrounds, with GFM plugin enabled for v2).
Review links:
- Before: https://reactnative.dev/contributing/how-to-open-a-pull-request#2-get-the-source-code
- After: https://deploy-preview-3807--react-native.netlify.app/contributing/how-to-open-a-pull-request#2-get-the-source-code
Both render the same:
| accessibilityTraits=“trait” | ||
| accessibilityTraits={[“trait”]} |
There was a problem hiding this comment.
Code blocks created through indentation does not work anymore in MDX v2 and cause compilation errors because of the {
Review links:
- Before: https://reactnative.dev/blog/2018/08/13/react-native-accessibility-updates#how-to-upgrade
- After: https://deploy-preview-3807--react-native.netlify.app/blog/2018/08/13/react-native-accessibility-updates#how-to-upgrade
Both render the same:
There was a problem hiding this comment.
should we add the tsx type after the ```?
There was a problem hiding this comment.
The syntax is not TS here, and the Docusaurus site has prism.defaultLanguage: 'jsx', so this does not seem required. I can add the language metastring here, but the current code is equivalent to what it used to be.
Do you want me to add tsx for futureproofness? It wouldn't do any harm.
There was a problem hiding this comment.
@cipolleschi I applied ```tsx to those blocks for expliciteness/futureproofness/consistency, as almost all of your other code blocks declare a language.
BTW @Simek unrelated but the fact that prism.defaultLanguage: 'jsx' is applied by default means that Prism is going to try to highlight with JSX all the code blocks that have no language, for example:
-keep class com.facebook.hermes.unicode.** { *; }
-keep class com.facebook.jni.** { *; }
.
├── button.js
└── img
├── check.png
├── check@2x.png
└── check@3x.png
"I am bold and red"
0-9: bold
9-17: bold, red
Maybe we need a Docusaurus option like ```undefined to unapply the default? 🤔
In practice it probably does not cause trouble but could some day.
| ### 9. Create a tracking discussion post | ||
|
|
||
| Create a "Road to <YOUR_MINOR_VERSION>" discussion post in the [`react-native-releases`](https://github.com/reactwg/react-native-releases/discussions) working group: | ||
| Create a `Road to <YOUR_MINOR_VERSION>` discussion post in the [`react-native-releases`](https://github.com/reactwg/react-native-releases/discussions) working group: |
There was a problem hiding this comment.
is this change ok? We can find another alternative like
"Road to `<YOUR_MINOR_VERSION>`"
Review links:
- Before: https://reactnative.dev/contributing/release-branch-cut-and-rc0#9-create-a-tracking-discussion-post
- After: https://deploy-preview-3807--react-native.netlify.app/contributing/release-branch-cut-and-rc0#9-create-a-tracking-discussion-post
Now renders as:
There was a problem hiding this comment.
Will using square brackets instead of lt/gt characters fix the issue? (Create a "Road to [YOUR_MINOR_VERSION]" discussion post in the...)
website/contributing/release-faq.md
Outdated
| ### How do I know if my fix/feature is in a certain release? | ||
|
|
||
| To determine whether a fix or feature is present in a given release, you will need the commit hash where the fix or feature was added to the `main` branch of the core `react-native` repo. If you know the PR, you can look for the comment from **@facebook-github-bot** that says 'closed this in <COMMIT_HASH>'. | ||
| To determine whether a fix or feature is present in a given release, you will need the commit hash where the fix or feature was added to the `main` branch of the core `react-native` repo. If you know the PR, you can look for the comment from **@facebook-github-bot** that says `closed this in <COMMIT_HASH>`. |
There was a problem hiding this comment.
is this change ok? We can find another alternative like
'closed this in `<COMMIT_HASH>`'
Review links:
- Before: https://reactnative.dev/contributing/release-faq#how-do-i-know-if-my-fixfeature-is-in-a-certain-release
- After: https://deploy-preview-3807--react-native.netlify.app/contributing/release-faq#how-do-i-know-if-my-fixfeature-is-in-a-certain-release
There was a problem hiding this comment.
yeah, I prefer this other as "closed this in" is not code.
There was a problem hiding this comment.
cipolleschi
left a comment
There was a problem hiding this comment.
Hi @slorber, thank you so much for investing the time to update our docs.
I left some comments here and there, let me know what do you think and whether they makes sense! :D
docs/javascript-environment.md
Outdated
|
|
||
| - [CommonJS require](https://nodejs.org/docs/latest/api/modules.html) | ||
| - [console.{log, warn, error, info, trace, table, group, groupEnd}](https://developer.chrome.com/devtools/docs/console-api) | ||
| - [console.{log, warn, error, info, trace, table, group, groupEnd}](https://developer.chrome.com/devtools/docs/console-api) |
There was a problem hiding this comment.
Here I'd rather use a code block. console.log is a piece of code, so it makes sense to have the code.
Also, is a little weird that we have an HTML code for the open parenthesis and the actual closed parenthesis at the end.
| | object: {top: number, left: number, bottom: number, right: number} | `{top: 0, left: 0, bottom: 0, right: 0}` | | ||
| | Type | Default | | ||
| | -------------------------------------------------------------------- | ---------------------------------------- | | ||
| | object: `{top: number, left: number, bottom: number, right: number}` | `{top: 0, left: 0, bottom: 0, right: 0}` | |
There was a problem hiding this comment.
I'd keep that separate as all the other types (like bool) are not in code blocks.
| accessibilityTraits=“trait” | ||
| accessibilityTraits={[“trait”]} |
There was a problem hiding this comment.
should we add the tsx type after the ```?
website/contributing/release-faq.md
Outdated
| ### How do I know if my fix/feature is in a certain release? | ||
|
|
||
| To determine whether a fix or feature is present in a given release, you will need the commit hash where the fix or feature was added to the `main` branch of the core `react-native` repo. If you know the PR, you can look for the comment from **@facebook-github-bot** that says 'closed this in <COMMIT_HASH>'. | ||
| To determine whether a fix or feature is present in a given release, you will need the commit hash where the fix or feature was added to the `main` branch of the core `react-native` repo. If you know the PR, you can look for the comment from **@facebook-github-bot** that says `closed this in <COMMIT_HASH>`. |
There was a problem hiding this comment.
yeah, I prefer this other as "closed this in" is not code.
| | ({nativeEvent: [PressEvent](pressevent)}) | | ||
| | Type | | ||
| | ---------------------------------------------- | | ||
| | `md ({nativeEvent: [PressEvent](pressevent)})` | |
There was a problem hiding this comment.
@cipolleschi @Simek @cortinico
This new inline code syntax
`md ({nativeEvent: [PressEvent](pressevent)})`
Turns on a basic support for Markdown links inside
Can you validate this idea?
IMHO this is an UX improvement, considering it's code it should be an inline code block. The non-usage of links before was probably a technical limitation that this new solution enables.
But this requires to teach technical writers to use the `md prefix to turn it on. Considering the current implementation, I prefer to keep it opt-in instead of applied everywhere by default.
Review links:
There was a problem hiding this comment.
I like it. I don't think that it will be an issue: if a technical writer wants to achieve the same result in these pages, it will likely go here and see how that was achieved and then it will copy the syntax!
| // Gives the ability to use basic Markdown links inside inline code blocks | ||
| // We use RegExp because a full Markdown parser would be quite heavy | ||
| // See https://github.com/facebook/react-native-website/pull/3807 | ||
| function linkify(input) { |
There was a problem hiding this comment.
@cipolleschi @Simek @cortinico
This is the code that enables the ability to use Markdown links inside inline code blocks, leading to this outcome:
This code is included in the client bundles, and I didn't want to include a heavy Markdown parser just for that use case. For that reason I choose to implement partial support (just markdown links), use regexp (less robust) and keep this feature opt-in.
| - [CommonJS require](https://nodejs.org/docs/latest/api/modules.html) | ||
| - [console.{log, warn, error, info, trace, table, group, groupEnd}](https://developer.chrome.com/devtools/docs/console-api) | ||
| - [XMLHttpRequest, fetch](network.md#content) | ||
| - [{set, clear}{Timeout, Interval, Immediate}, {request, cancel}AnimationFrame](timers.md#content) | ||
| - [CommonJS `require`](https://nodejs.org/docs/latest/api/modules.html) | ||
| - `md [console.{log, warn, error, info, trace, table, group, groupEnd}](https://developer.chrome.com/devtools/docs/console-api)` | ||
| - [`XMLHttpRequest`, `fetch`](network.md#content) | ||
| - [`{set, clear}{Timeout, Interval, Immediate}, {request, cancel}AnimationFrame`](timers.md#content) | ||
|
|
||
| #### ECMAScript 2015 (ES6) | ||
|
|
||
| - [Array.from](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) | ||
| - Array.prototype.{[find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find), [findIndex](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex)} | ||
| - [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) | ||
| - String.prototype.{[startsWith](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith), [endsWith](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith), [repeat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat), [includes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes)} | ||
| - [`Array.from`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) | ||
| - `md Array.prototype.{[find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find), [findIndex](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex)}` | ||
| - [`Object.assign`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) | ||
| - `md String.prototype.{[startsWith](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith), [endsWith](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith), [repeat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat), [includes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes)}` | ||
|
|
||
| #### ECMAScript 2016 (ES7) | ||
|
|
||
| - Array.prototype.[includes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes) | ||
| - `md Array.prototype.[includes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)` | ||
|
|
||
| #### ECMAScript 2017 (ES8) | ||
|
|
||
| - Object.{[entries](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries), [values](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values)} | ||
| - `md Object.{[entries](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries), [values](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values)}` |
There was a problem hiding this comment.
@cipolleschi , in reply to your comment
On this page, if we start using inline code blocks, then it's not always clear how to keep it consistent without modifying a bit the content:
- Should the link wrap the inline code block? (only possible in some cases)
- Should the link be inside the inline code block? (needed if there's more than 1 link, cf
Array.prototype.{xLink,yLink})
To understand better the visual consistency problem:
Before: https://reactnative.dev/docs/next/javascript-environment#polyfills
After: https://deploy-preview-3807--react-native.netlify.app/docs/next/javascript-environment#polyfills
As you can see, it does not visually render exactly the same depending on the order in which you apply the link/inline-code-block, and with current content shape, it's not really possible consistently one pattern or the other (or you would have to use code blocks for things that are not actually code: CommonJS require, XMLHttpRequest, fetch)
Is this consistency problem a blocker, or can we still merge this PR?
It can also be possible to modify the content itself to make it more consistent, because in some cases we have one link to a whole API (console), and sometimes we link to individual functions (Array methods).
In {set, clear}{Timeout, Interval, Immediate}, {request, cancel}AnimationFrame it's quite hard to know where to apply inline code blocks 😅 Note the , in the middle is not code.
slorber
left a comment
There was a problem hiding this comment.
Ready for a final review 👍
|
Thank you for the updates, let's ship it! 🚀 |




This PR is the preliminary docs changes that will be required to upgrade to Docusaurus v3.
Docusaurus v3 upgrades MDX from v1 to v2. The new MDX version is better, but the supported syntax is now slightly different (MDX breaking chance):
Why is this PR needed?:
Problematic syntax under MDX v2:
Syntax in MDX v2 is stricter than before and usually require changes related to these chars:
{: JSX opening expression<: React opening tagPossible solutions:
\{\<{or<<XYZ> {x: number, y: number}There's no single "best solution", it depends on the context and what is less confusing for RNW tech writers.
Escaping (1) can't be applied right now because with Docusaurus v2 (MDX v1) will keep rendering the escaped character:
\{will render as\{on Docusaurus v2 (bad)\{will render as{on Docusaurus v3 (good)The goal is to migrate some problematic docs to a syntax that works both for MDX v1 and v2, and only solutions (2) and (3) match these criteria.
You can test if the syntax work using those playgrounds:
Changes in this PR
I tried to apply one of the 2 possible solutions depending on the context:
I have added many PR comments to justify each kind of usage and open the discussion to see if that specific change is welcome.
TODO - API types with links
Some docs constructs are harder to handle because they can't be converted to inline code blocks as is due to the Markdown link, for example:
I will try to investigate 2 solutions to handle those, please let me know if you have a preferred one:
Inline code block prefix
Tradeoff:
filename.mdextension linking won't work and the link will remain "unprocessed" (but RNW doesn't seem to create md link through file extensions, and only uses pathnames)Set of MDX API components
The number of problematic cases is relatively small, so it could be possible to create a list of "MDX components" to support each case:
<NativeEventPressEventCallback/>If importing becomes a burden, those components can be added to the global MDX scope.
Process
Before merging this PR, please confirm that all the docs changes made in this PR are welcome and good enough to deploy in production.
Once validated, I will backport them to all the older docs versions.
We don't have to agree on 100% of the changes, in which case I'll revert the unwanted changes, and will have to handle them in the Docusaurus v3 PR (where it will be fine to use escaping
\{)cc @Simek