Update react-docgen and ignore pages with no header

This commit is contained in:
Felix Kling
2015-02-18 16:39:28 -08:00
parent 022696c345
commit 472c287cd3
12 changed files with 564 additions and 246 deletions

View File

@@ -14,7 +14,8 @@ function splitHeader(content) {
}
}
return {
header: lines.slice(1, i + 1).join('\n'),
header: i < lines.length - 1 ?
lines.slice(1, i + 1).join('\n') : null,
content: lines.slice(i + 1).join('\n')
};
}
@@ -47,6 +48,9 @@ function execute() {
// Extract markdown metadata header
var both = splitHeader(content);
if (!both.header) {
return;
}
var lines = both.header.split('\n');
for (var i = 0; i < lines.length - 1; ++i) {
var keyvalue = lines[i].split(':');

View File

@@ -1,4 +1,10 @@
var docs = require('../react-docgen');
var findExportedReactCreateClassCall = require(
'../react-docgen/dist/strategies/findExportedReactCreateClassCall'
);
var findAllReactCreateClassCalls = require(
'../react-docgen/dist/strategies/findAllReactCreateClassCalls'
);
var fs = require('fs');
var path = require('path');
var slugify = require('../core/slugify');
@@ -12,7 +18,14 @@ function getNameFromPath(filepath) {
}
function docsToMarkdown(filepath, i) {
var json = docs.parseSource(fs.readFileSync(filepath));
var json = docs.parseSource(
fs.readFileSync(filepath),
function(node, recast) {
return findExportedReactCreateClassCall(node, recast) ||
findAllReactCreateClassCalls(node, recast)[0];
}
)
var componentName = getNameFromPath(filepath);
var res = [
@@ -45,7 +58,7 @@ var components = [
'../Libraries/Components/TextInput/TextInput.ios.js',
'../Libraries/Components/Touchable/TouchableHighlight.js',
'../Libraries/Components/Touchable/TouchableWithoutFeedback.js',
// '../Libraries/Components/View/View.js',
'../Libraries/Components/View/View.js',
];
module.exports = function() {