Skip to content

Commit

Permalink
Add more autogenerated documentation to the whitelist
Browse files Browse the repository at this point in the history
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 #8791

Differential Revision: D3566466

Pulled By: lacker

fbshipit-source-id: 0d7c1f242c96bf9afe5f8b54ea7e0b6891effa4b
  • Loading branch information
lacker authored and Facebook Github Bot 6 committed Jul 15, 2016
1 parent 2b1b841 commit 81bf5de
Showing 1 changed file with 57 additions and 32 deletions.
89 changes: 57 additions & 32 deletions website/server/extractDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 = {};
Expand Down Expand Up @@ -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) {
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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 = [
Expand Down

0 comments on commit 81bf5de

Please sign in to comment.