From 00200d85605b988997ae00d68387e2604c32bca4 Mon Sep 17 00:00:00 2001 From: Ayush Jain Date: Sun, 9 Aug 2020 01:58:34 +0530 Subject: [PATCH 1/5] Add findAllComponentDefinitions resolver --- docs/activityindicator.md | 6 +- docs/button.md | 6 +- docs/flatlist.md | 54 +- docs/refreshcontrol.md | 24 +- docs/scrollview.md | 534 ++++++++++-------- docs/switch.md | 14 +- .../sync-api-docs/extractDocsFromRN.js | 10 +- .../scripts/sync-api-docs/propFormatter.js | 9 + 8 files changed, 368 insertions(+), 289 deletions(-) diff --git a/docs/activityindicator.md b/docs/activityindicator.md index 38226ee167e..8e973c53e1c 100644 --- a/docs/activityindicator.md +++ b/docs/activityindicator.md @@ -104,9 +104,9 @@ Whether to show the indicator (`true`) or hide it (`false`). The foreground color of the spinner. -| Type | Default | -| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| enum(null, string, NativeColorValue) | `null` (system accent default color)
Android

`'#999999'`
iOS
| +| Type | Default | +| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [color](colors.md) | `null` (system accent default color)
Android

`'#999999'`
iOS
| --- diff --git a/docs/button.md b/docs/button.md index 7312ae48ac9..acce0134916 100644 --- a/docs/button.md +++ b/docs/button.md @@ -145,9 +145,9 @@ Text to display for blindness accessibility features. Color of the text (iOS), or background color of the button (Android). -| Type | Default | -| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| enum(null, string, NativeColorValue) | `'#2196F3'`
Android

`'#007AFF'`
iOS
| +| Type | Default | +| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [color](colors.md) | `'#2196F3'`
Android

`'#007AFF'`
iOS
| --- diff --git a/docs/flatlist.md b/docs/flatlist.md index 1c896ba91ea..eccd2e763c8 100644 --- a/docs/flatlist.md +++ b/docs/flatlist.md @@ -439,16 +439,16 @@ scrollToEnd([params]); Scrolls to the end of the content. May be janky without `getItemLayout` prop. -**Parameters:** - -| Name | Type | Required | Description | -| ------ | ------ | -------- | ----------- | -| params | object | No | See below | - Valid `params` keys are: - 'animated' (boolean) - Whether the list should do an animation while scrolling. Defaults to `true`. +**Parameters:** + +| Name | Type | Required | +| ------ | ------ | -------- | +| params | object | No | + --- ### `scrollToIndex()` @@ -461,12 +461,6 @@ Scrolls to the item at the specified index such that it is positioned in the vie > Note: Cannot scroll to locations outside the render window without specifying the `getItemLayout` prop. -**Parameters:** - -| Name | Type | Required | Description | -| ------ | ------ | -------- | ----------- | -| params | object | Yes | See below | - Valid `params` keys are: - 'animated' (boolean) - Whether the list should do an animation while scrolling. Defaults to `true`. @@ -474,6 +468,12 @@ Valid `params` keys are: - 'viewOffset' (number) - A fixed number of pixels to offset the final target position. - 'viewPosition' (number) - A value of `0` places the item specified by index at the top, `1` at the bottom, and `0.5` centered in the middle. +**Parameters:** + +| Name | Type | Required | +| ------ | ------ | -------- | +| params | object | Yes | + --- ### `scrollToItem()` @@ -486,17 +486,17 @@ Requires linear scan through data - use `scrollToIndex` instead if possible. > Note: Cannot scroll to locations outside the render window without specifying the `getItemLayout` prop. -**Parameters:** - -| Name | Type | Required | Description | -| ------ | ------ | -------- | ----------- | -| params | object | Yes | See below | - Valid `params` keys are: - 'animated' (boolean) - Whether the list should do an animation while scrolling. Defaults to `true`. -- 'item' (ItemT) - The item to scroll to. Required. -- 'viewPosition' (number) - Missing desc +- 'item' (object) - The item to scroll to. Required. +- 'viewPosition' (number) + +**Parameters:** + +| Name | Type | Required | +| ------ | ------ | -------- | +| params | object | Yes | --- @@ -508,16 +508,16 @@ scrollToOffset(params); Scroll to a specific content pixel offset in the list. -**Parameters:** +Valid `params` keys are: -| Name | Type | Required | Description | -| ------ | ------ | -------- | ----------- | -| params | object | Yes | See below | +- 'offset' (number) - The offset to scroll to. In case of `horizontal` being true, the offset is the x-value, in any other case the offset is the y-value. Required. +- 'animated' (boolean) - Whether the list should do an animation while scrolling. Defaults to `true`. -Valid `params` keys are: +**Parameters:** -- 'animated' (boolean) - The offset to scroll to. In case of `horizontal` being true, the offset is the x-value, in any other case the offset is the y-value. Required. -- 'offset' (number) - Whether the list should do an animation while scrolling. Defaults to `true`. +| Name | Type | Required | +| ------ | ------ | -------- | +| params | object | Yes | --- diff --git a/docs/refreshcontrol.md b/docs/refreshcontrol.md index 2f0550e71ad..c95fa30cdc5 100644 --- a/docs/refreshcontrol.md +++ b/docs/refreshcontrol.md @@ -117,9 +117,9 @@ Called when the view starts refreshing. The background color of the refresh indicator. -| Type | -| ------------------------------------ | -| enum(null, string, NativeColorValue) | +| Type | +| ------------------ | +| [color](colors.md) | --- @@ -137,9 +137,9 @@ Progress view top offset Size of the refresh indicator. -| Type | Default | -| ------------------------------------------------------------------------------------ | ---------------------------------- | -| enum(typeof RefreshLayoutConsts.SIZE.DEFAULT, typeof RefreshLayoutConsts.SIZE.LARGE) | `RefreshLayoutConsts.SIZE.DEFAULT` | +| Type | Default | +| ---------------------------------------------------------------- | ---------------------------------- | +| [RefreshControl.SIZE](refreshcontrol.md#refreshlayoutconstssize) | `RefreshLayoutConsts.SIZE.DEFAULT` | --- @@ -147,9 +147,9 @@ Size of the refresh indicator. The color of the refresh indicator. -| Type | -| ------------------------------------ | -| enum(null, string, NativeColorValue) | +| Type | +| ------------------ | +| [color](colors.md) | --- @@ -167,6 +167,6 @@ The title displayed under the refresh indicator. The color of the refresh indicator title. -| Type | -| ------------------------------------ | -| enum(null, string, NativeColorValue) | +| Type | +| ------------------ | +| [color](colors.md) | diff --git a/docs/scrollview.md b/docs/scrollview.md index ad7e3cffea0..077fd7cea78 100644 --- a/docs/scrollview.md +++ b/docs/scrollview.md @@ -69,73 +69,81 @@ export default App; Inherits [View Props](view.md#props). -### `alwaysBounceHorizontal` +### `alwaysBounceHorizontal`
iOS
When true, the scroll view bounces horizontally when it reaches the end even if the content is smaller than the scroll view itself. The default value is true when `horizontal={true}` and false otherwise. -| Type | Required | Platform | -| ---- | -------- | -------- | -| bool | No | iOS | +| Type | +| ---- | +| bool | --- -### `alwaysBounceVertical` +### `alwaysBounceVertical`
iOS
When true, the scroll view bounces vertically when it reaches the end even if the content is smaller than the scroll view itself. The default value is false when `horizontal={true}` and true otherwise. -| Type | Required | Platform | -| ---- | -------- | -------- | -| bool | No | iOS | +| Type | +| ---- | +| bool | --- -### `automaticallyAdjustContentInsets` +### `automaticallyAdjustContentInsets`
iOS
-Controls whether iOS should automatically adjust the content inset for scroll views that are placed behind a navigation bar or tab bar/ toolbar. The default value is true. +Controls whether iOS should automatically adjust the content inset for scroll views that are placed behind a navigation bar or tab bar/ toolbar. -| Type | Required | Platform | -| ---- | -------- | -------- | -| bool | No | iOS | +| Type | Default | +| ---- | ------- | +| bool | `true` | --- -### `bounces` +### `bounces`
iOS
-When true, the scroll view bounces when it reaches the end of the content if the content is larger then the scroll view along the axis of the scroll direction. When false, it disables all bouncing even if the `alwaysBounce*` props are true. The default value is true. +When true, the scroll view bounces when it reaches the end of the content if the content is larger then the scroll view along the axis of the scroll direction. When false, it disables all bouncing even if the `alwaysBounce*` props are true. -| Type | Required | Platform | -| ---- | -------- | -------- | -| bool | No | iOS | +| Type | Default | +| ---- | ------- | +| bool | `true` | --- -### `bouncesZoom` +### `bouncesZoom`
iOS
When true, gestures can drive zoom past min/max and the zoom will animate to the min/max value at gesture end, otherwise the zoom will not exceed the limits. -| Type | Required | Platform | -| ---- | -------- | -------- | -| bool | No | iOS | +| Type | +| ---- | +| bool | --- -### `canCancelContentTouches` +### `canCancelContentTouches`
iOS
-When false, once tracking starts, won't try to drag if the touch moves. The default value is true. +When false, once tracking starts, won't try to drag if the touch moves. -| Type | Required | Platform | -| ---- | -------- | -------- | -| bool | No | iOS | +| Type | Default | +| ---- | ------- | +| bool | `true` | --- -### `centerContent` +### `centerContent`
iOS
-When true, the scroll view automatically centers the content when the content is smaller than the scroll view bounds; when the content is larger than the scroll view, this property has no effect. The default value is false. +When true, the scroll view automatically centers the content when the content is smaller than the scroll view bounds; when the content is larger than the scroll view, this property has no effect. -| Type | Required | Platform | -| ---- | -------- | -------- | -| bool | No | iOS | +| Type | Default | +| ---- | ------- | +| bool | `false` | + +--- + +### `children` + +| Type | +| ------------ | +| `React.Node` | --- @@ -156,39 +164,39 @@ const styles = StyleSheet.create({ }); ``` -| Type | Required | -| ------------------------------------ | -------- | -| StyleSheetPropType(View Style props) | No | +| Type | +| -------------------------------------------------------------------- | +| enum(null, void, T, false, '', \$ReadOnlyArray>) | --- -### `contentInset` +### `contentInset`
iOS
The amount by which the scroll view content is inset from the edges of the scroll view. Defaults to `{top: 0, left: 0, bottom: 0, right: 0}`. -| Type | Required | Platform | -| ------------------------------------------------------------------ | -------- | -------- | -| object: {top: number, left: number, bottom: number, right: number} | No | iOS | +| Type | +| ---------- | +| object: {} | --- -### `contentInsetAdjustmentBehavior` +### `contentInsetAdjustmentBehavior`
iOS
-This property specifies how the safe area insets are used to modify the content area of the scroll view. The default value of this property is "never". Available on iOS 11 and later. +This property specifies how the safe area insets are used to modify the content area of the scroll view. Available on iOS 11 and later. -| Type | Required | Platform | -| ------------------------------------------------------ | -------- | -------- | -| enum('automatic', 'scrollableAxes', 'never', 'always') | No | iOS | +| Type | Default | +| ------------------------------------------------------ | --------- | +| enum('automatic', 'scrollableAxes', 'never', 'always') | `'never'` | --- -### `contentOffset` +### `contentOffset`
iOS
Used to manually set the starting scroll offset. The default value is `{x: 0, y: 0}`. -| Type | Required | Platform | -| ------------- | -------- | -------- | -| PointPropType | No | iOS | +| Type | +| ---------- | +| object: {} | --- @@ -199,75 +207,75 @@ A floating-point number that determines how quickly the scroll view decelerates - `'normal'` (the default), 0.998 on iOS, 0.985 on Android. - `'fast'`, 0.99 on iOS, 0.9 on Android. -| Type | Required | -| ------------------------------- | -------- | -| enum('fast', 'normal'), ,number | No | +| Type | +| ------------------------------ | +| enum('fast', 'normal', number) | --- -### `directionalLockEnabled` +### `directionalLockEnabled`
iOS
-When true, the ScrollView will try to lock to only vertical or horizontal scrolling while dragging. The default value is false. +When true, the ScrollView will try to lock to only vertical or horizontal scrolling while dragging. -| Type | Required | Platform | -| ---- | -------- | -------- | -| bool | No | iOS | +| Type | Default | +| ---- | ------- | +| bool | `false` | --- ### `disableIntervalMomentum` -When true, the scroll view stops on the next index (in relation to scroll position at release) regardless of how fast the gesture is. This can be used for horizontal pagination when the page is less than the width of the ScrollView. The default value is false. +When true, the scroll view stops on the next index (in relation to scroll position at release) regardless of how fast the gesture is. This can be used for horizontal pagination when the page is less than the width of the ScrollView. -| Type | Required | -| ---- | -------- | -| bool | No | +| Type | Default | +| ---- | ------- | +| bool | `false` | --- ### `disableScrollViewPanResponder` -When true, the default JS pan responder on the ScrollView is disabled, and full control over touches inside the ScrollView is left to its child components. This is particularly useful if `snapToInterval` is enabled, since it does not follow typical touch patterns. Do not use this on regular ScrollView use cases without `snapToInterval` as it may cause unexpected touches to occur while scrolling. The default value is false. +When true, the default JS pan responder on the ScrollView is disabled, and full control over touches inside the ScrollView is left to its child components. This is particularly useful if `snapToInterval` is enabled, since it does not follow typical touch patterns. Do not use this on regular ScrollView use cases without `snapToInterval` as it may cause unexpected touches to occur while scrolling. -| Type | Required | -| ---- | -------- | -| bool | No | +| Type | Default | +| ---- | ------- | +| bool | `false` | --- -### `endFillColor` +### `endFillColor`
Android
Sometimes a scrollview takes up more space than its content fills. When this is the case, this prop will fill the rest of the scrollview with a color to avoid setting a background and creating unnecessary overdraw. This is an advanced optimization that is not needed in the general case. -| Type | Required | Platform | -| ------------------ | -------- | -------- | -| [color](colors.md) | No | Android | +| Type | +| ------------------------------------ | +| enum(null, string, NativeColorValue) | --- -### `fadingEdgeLength` +### `fadingEdgeLength`
Android
Fades out the edges of the the scroll content. If the value is greater than 0, the fading edges will be set accordingly to the current scroll direction and position, indicating if there is more content to show. -| Type | Required | Default | Platform | -| ------ | -------- | ------- | -------- | -| number | No | 0 | Android | +| Type | Default | +| ------ | ------- | +| number | `0` | --- ### `horizontal` -When true, the scroll view's children are arranged horizontally in a row instead of vertically in a column. The default value is false. +When true, the scroll view's children are arranged horizontally in a row instead of vertically in a column. -| Type | Required | -| ---- | -------- | -| bool | No | +| Type | Default | +| ---- | ------- | +| bool | `false` | --- -### `indicatorStyle` +### `indicatorStyle`
iOS
The style of the scroll indicators. @@ -275,9 +283,19 @@ The style of the scroll indicators. - `'black'`, scroll indicator is `black`. This style is good against a light background. - `'white'`, scroll indicator is `white`. This style is good against a dark background. -| Type | Required | Platform | -| --------------------------------- | -------- | -------- | -| enum('default', 'black', 'white') | No | iOS | +| Type | +| --------------------------------- | +| enum('default', 'black', 'white') | + +--- + +### `innerViewRef` + +A ref to the inner View element of the ScrollView. This should be used instead of calling `getInnerViewRef`. + +| Type | +| ------------------------ | +| `React.Ref` | --- @@ -285,9 +303,9 @@ The style of the scroll indicators. If sticky headers should stick at the bottom instead of the top of the ScrollView. This is usually used with inverted ScrollViews. -| Type | Required | -| ---- | -------- | -| bool | No | +| Type | +| ---- | +| bool | --- @@ -304,9 +322,9 @@ _iOS Only_ - `'interactive'`, the keyboard is dismissed interactively with the drag and moves in synchrony with the touch; dragging upwards cancels the dismissal. On android this is not supported and it will have the same behavior as 'none'. -| Type | Required | -| -------------------------------------- | -------- | -| enum('none', 'on-drag', 'interactive') | No | +| Type | +| -------------------------------------------------------- | +| enum('none' // cross-platform, 'on-drag', 'interactive') | --- @@ -320,13 +338,13 @@ Determines when the keyboard should stay visible after a tap. - `false`, **_deprecated_**, use 'never' instead - `true`, **_deprecated_**, use 'always' instead -| Type | Required | -| ----------------------------------------------- | -------- | -| enum('always', 'never', 'handled', false, true) | No | +| Type | Default | +| ----------------------------------------------- | --------- | +| enum('always', 'never', 'handled', true, false) | `"never"` | --- -### `maintainVisibleContentPosition` +### `maintainVisibleContentPosition`
iOS
When set, the scroll view will adjust the scroll position so that the first child that is currently visible and at or beyond `minIndexForVisible` will not change position. This is useful for lists that are loading content in both directions, e.g. a chat thread, where new messages coming in might otherwise cause the scroll position to jump. A value of 0 is common, but other values such as 1 can be used to skip loading spinners or other content that should not maintain position. @@ -336,39 +354,41 @@ Caveat 1: Reordering elements in the scrollview with this enabled will probably Caveat 2: This uses `contentOffset` and `frame.origin` in native code to compute visibility. Occlusion, transforms, and other complexity won't be taken into account as to whether content is "visible" or not. -| Type | Required | Platform | -| ------------------------------------------------------------------------ | -------- | -------- | -| object: { minIndexForVisible: number, autoscrollToTopThreshold: number } | No | iOS | +| Type | +| ---------- | +| object: {} | --- -### `maximumZoomScale` +### `maximumZoomScale`
iOS
-The maximum allowed zoom scale. The default value is 1.0. +The maximum allowed zoom scale. -| Type | Required | Platform | -| ------ | -------- | -------- | -| number | No | iOS | +| Type | Default | +| ------ | ------- | +| number | `1.0` | --- -### `minimumZoomScale` +### `minimumZoomScale`
iOS
-The minimum allowed zoom scale. The default value is 1.0. +The minimum allowed zoom scale. -| Type | Required | Platform | -| ------ | -------- | -------- | -| number | No | iOS | +| Type | Default | +| ------ | ------- | +| number | `1.0` | --- -### `nestedScrollEnabled` +### `nestedScrollEnabled`
Android
Enables nested scrolling for Android API level 21+. Nested scrolling is supported by default on iOS. -| Type | Required | Platform | -| ---- | -------- | -------- | -| bool | No | Android | +| Type | +| ---- | +| bool | + +--- ### `onContentSizeChange` @@ -378,9 +398,17 @@ Handler function is passed the content width and content height as parameters: ` It's implemented using onLayout handler attached to the content container which this ScrollView renders. -| Type | Required | -| -------- | -------- | -| function | No | +| Type | +| -------- | +| function | + +--- + +### `onKeyboardDidShow` + +| Type | +| ------------------------------------- | +| function([PressEvent](pressevent.md)) | --- @@ -388,9 +416,9 @@ It's implemented using onLayout handler attached to the content container which Called when the momentum scroll starts (scroll which occurs as the ScrollView starts gliding). -| Type | Required | -| -------- | -------- | -| function | No | +| Type | +| -------- | +| function | --- @@ -398,9 +426,9 @@ Called when the momentum scroll starts (scroll which occurs as the ScrollView st Called when the momentum scroll ends (scroll which occurs as the ScrollView glides to a stop). -| Type | Required | -| -------- | -------- | -| function | No | +| Type | +| -------- | +| function | --- @@ -420,9 +448,9 @@ Fires at most once per frame during scrolling. The frequency of the events can b } ``` -| Type | Required | -| -------- | -------- | -| function | No | +| Type | +| -------- | +| function | --- @@ -430,9 +458,9 @@ Fires at most once per frame during scrolling. The frequency of the events can b Called when the user begins to drag the scroll view. -| Type | Required | -| -------- | -------- | -| function | No | +| Type | +| -------- | +| function | --- @@ -440,23 +468,23 @@ Called when the user begins to drag the scroll view. Called when the user stops dragging the scroll view and it either stops or begins to glide. -| Type | Required | -| -------- | -------- | -| function | No | +| Type | +| -------- | +| function | --- -### `onScrollToTop` +### `onScrollToTop`
iOS
Fires when the scroll view scrolls to top after the status bar has been tapped. -| Type | Required | Platform | -| -------- | -------- | -------- | -| function | No | iOS | +| Type | +| -------- | +| function | --- -### `overScrollMode` +### `overScrollMode`
Android
Used to override default value of overScroll mode. @@ -466,41 +494,41 @@ Possible values: - `'always'` - Always allow a user to over-scroll this view. - `'never'` - Never allow a user to over-scroll this view. -| Type | Required | Platform | -| ------------------------------- | -------- | -------- | -| enum('auto', 'always', 'never') | No | Android | +| Type | +| ------------------------------- | +| enum('auto', 'always', 'never') | --- ### `pagingEnabled` -When true, the scroll view stops on multiples of the scroll view's size when scrolling. This can be used for horizontal pagination. The default value is false. +When true, the scroll view stops on multiples of the scroll view's size when scrolling. This can be used for horizontal pagination. Note: Vertical pagination is not supported on Android. -| Type | Required | -| ---- | -------- | -| bool | No | +| Type | Default | +| ---- | ------- | +| bool | `false` | --- -### `persistentScrollbar` +### `persistentScrollbar`
Android
-Causes the scrollbars not to turn transparent when they are not in use. The default value is false. +Causes the scrollbars not to turn transparent when they are not in use. -| Type | Required | Platform | -| ---- | -------- | -------- | -| bool | No | Android | +| Type | Default | +| ---- | ------- | +| bool | `false` | --- -### `pinchGestureEnabled` +### `pinchGestureEnabled`
iOS
-When true, ScrollView allows use of pinch gestures to zoom in and out. The default value is true. +When true, ScrollView allows use of pinch gestures to zoom in and out. -| Type | Required | Platform | -| ---- | -------- | -------- | -| bool | No | iOS | +| Type | Default | +| ---- | ------- | +| bool | `true` | --- @@ -510,9 +538,9 @@ A RefreshControl component, used to provide pull-to-refresh functionality for th See [RefreshControl](refreshcontrol.md). -| Type | Required | -| ------- | -------- | -| element | No | +| Type | +| -------------------- | +| `React.Element` | --- @@ -520,9 +548,9 @@ See [RefreshControl](refreshcontrol.md). Experimental: When true, offscreen child views (whose `overflow` value is `hidden`) are removed from their native backing superview when offscreen. This can improve scrolling performance on long lists. -| Type | Required | -| ---- | -------- | -| bool | No | +| Type | +| ---- | +| bool | --- @@ -530,128 +558,128 @@ Experimental: When true, offscreen child views (whose `overflow` value is `hidde Optionally an image can be used for the scroll bar thumb. This will override the color. While the image is loading or the image fails to load the color will be used instead. Use an alpha of 0 in the color to avoid seeing it while the image is loading. -- `uri`, a string representing the resource identifier for the image, which should be either a local file path or the name of a static image resource. -- `number`, opaque type returned by something like `import IMAGE from './image.jpg'`. +- `uri` - a string representing the resource identifier for the image, which should be either a local file path or the name of a static image resource +- `number` - Opaque type returned by something like `import IMAGE from './image.jpg'`. -| Type | Required | Platform | -| ------ | -------- | -------- | -| number | No | VR | +| Type | +| ------------------------------ | +| enum(\$ReadOnly<{, }>, number) | --- ### `scrollEnabled` -When false, the view cannot be scrolled via touch interaction. The default value is true. +When false, the view cannot be scrolled via touch interaction. Note that the view can always be scrolled by calling `scrollTo`. -| Type | Required | -| ---- | -------- | -| bool | No | +| Type | Default | +| ---- | ------- | +| bool | `true` | --- -### `scrollEventThrottle` +### `scrollEventThrottle`
iOS
This controls how often the scroll event will be fired while scrolling (as a time interval in ms). A lower number yields better accuracy for code that is tracking the scroll position, but can lead to scroll performance problems due to the volume of information being sent over the bridge. You will not notice a difference between values set between 1-16 as the JS run loop is synced to the screen refresh rate. If you do not need precise scroll position tracking, set this value higher to limit the information being sent across the bridge. The default value is zero, which results in the scroll event being sent only once each time the view is scrolled. -| Type | Required | Platform | -| ------ | -------- | -------- | -| number | No | iOS | +| Type | +| ------ | +| number | --- -### `scrollIndicatorInsets` +### `scrollIndicatorInsets`
iOS
The amount by which the scroll view indicators are inset from the edges of the scroll view. This should normally be set to the same value as the `contentInset`. Defaults to `{0, 0, 0, 0}`. -| Type | Required | Platform | -| ------------------------------------------------------------------ | -------- | -------- | -| object: {top: number, left: number, bottom: number, right: number} | No | iOS | +| Type | +| ---------- | +| object: {} | --- -### `scrollPerfTag` +### `scrollPerfTag`
Android
Tag used to log scroll performance on this scroll view. Will force momentum events to be turned on (see sendMomentumEvents). This doesn't do anything out of the box and you need to implement a custom native FpsListener for it to be useful. -| Type | Required | Platform | -| ------ | -------- | -------- | -| string | No | Android | +| Type | +| ------ | +| string | --- -### `scrollToOverflowEnabled` +### `scrollsToTop`
iOS
-When true, the scroll view can be programmatically scrolled beyond its content size. The default value is false. +When true, the scroll view scrolls to top when the status bar is tapped. -| Type | Required | Platform | -| ---- | -------- | -------- | -| bool | No | iOS | +| Type | Default | +| ---- | ------- | +| bool | `true` | --- -### `scrollsToTop` +### `scrollToOverflowEnabled`
iOS
-When true, the scroll view scrolls to top when the status bar is tapped. The default value is true. +When true, the scroll view can be programmatically scrolled beyond its content size. -| Type | Required | Platform | -| ---- | -------- | -------- | -| bool | No | iOS | +| Type | Default | +| ---- | ------- | +| bool | `false` | --- -### `DEPRECATED_sendUpdatedChildFrames` +### `scrollViewRef` -When true, ScrollView will emit updateChildFrames data in scroll events, otherwise will not compute or emit child frame data. This only exists to support legacy issues, `onLayout` should be used instead to retrieve frame data. The default value is false. +A ref to the Native ScrollView component. This ref can be used to call all of ScrollView's public methods, in addition to native methods like measure, measureLayout, etc. -| Type | Required | Platform | -| ---- | -------- | -------- | -| bool | No | iOS | +| Type | +| ------------------------------------------------------------------------------ | +| `React.Ref< typeof ScrollViewNativeComponent & ScrollViewImperativeMethods, >` | --- ### `showsHorizontalScrollIndicator` -When true, shows a horizontal scroll indicator. The default value is true. +When true, shows a horizontal scroll indicator. -| Type | Required | -| ---- | -------- | -| bool | No | +| Type | Default | +| ---- | ------- | +| bool | `true` | --- ### `showsVerticalScrollIndicator` -When true, shows a vertical scroll indicator. The default value is true. +When true, shows a vertical scroll indicator. -| Type | Required | -| ---- | -------- | -| bool | No | +| Type | Default | +| ---- | ------- | +| bool | `true` | --- -### `snapToAlignment` +### `snapToAlignment`
iOS
When `snapToInterval` is set, `snapToAlignment` will define the relationship of the snapping to the scroll view. -- `'start'` (the default) will align the snap at the left (horizontal) or top (vertical). -- `'center'` will align the snap in the center. -- `'end'` will align the snap at the right (horizontal) or bottom (vertical). +- `'start'` (the default) will align the snap at the left (horizontal) or top (vertical) +- `'center'` will align the snap in the center +- `'end'` will align the snap at the right (horizontal) or bottom (vertical) -| Type | Required | Platform | -| ------------------------------ | -------- | -------- | -| enum('start', 'center', 'end') | No | iOS | +| Type | +| ------------------------------ | +| enum('start', 'center', 'end') | --- ### `snapToEnd` -Use in conjunction with `snapToOffsets`. By default, the end of the list counts as a snap offset. Set `snapToEnd` to false to disable this behavior and allow the list to scroll freely between its end and the last `snapToOffsets` offset. The default value is true. +Use in conjunction with `snapToOffsets`. By default, the end of the list counts as a snap offset. Set `snapToEnd` to false to disable this behavior and allow the list to scroll freely between its end and the last `snapToOffsets` offset. -| Type | Required | -| ------- | -------- | -| boolean | No | +| Type | Default | +| ---- | ------- | +| bool | `true` | --- @@ -659,9 +687,9 @@ Use in conjunction with `snapToOffsets`. By default, the end of the list counts When set, causes the scroll view to stop at multiples of the value of `snapToInterval`. This can be used for paginating through children that have lengths smaller than the scroll view. Typically used in combination with `snapToAlignment` and `decelerationRate="fast"`. Overrides less configurable `pagingEnabled` prop. -| Type | Required | -| ------ | -------- | -| number | No | +| Type | +| ------ | +| number | --- @@ -669,19 +697,29 @@ When set, causes the scroll view to stop at multiples of the value of `snapToInt When set, causes the scroll view to stop at the defined offsets. This can be used for paginating through variously sized children that have lengths smaller than the scroll view. Typically used in combination with `decelerationRate="fast"`. Overrides less configurable `pagingEnabled` and `snapToInterval` props. -| Type | Required | -| --------------- | -------- | -| array of number | No | +| Type | +| ------------------------ | +| `$ReadOnlyArray` | --- ### `snapToStart` -Use in conjunction with `snapToOffsets`. By default, the beginning of the list counts as a snap offset. Set `snapToStart` to false to disable this behavior and allow the list to scroll freely between its start and the first `snapToOffsets` offset. The default value is true. +Use in conjunction with `snapToOffsets`. By default, the beginning of the list counts as a snap offset. Set `snapToStart` to false to disable this behavior and allow the list to scroll freely between its start and the first `snapToOffsets` offset. -| Type | Required | -| ------- | -------- | -| boolean | No | +| Type | Default | +| ---- | ------- | +| bool | `true` | + +--- + +### `StickyHeaderComponent` + +A React Component that will be used to render sticky headers. To be used together with `stickyHeaderIndices` or with `SectionList`, defaults to `ScrollViewStickyHeader`. You may need to set this if your sticky header uses custom transforms (eg. translation), for example when you want your list to have an animated hidable header. + +| Type | +| ----------------------------------------------------------------------------------------------------------- | +| `React.AbstractComponent< ScrollViewStickyHeaderProps, $ReadOnly<{setNextHeaderY: number => void, ...}>, >` | --- @@ -689,19 +727,19 @@ Use in conjunction with `snapToOffsets`. By default, the beginning of the list c An array of child indices determining which children get docked to the top of the screen when scrolling. For example, passing `stickyHeaderIndices={[0]}` will cause the first child to be fixed to the top of the scroll view. This property is not supported in conjunction with `horizontal={true}`. -| Type | Required | -| --------------- | -------- | -| array of number | No | +| Type | +| ------------------------ | +| `$ReadOnlyArray` | --- -### `zoomScale` +### `zoomScale`
iOS
-The current scale of the scroll view content. The default value is 1.0. +The current scale of the scroll view content. -| Type | Required | Platform | -| ------ | -------- | -------- | -| number | No | iOS | +| Type | Default | +| ------ | ------- | +| number | `1.0` | ## Methods @@ -715,13 +753,35 @@ Displays the scroll indicators momentarily. --- +### `getInnerViewNode()` + +--- + +### `getInnerViewRef()` + +--- + +### `getNativeScrollRef()` + +--- + +### `getScrollableNode()` + +--- + +### `getScrollResponder()` + +Returns a reference to the underlying scroll responder, which supports operations like `scrollTo`. All ScrollView-like components should implement this method so that they can be composed while providing access to the underlying scroll responder's methods. + +--- + ### `scrollTo()` ```jsx scrollTo( options?: {x?: number, y?: number, animated?: boolean} | number, deprecatedX?: number, - deprecatedAnimated?: boolean, + deprecatedAnimated?: boolean, ); ``` @@ -733,6 +793,14 @@ Example: Note: The weird function signature is due to the fact that, for historical reasons, the function also accepts separate arguments as an alternative to the options object. This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED. +**Parameters:** + +| Name | Type | Required | +| ------------------ | ---- | -------- | +| options | | No | +| deprecatedX | | No | +| deprecatedAnimated | | No | + --- ### `scrollToEnd()` @@ -745,12 +813,8 @@ If this is a vertical ScrollView scrolls to the bottom. If this is a horizontal Use `scrollToEnd({animated: true})` for smooth animated scrolling, `scrollToEnd({animated: false})` for immediate scrolling. For Android, you may specify a duration, e.g. `scrollToEnd({duration: 500})` for a controlled duration scroll. If no options are passed, `animated` defaults to true. ---- - -### `scrollWithoutAnimationTo()` - -```jsx -scrollWithoutAnimationTo(y, x); -``` +**Parameters:** -Deprecated, use `scrollTo` instead. +| Name | Type | Required | +| ------- | ------ | -------- | +| options | object | No | diff --git a/docs/switch.md b/docs/switch.md index 4f812e4ab30..a9186fc7cfe 100644 --- a/docs/switch.md +++ b/docs/switch.md @@ -63,9 +63,9 @@ If true the user won't be able to toggle the switch. On iOS, custom color for the background. This background color can be seen either when the switch value is false or when the switch is disabled (and the switch is translucent). -| Type | -| ------------------------------------ | -| enum(null, string, NativeColorValue) | +| Type | +| ------------------ | +| [color](colors.md) | --- @@ -93,9 +93,9 @@ Invoked when the user tries to change the value of the switch. Receives the new Color of the foreground switch grip. If this is set on iOS, the switch grip will lose its drop shadow. -| Type | -| ------------------------------------ | -| enum(null, string, NativeColorValue) | +| Type | +| ------------------ | +| [color](colors.md) | --- @@ -103,7 +103,7 @@ Color of the foreground switch grip. If this is set on iOS, the switch grip will Custom colors for the switch track. -_iOS_: When the switch value is false, the track shrinks into the border. If you want to change the color of the background exposed by the shrunken track, use [`ios_backgroundColor`](switch#ios_backgroundColor). +_iOS_: When the switch value is false, the track shrinks into the border. If you want to change the color of the background exposed by the shrunken track, use [`ios_backgroundColor`](https://reactnative.dev/docs/switch#ios_backgroundColor). | Type | | ------------------------------------------------------------- | diff --git a/website/scripts/sync-api-docs/extractDocsFromRN.js b/website/scripts/sync-api-docs/extractDocsFromRN.js index f55543ba44e..c87806aa8a4 100644 --- a/website/scripts/sync-api-docs/extractDocsFromRN.js +++ b/website/scripts/sync-api-docs/extractDocsFromRN.js @@ -41,16 +41,22 @@ async function extractDocsFromRN(rnRoot) { const result = reactDocs.parse( contents, - reactDocs.resolver.findExportedComponentDefinition, + reactDocs.resolver.findAllComponentDefinitions, reactDocs.defaultHandlers.filter( handler => handler !== reactDocs.handlers.propTypeCompositionHandler ), {filename: file} ); + const filteredResult = result.filter(item => { + if (item.description) return item; + }); + + // console.log(filteredResult) + docs.push({ file, - component: cleanComponentResult(result), + component: cleanComponentResult(...filteredResult), }); } diff --git a/website/scripts/sync-api-docs/propFormatter.js b/website/scripts/sync-api-docs/propFormatter.js index e417f8a13e1..3664b85fd98 100644 --- a/website/scripts/sync-api-docs/propFormatter.js +++ b/website/scripts/sync-api-docs/propFormatter.js @@ -181,6 +181,15 @@ function formatTypeColumn(prop) { if (item) return item; }); + // Get text and url from magic aliases + prop?.flowType?.elements?.forEach(elem => { + if (Object.hasOwnProperty.call(magic.linkableTypeAliases, elem.name)) { + ({url, text} = magic.linkableTypeAliases[elem.name]); + } + }); + + if (url) return `[${text}](${url})`; + return `enum(${unionTypes.join(', ')})`; } else { // Get text and url from magic aliases From d0c0f2e5c2096b5015821db219b2547a8b812734 Mon Sep 17 00:00:00 2001 From: Ayush Jain Date: Sun, 9 Aug 2020 03:33:49 +0530 Subject: [PATCH 2/5] Handle case with empty description in method FlowType --- docs/flatlist.md | 52 +++++++++---------- .../scripts/sync-api-docs/generateMarkdown.js | 8 +-- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/docs/flatlist.md b/docs/flatlist.md index eccd2e763c8..fc631d154d5 100644 --- a/docs/flatlist.md +++ b/docs/flatlist.md @@ -439,15 +439,15 @@ scrollToEnd([params]); Scrolls to the end of the content. May be janky without `getItemLayout` prop. -Valid `params` keys are: +**Parameters:** -- 'animated' (boolean) - Whether the list should do an animation while scrolling. Defaults to `true`. +| Name | Type | Required | Description | +| ------ | ------ | -------- | ----------- | +| params | object | No | See below | -**Parameters:** +Valid `params` keys are: -| Name | Type | Required | -| ------ | ------ | -------- | -| params | object | No | +- 'animated' (boolean) - Whether the list should do an animation while scrolling. Defaults to `true`. --- @@ -461,6 +461,12 @@ Scrolls to the item at the specified index such that it is positioned in the vie > Note: Cannot scroll to locations outside the render window without specifying the `getItemLayout` prop. +**Parameters:** + +| Name | Type | Required | Description | +| ------ | ------ | -------- | ----------- | +| params | object | Yes | See below | + Valid `params` keys are: - 'animated' (boolean) - Whether the list should do an animation while scrolling. Defaults to `true`. @@ -468,12 +474,6 @@ Valid `params` keys are: - 'viewOffset' (number) - A fixed number of pixels to offset the final target position. - 'viewPosition' (number) - A value of `0` places the item specified by index at the top, `1` at the bottom, and `0.5` centered in the middle. -**Parameters:** - -| Name | Type | Required | -| ------ | ------ | -------- | -| params | object | Yes | - --- ### `scrollToItem()` @@ -486,18 +486,18 @@ Requires linear scan through data - use `scrollToIndex` instead if possible. > Note: Cannot scroll to locations outside the render window without specifying the `getItemLayout` prop. +**Parameters:** + +| Name | Type | Required | Description | +| ------ | ------ | -------- | ----------- | +| params | object | Yes | See below | + Valid `params` keys are: - 'animated' (boolean) - Whether the list should do an animation while scrolling. Defaults to `true`. -- 'item' (object) - The item to scroll to. Required. +- 'item' (ItemT) - The item to scroll to. Required. - 'viewPosition' (number) -**Parameters:** - -| Name | Type | Required | -| ------ | ------ | -------- | -| params | object | Yes | - --- ### `scrollToOffset()` @@ -508,16 +508,16 @@ scrollToOffset(params); Scroll to a specific content pixel offset in the list. -Valid `params` keys are: +**Parameters:** -- 'offset' (number) - The offset to scroll to. In case of `horizontal` being true, the offset is the x-value, in any other case the offset is the y-value. Required. -- 'animated' (boolean) - Whether the list should do an animation while scrolling. Defaults to `true`. +| Name | Type | Required | Description | +| ------ | ------ | -------- | ----------- | +| params | object | Yes | See below | -**Parameters:** +Valid `params` keys are: -| Name | Type | Required | -| ------ | ------ | -------- | -| params | object | Yes | +- 'animated' (boolean) - The offset to scroll to. In case of `horizontal` being true, the offset is the x-value, in any other case the offset is the y-value. Required. +- 'offset' (number) - Whether the list should do an animation while scrolling. Defaults to `true`. --- diff --git a/website/scripts/sync-api-docs/generateMarkdown.js b/website/scripts/sync-api-docs/generateMarkdown.js index b158df1efa3..0a597efef22 100644 --- a/website/scripts/sync-api-docs/generateMarkdown.js +++ b/website/scripts/sync-api-docs/generateMarkdown.js @@ -92,9 +92,11 @@ function generateMethod(method, component) { } obj.map(item => { - mdPoints += `- '${item.key}' (${item.value.name}) - ${ - item.description - }`; + if (item.description.trim() !== 'missing') + mdPoints += `- '${item.key}' (${item.value.name}) - ${ + item.description + }`; + else mdPoints += `- '${item.key}' (${item.value.name})`; }); method.params[0]['description'] = 'See below'; From 516b8e024451a2c08a8db600b30bda59a34806b7 Mon Sep 17 00:00:00 2001 From: Ayush Jain Date: Mon, 10 Aug 2020 16:25:19 +0530 Subject: [PATCH 3/5] Fix description parsing with snackplayer --- .../scripts/sync-api-docs/generateMarkdown.js | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/website/scripts/sync-api-docs/generateMarkdown.js b/website/scripts/sync-api-docs/generateMarkdown.js index 0a597efef22..6fdd7c4d18e 100644 --- a/website/scripts/sync-api-docs/generateMarkdown.js +++ b/website/scripts/sync-api-docs/generateMarkdown.js @@ -261,17 +261,24 @@ function preprocessDescription(desc) { }); if (tabs === 2) { - const wrapper = `${playgroundTab}\n\n${functionalBlock}\n\n${ - descriptionTokenized.examples[0].raw - }\n\n${classBlock}\n\n${ - descriptionTokenized.examples[1].raw - }\n\n${endBlock}`; + const firstExample = desc.substr(desc.search('```SnackPlayer') + 1); + const secondExample = firstExample.substr( + firstExample.search('```SnackPlayer') + 1 + ); + return ( - descriptionTokenized.description + + desc.substr(0, desc.search('```SnackPlayer')) + `\n## Example\n` + - wrapper + - '\n' + - descriptionTokenized?.footer + `${playgroundTab}\n\n${functionalBlock}\n\n${'`' + + firstExample.substr( + 0, + firstExample.search('```') + 3 + )}\n\n${classBlock}\n\n${'`' + + secondExample.substr( + 0, + secondExample.search('```') + 3 + )}\n\n${endBlock}` + + secondExample.substr(secondExample.search('```') + 3) ); } else { return ( From 8b7f41be757542d8a7ac1e408bf8aa2875ec06e0 Mon Sep 17 00:00:00 2001 From: Ayush Jain Date: Tue, 11 Aug 2020 01:21:12 +0530 Subject: [PATCH 4/5] Add more prop types --- docs/flatlist.md | 18 ++--- docs/scrollview.md | 68 +++++++++---------- .../scripts/sync-api-docs/propFormatter.js | 13 ++++ 3 files changed, 56 insertions(+), 43 deletions(-) diff --git a/docs/flatlist.md b/docs/flatlist.md index fc631d154d5..db35d24d34f 100644 --- a/docs/flatlist.md +++ b/docs/flatlist.md @@ -202,9 +202,9 @@ Inherits [ScrollView Props](scrollview.md#props), unless it is nested in another For simplicity, data is a plain array. If you want to use something else, like an immutable list, use the underlying [`VirtualizedList`](virtualizedlist.md) directly. -| Type | -| ----------------------- | -| `$ReadOnlyArray` | +| Type | +| ----- | +| array | --- @@ -236,9 +236,9 @@ Used to extract a unique key for a given item at the specified index. Key is use Optional custom style for multi-item rows generated when `numColumns > 1`. -| Type | -| -------------------------------------------------------------------- | -| enum(null, void, T, false, '', \$ReadOnlyArray>) | +| Type | +| ------------ | +| style object | --- @@ -246,9 +246,9 @@ Optional custom style for multi-item rows generated when `numColumns > 1`. A marker property for telling the list to re-render (since it implements `PureComponent`). If any of your `renderItem`, Header, Footer, etc. functions depend on anything outside of the `data` prop, stick it here and treat it immutably. -| Type | -| ---- | -| any | +| Type | +| -------- | +| function | --- diff --git a/docs/scrollview.md b/docs/scrollview.md index 077fd7cea78..1d9578509ee 100644 --- a/docs/scrollview.md +++ b/docs/scrollview.md @@ -164,19 +164,19 @@ const styles = StyleSheet.create({ }); ``` -| Type | -| -------------------------------------------------------------------- | -| enum(null, void, T, false, '', \$ReadOnlyArray>) | +| Type | +| ------------------------------------ | +| StyleSheetPropType(View Style props) | --- ### `contentInset`
iOS
-The amount by which the scroll view content is inset from the edges of the scroll view. Defaults to `{top: 0, left: 0, bottom: 0, right: 0}`. +The amount by which the scroll view content is inset from the edges of the scroll view. -| Type | -| ---------- | -| object: {} | +| Type | Default | +| ------------------------------------------------------------------ | ---------------------------------------- | +| object: {bottom: number, left: number, right: number, top: number} | `{top: 0, left: 0, bottom: 0, right: 0}` | --- @@ -192,11 +192,11 @@ This property specifies how the safe area insets are used to modify the content ### `contentOffset`
iOS
-Used to manually set the starting scroll offset. The default value is `{x: 0, y: 0}`. +Used to manually set the starting scroll offset. -| Type | -| ---------- | -| object: {} | +| Type | Default | +| ------------- | -------------- | +| PointPropType | `{x: 0, y: 0}` | --- @@ -247,9 +247,9 @@ When true, the default JS pan responder on the ScrollView is disabled, and full Sometimes a scrollview takes up more space than its content fills. When this is the case, this prop will fill the rest of the scrollview with a color to avoid setting a background and creating unnecessary overdraw. This is an advanced optimization that is not needed in the general case. -| Type | -| ------------------------------------ | -| enum(null, string, NativeColorValue) | +| Type | +| ------------------ | +| [color](colors.md) | --- @@ -354,9 +354,9 @@ Caveat 1: Reordering elements in the scrollview with this enabled will probably Caveat 2: This uses `contentOffset` and `frame.origin` in native code to compute visibility. Occlusion, transforms, and other complexity won't be taken into account as to whether content is "visible" or not. -| Type | -| ---------- | -| object: {} | +| Type | +| ---------------------------------------------------------------------- | +| object: {minIndexForVisible: number, autoscrollToTopThreshold: number} | --- @@ -538,9 +538,9 @@ A RefreshControl component, used to provide pull-to-refresh functionality for th See [RefreshControl](refreshcontrol.md). -| Type | -| -------------------- | -| `React.Element` | +| Type | +| ------- | +| element | --- @@ -554,16 +554,16 @@ Experimental: When true, offscreen child views (whose `overflow` value is `hidde --- -### `scrollBarThumbImage` +### `scrollBarThumbImage`
VR
Optionally an image can be used for the scroll bar thumb. This will override the color. While the image is loading or the image fails to load the color will be used instead. Use an alpha of 0 in the color to avoid seeing it while the image is loading. - `uri` - a string representing the resource identifier for the image, which should be either a local file path or the name of a static image resource - `number` - Opaque type returned by something like `import IMAGE from './image.jpg'`. -| Type | -| ------------------------------ | -| enum(\$ReadOnly<{, }>, number) | +| Type | +| ------ | +| number | --- @@ -591,11 +591,11 @@ This controls how often the scroll event will be fired while scrolling (as a tim ### `scrollIndicatorInsets`
iOS
-The amount by which the scroll view indicators are inset from the edges of the scroll view. This should normally be set to the same value as the `contentInset`. Defaults to `{0, 0, 0, 0}`. +The amount by which the scroll view indicators are inset from the edges of the scroll view. This should normally be set to the same value as the `contentInset`. -| Type | -| ---------- | -| object: {} | +| Type | Default | +| ------------------------------------------------------------------ | -------------- | +| object: {bottom: number, left: number, right: number, top: number} | `{0, 0, 0, 0}` | --- @@ -697,9 +697,9 @@ When set, causes the scroll view to stop at multiples of the value of `snapToInt When set, causes the scroll view to stop at the defined offsets. This can be used for paginating through variously sized children that have lengths smaller than the scroll view. Typically used in combination with `decelerationRate="fast"`. Overrides less configurable `pagingEnabled` and `snapToInterval` props. -| Type | -| ------------------------ | -| `$ReadOnlyArray` | +| Type | +| --------------- | +| array of number | --- @@ -727,9 +727,9 @@ A React Component that will be used to render sticky headers. To be used togethe An array of child indices determining which children get docked to the top of the screen when scrolling. For example, passing `stickyHeaderIndices={[0]}` will cause the first child to be fixed to the top of the scroll view. This property is not supported in conjunction with `horizontal={true}`. -| Type | -| ------------------------ | -| `$ReadOnlyArray` | +| Type | +| --------------- | +| array of number | --- diff --git a/website/scripts/sync-api-docs/propFormatter.js b/website/scripts/sync-api-docs/propFormatter.js index 3664b85fd98..ea741fad9ed 100644 --- a/website/scripts/sync-api-docs/propFormatter.js +++ b/website/scripts/sync-api-docs/propFormatter.js @@ -24,6 +24,10 @@ function formatMultiplePlatform(platforms) { break; case 'tv': platformString += '
' + 'TV' + '
'; + break; + //TODO: Add a new CSS class for VR + case 'vr': + platformString += '
' + 'VR' + '
'; } }); return platformString; @@ -149,6 +153,12 @@ function formatTypeColumn(prop) { [] ); return `array of enum(${unionTypes.join(', ')})`; + } else if (prop?.flowType?.elements[0]?.name) { + //array of number + if (prop?.flowType?.elements[0]?.name === 'number') + return `array of ${prop.flowType.elements[0].name}`; + //default array for all other types + else return 'array'; } } else if (prop.flowType.name === '$ReadOnly') { // Special Case: switch#trackcolor @@ -164,6 +174,7 @@ function formatTypeColumn(prop) { markdown += `${key}: [${text}](${url})` + ', '; } }); + if (!url) markdown += `${key}: ${value.name}` + ', '; } ); if (markdown.match(/, $/)) markdown = markdown.replace(/, $/, ''); @@ -191,6 +202,8 @@ function formatTypeColumn(prop) { if (url) return `[${text}](${url})`; return `enum(${unionTypes.join(', ')})`; + } else if (prop.flowType.name === 'ReactElement') { + return 'element'; } else { // Get text and url from magic aliases prop?.flowType?.elements?.forEach(elem => { From e72b9a5b0e86db5a2a1e61d80a6305bbfc41ad59 Mon Sep 17 00:00:00 2001 From: Ayush Jain Date: Tue, 11 Aug 2020 03:01:44 +0530 Subject: [PATCH 5/5] Minor fix in description parsing --- .../scripts/sync-api-docs/extractDocsFromRN.js | 2 -- .../scripts/sync-api-docs/generateMarkdown.js | 16 +++++++++------- website/scripts/sync-api-docs/magic.js | 4 ++++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/website/scripts/sync-api-docs/extractDocsFromRN.js b/website/scripts/sync-api-docs/extractDocsFromRN.js index c87806aa8a4..6a1b7e20baf 100644 --- a/website/scripts/sync-api-docs/extractDocsFromRN.js +++ b/website/scripts/sync-api-docs/extractDocsFromRN.js @@ -52,8 +52,6 @@ async function extractDocsFromRN(rnRoot) { if (item.description) return item; }); - // console.log(filteredResult) - docs.push({ file, component: cleanComponentResult(...filteredResult), diff --git a/website/scripts/sync-api-docs/generateMarkdown.js b/website/scripts/sync-api-docs/generateMarkdown.js index 6fdd7c4d18e..47af24a4a05 100644 --- a/website/scripts/sync-api-docs/generateMarkdown.js +++ b/website/scripts/sync-api-docs/generateMarkdown.js @@ -281,13 +281,15 @@ function preprocessDescription(desc) { secondExample.substr(secondExample.search('```') + 3) ); } else { - return ( - desc.substr(0, desc.search('```SnackPlayer')) + - '\n' + - '\n## Example\n' + - '\n' + - desc.substr(desc.search('```SnackPlayer')) - ); + if (desc.search('```SnackPlayer') !== -1) { + return ( + desc.substr(0, desc.search('```SnackPlayer')) + + '\n' + + '\n## Example\n' + + '\n' + + desc.substr(desc.search('```SnackPlayer')) + ); + } else return desc; } } diff --git a/website/scripts/sync-api-docs/magic.js b/website/scripts/sync-api-docs/magic.js index e40137628e1..acd9afc8f57 100644 --- a/website/scripts/sync-api-docs/magic.js +++ b/website/scripts/sync-api-docs/magic.js @@ -29,5 +29,9 @@ module.exports = { text: 'RefreshControl.SIZE', url: 'refreshcontrol.md#refreshlayoutconstssize', }, + ReactNode: { + text: 'React.Node', + url: 'react-node.md', + }, }, };