Skip to content

chore: prepare docs for Docusaurus v3 upgrade - 2nd iteration#3830

Merged
elicwhite merged 14 commits intofacebook:mainfrom
slorber:slorber/rnw-docs-fix
Sep 1, 2023
Merged

chore: prepare docs for Docusaurus v3 upgrade - 2nd iteration#3830
elicwhite merged 14 commits intofacebook:mainfrom
slorber:slorber/rnw-docs-fix

Conversation

@slorber
Copy link
Copy Markdown
Contributor

@slorber slorber commented Aug 25, 2023

This is a follow-up of #3807

The goal is to adjust docs so that they render exactly the same on MDX v1 and MDX v2.
This permits my visual regression tests to avoid reporting false positives due to MDX behavior changes.

This also permitted to catch a few typos and inconsistencies.

Preview: https://deploy-preview-3830--react-native.netlify.app/

@netlify
Copy link
Copy Markdown

netlify bot commented Aug 25, 2023

Deploy Preview for react-native ready!

Name Link
🔨 Latest commit 0e545b2
🔍 Latest deploy log https://app.netlify.com/sites/react-native/deploys/64e8a72dd78c200008998623
😎 Deploy Preview https://deploy-preview-3830--react-native.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Copy Markdown
Contributor Author

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready to review @Simek

3. Right click and choose **Load profile...**

<img src="/docs/assets/openChromeProfile.png" alt="Loading a performance profile on Chrome DevTools" />
<img src="/docs/assets/openChromeProfile.png" alt="Loading a performance profile on Chrome DevTools" />
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines -405 to +407
- `alert` :boolean
- `badge` :boolean
- `sound` :boolean
- `alert: boolean`
- `badge: boolean`
- `sound: boolean`
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:xyz, ::xyz and :::xyz are "Markdown Directives" and we turn them on by default in Docusaurus v3 to bring admonition support.

This means you should avoid that in your code (unless escaped) otherwise those annotations will magically disappear when upgrading.

CleanShot 2023-08-25 at 12 47 37@2x

I think it's reasonable to make the boolean part of the inline code block

Before: https://reactnative.dev/docs/pushnotificationios#checkpermissions
After: https://deploy-preview-3830--react-native.netlify.app/docs/pushnotificationios#checkpermissions

options?: {x?: number, y?: number, animated?: boolean} | number,
deprecatedX?: number,
deprecatedAnimated?: boolean,
deprecatedAnimated?: boolean,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a typo

```

Creates an object that represents android theme's default background for selectable elements (?android:attr/selectableItemBackground). `rippleRadius` parameter controls the radius of the ripple effect.
Creates an object that represents android theme's default background for selectable elements (`?android:attr/selectableItemBackground`). `rippleRadius` parameter controls the radius of the ripple effect.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another "Markdown Directive", we want to avoid them, escape them or wrap them in code blocks.

Otherwise the upgrade will lead to:

CleanShot 2023-08-25 at 12 52 23@2x

In the above example, React creates the new tree using these operations:

1. CloneNode(**Node 3**, {backgroundColor: 'yellow'}) → **Node 3'**
1. CloneNode(**Node 3**, `{backgroundColor: 'yellow'}`) → **Node 3'**
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks reasonable to wrap in code block

{ will mess up with MDX 2 and require to be escaped

Comment on lines -56 to +64
[[RCTI18nUtil sharedInstance] allowRTL:YES];
[[RCTI18nUtil sharedInstance] allowRTL:YES];
```

Android:

```java
// in MainActivity.java
I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
sharedI18nUtilInstance.allowRTL(context, true);
I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
sharedI18nUtilInstance.allowRTL(context, true);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace tabs with spaces for consistency + avoid extra spacing appearing when upgrading:

CleanShot 2023-08-25 at 13 02 33@2x

Comment on lines 68 to 102
@@ -45,7 +45,7 @@
<dict>
<key>localhost</key>
<dict>
- <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
+ <key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
<dict>
<key>localhost</key>
<dict>
- <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
+ <key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
[...]
```

All we need now is to apply this patch to your source files. While the old `react-native upgrade` process would have prompted you for any small difference, Git is able to merge most of the changes automatically using its 3-way merge algorithm and eventually leave us with familiar conflict delimiters:

```
13B07F951A680F5B00A75B9A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
13B07F951A680F5B00A75B9A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
<<<<<<< ours
CODE_SIGN_IDENTITY = "iPhone Developer";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/HockeySDK.embeddedframework",
"$(PROJECT_DIR)/HockeySDK-iOS/HockeySDK.embeddedframework",
);
CODE_SIGN_IDENTITY = "iPhone Developer";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/HockeySDK.embeddedframework",
"$(PROJECT_DIR)/HockeySDK-iOS/HockeySDK.embeddedframework",
);
=======
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 1;
>>>>>>> theirs
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../node_modules/react-native/React/**",
"$(SRCROOT)/../node_modules/react-native-code-push/ios/CodePush/**",
);
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../node_modules/react-native/React/**",
"$(SRCROOT)/../node_modules/react-native-code-push/ios/CodePush/**",
);
```
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RCT_CUSTOM_VIEW_PROPERTY(region, MKCoordinateRegion, MKMapView)
{
[view setRegion:json ? [RCTConvert MKCoordinateRegion:json] : defaultView.region animated:YES];
[view setRegion:json ? [RCTConvert MKCoordinateRegion:json] : defaultView.region animated:YES];
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace tab with space + reduce indentation for consistency

Avoid this extra spacing when upgrading:

CleanShot 2023-08-25 at 13 07 16@2x

Before: https://reactnative.dev/docs/native-components-ios#events
After: https://deploy-preview-3830--react-native.netlify.app/docs/native-components-ios#events

Comment on lines +18 to +21
<>
<img src="/blog/assets/rtl-ama-ios-arabic.png" width={280} style={{ margin: 10 }} />

<img src="/blog/assets/rtl-ama-android-hebrew.png" width={280} style={{ margin: 10 }} />
</>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a fragment here permits to avoid having an extra useless \n char when upgrading to MDX v2.

CleanShot 2023-08-25 at 14 51 24@2x

https://twitter.com/badsyntax/status/1695041116893036746

In practice it's not super impactful, but this change will ensure the 2 images look exactly the same before/after the MDX v2 upgrade.

version "1.28.0"
resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.28.0.tgz#0d8f561fa0f7cf6ebca901747828b149147044b6"
integrity sha512-8aaXdYvl1F7iC7Xm1spqSaY/OJBpYW3v+KJ+F17iYxvdc8sfjW194COK5wVhMZX45tGteiBQgdvD/nhxcRwylw==
version "1.29.0"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor update, the only impact I found in my visual tests was this change in Java code blocks:

CleanShot 2023-08-25 at 15 05 55@2x

@slorber slorber marked this pull request as ready for review August 25, 2023 13:15
@slorber slorber changed the title More docs fixes preparing for Docusaurus v3 chore: prepare docs for Docusaurus v3 upgrade - 2nd iteration Aug 25, 2023
@elicwhite elicwhite self-assigned this Sep 1, 2023
@elicwhite elicwhite self-requested a review September 1, 2023 21:44
@elicwhite
Copy link
Copy Markdown
Member

Thanks for the care you put into finding these issues and documenting the diff inline to make it easy to review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants