From 81bf5decb1dc366a28af21a2ae9a7b7deac235e7 Mon Sep 17 00:00:00 2001 From: Kevin Lacker Date: Thu, 14 Jul 2016 18:51:51 -0700 Subject: [PATCH] Add more autogenerated documentation to the whitelist Summary: I went through and checked what React Native exports that we don't have any autogen docs for, and added the missing stuff into the whitelist. The extra docs seem useful. Still not reference-documented because docgen chokes: AppStateIOS ART Keyboard LinkingIOS Platform RecyclerViewBackedScrollView Touchable UIManager I also fixed up a bit of alphabetical order Closes https://github.com/facebook/react-native/pull/8791 Differential Revision: D3566466 Pulled By: lacker fbshipit-source-id: 0d7c1f242c96bf9afe5f8b54ea7e0b6891effa4b --- website/server/extractDocs.js | 89 ++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 32 deletions(-) diff --git a/website/server/extractDocs.js b/website/server/extractDocs.js index dd3517e656..3540cdcfb2 100644 --- a/website/server/extractDocs.js +++ b/website/server/extractDocs.js @@ -257,19 +257,24 @@ function getTypedef(filepath, fileContent, json) { } function renderComponent(filepath) { - const fileContent = fs.readFileSync(filepath); - const json = docgen.parse( - fileContent, - docgenHelpers.findExportedOrFirst, - docgen.defaultHandlers.concat([ - docgenHelpers.stylePropTypeHandler, - docgenHelpers.deprecatedPropTypeHandler, - docgenHelpers.jsDocFormatHandler, - ]) - ); - json.typedef = getTypedef(filepath, fileContent); + try { + const fileContent = fs.readFileSync(filepath); + const json = docgen.parse( + fileContent, + docgenHelpers.findExportedOrFirst, + docgen.defaultHandlers.concat([ + docgenHelpers.stylePropTypeHandler, + docgenHelpers.deprecatedPropTypeHandler, + docgenHelpers.jsDocFormatHandler, + ]) + ); + json.typedef = getTypedef(filepath, fileContent); - return componentsToMarkdown('component', json, filepath, componentCount++, styleDocs); + return componentsToMarkdown('component', json, filepath, componentCount++, styleDocs); + } catch (e) { + console.log('error in renderComponent for', filepath); + throw e; + } } function isJsDocFormat(fileContent) { @@ -330,6 +335,9 @@ function parseAPIInferred(filepath, fileContent) { let json; try { json = jsDocs(fileContent); + if (!json) { + throw new Error('jsDocs returned falsy'); + } } catch (e) { console.error('Cannot parse file', filepath, e); json = {}; @@ -427,27 +435,32 @@ function getJsDocFormatType(entities) { } function renderAPI(filepath, type) { - const fileContent = fs.readFileSync(filepath).toString(); - let json = parseAPIInferred(filepath, fileContent); - if (isJsDocFormat(fileContent)) { - let jsonJsDoc = parseAPIJsDocFormat(filepath, fileContent); - // Combine method info with jsdoc fomatted content - const methods = json.methods; - if (methods && methods.length) { - let modMethods = methods; - methods.map((method, methodIndex) => { - modMethods[methodIndex].params = getJsDocFormatType(method.params); - modMethods[methodIndex].returns = + try { + const fileContent = fs.readFileSync(filepath).toString(); + let json = parseAPIInferred(filepath, fileContent); + if (isJsDocFormat(fileContent)) { + let jsonJsDoc = parseAPIJsDocFormat(filepath, fileContent); + // Combine method info with jsdoc formatted content + const methods = json.methods; + if (methods && methods.length) { + let modMethods = methods; + methods.map((method, methodIndex) => { + modMethods[methodIndex].params = getJsDocFormatType(method.params); + modMethods[methodIndex].returns = getJsDocFormatType(method.returntypehint); - delete modMethods[methodIndex].returntypehint; - }); - json.methods = modMethods; - // Use deep Object.assign so duplicate properties are overwritten. - deepAssign(jsonJsDoc.methods, json.methods); + delete modMethods[methodIndex].returntypehint; + }); + json.methods = modMethods; + // Use deep Object.assign so duplicate properties are overwritten. + deepAssign(jsonJsDoc.methods, json.methods); + } + json = jsonJsDoc; } - json = jsonJsDoc; + return componentsToMarkdown(type, json, filepath, componentCount++); + } catch (e) { + console.log('error in renderAPI for', filepath); + throw e; } - return componentsToMarkdown(type, json, filepath, componentCount++); } function renderStyle(filepath) { @@ -472,6 +485,7 @@ function renderStyle(filepath) { const components = [ '../Libraries/Components/ActivityIndicator/ActivityIndicator.js', + '../Libraries/Components/ActivityIndicator/ActivityIndicatorIOS.ios.js', '../Libraries/Components/DatePicker/DatePickerIOS.ios.js', '../Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js', '../Libraries/Image/Image.ios.js', @@ -480,8 +494,8 @@ const components = [ '../Libraries/Modal/Modal.js', '../Libraries/CustomComponents/Navigator/Navigator.js', '../Libraries/Components/Navigation/NavigatorIOS.ios.js', - '../Libraries/Components/Picker/PickerIOS.ios.js', '../Libraries/Components/Picker/Picker.js', + '../Libraries/Components/Picker/PickerIOS.ios.js', '../Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js', '../Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js', '../Libraries/Components/RefreshControl/RefreshControl.js', @@ -490,7 +504,10 @@ const components = [ '../Libraries/Components/Slider/Slider.js', '../Libraries/Components/SliderIOS/SliderIOS.ios.js', '../Libraries/Components/StatusBar/StatusBar.js', + '../Libraries/RCTTest/SnapshotViewIOS.ios.js', '../Libraries/Components/Switch/Switch.js', + '../Libraries/Components/SwitchAndroid/SwitchAndroid.android.js', + '../Libraries/Components/SwitchIOS/SwitchIOS.ios.js', '../Libraries/Components/TabBarIOS/TabBarIOS.ios.js', '../Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js', '../Libraries/Text/Text.js', @@ -507,6 +524,7 @@ const components = [ const apis = [ '../Libraries/ActionSheetIOS/ActionSheetIOS.js', + '../Libraries/AdSupport/AdSupportIOS.js', '../Libraries/Utilities/Alert.js', '../Libraries/Utilities/AlertIOS.js', '../Libraries/Animated/src/AnimatedImplementation.js', @@ -518,23 +536,30 @@ const apis = [ '../Libraries/Components/Clipboard/Clipboard.js', '../Libraries/Components/DatePickerAndroid/DatePickerAndroid.android.js', '../Libraries/Utilities/Dimensions.js', + '../Libraries/Animated/src/Easing.js', '../Libraries/Geolocation/Geolocation.js', + '../Libraries/Image/ImageEditor.js', + '../Libraries/CameraRoll/ImagePickerIOS.js', + '../Libraries/Image/ImageStore.js', '../Libraries/Components/Intent/IntentAndroid.android.js', '../Libraries/Interaction/InteractionManager.js', '../Libraries/LayoutAnimation/LayoutAnimation.js', '../Libraries/Linking/Linking.js', '../Libraries/CustomComponents/ListView/ListViewDataSource.js', '../node_modules/react/lib/NativeMethodsMixin.js', + '../Libraries/BatchedBridge/BatchedBridgedModules/NativeModules.js', '../Libraries/Network/NetInfo.js', '../Libraries/Interaction/PanResponder.js', '../Libraries/Utilities/PixelRatio.js', '../Libraries/PushNotificationIOS/PushNotificationIOS.js', + '../Libraries/Settings/Settings.ios.js', '../Libraries/Components/StatusBar/StatusBarIOS.ios.js', '../Libraries/StyleSheet/StyleSheet.js', + '../Libraries/Utilities/Systrace.js', '../Libraries/Components/TimePickerAndroid/TimePickerAndroid.android.js', '../Libraries/Components/ToastAndroid/ToastAndroid.android.js', - '../Libraries/Vibration/VibrationIOS.ios.js', '../Libraries/Vibration/Vibration.js', + '../Libraries/Vibration/VibrationIOS.ios.js', ]; const stylesWithPermalink = [