2015-02-12 22:43:41 +00:00
|
|
|
var docs = require('../react-docgen');
|
|
|
|
var fs = require('fs');
|
|
|
|
var path = require('path');
|
|
|
|
var slugify = require('../core/slugify');
|
|
|
|
|
|
|
|
function getNameFromPath(filepath) {
|
|
|
|
var ext = null;
|
|
|
|
while (ext = path.extname(filepath)) {
|
|
|
|
filepath = path.basename(filepath, ext);
|
|
|
|
}
|
|
|
|
return filepath;
|
|
|
|
}
|
|
|
|
|
|
|
|
function docsToMarkdown(filepath, i) {
|
2015-03-03 01:31:26 +00:00
|
|
|
var json = docs.parse(
|
2015-02-19 00:39:28 +00:00
|
|
|
fs.readFileSync(filepath),
|
|
|
|
function(node, recast) {
|
2015-03-03 01:31:26 +00:00
|
|
|
return docs.resolver.findExportedReactCreateClassCall(node, recast) ||
|
|
|
|
docs.resolver.findAllReactCreateClassCalls(node, recast)[0];
|
2015-02-19 00:39:28 +00:00
|
|
|
}
|
2015-03-05 02:10:12 +00:00
|
|
|
);
|
2015-02-19 00:39:28 +00:00
|
|
|
|
2015-02-12 22:43:41 +00:00
|
|
|
var componentName = getNameFromPath(filepath);
|
|
|
|
|
|
|
|
var res = [
|
|
|
|
'---',
|
|
|
|
'id: ' + slugify(componentName),
|
|
|
|
'title: ' + componentName,
|
2015-03-05 02:10:12 +00:00
|
|
|
'layout: autodocs',
|
2015-02-12 22:43:41 +00:00
|
|
|
'category: Components',
|
|
|
|
'permalink: docs/' + slugify(componentName) + '.html',
|
|
|
|
components[i + 1] && ('next: ' + slugify(getNameFromPath(components[i + 1]))),
|
|
|
|
'---',
|
2015-03-05 02:10:12 +00:00
|
|
|
JSON.stringify(json, null, 2),
|
2015-02-12 22:43:41 +00:00
|
|
|
].filter(function(line) { return line; }).join('\n');
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
var components = [
|
|
|
|
'../Libraries/Components/Navigation/NavigatorIOS.ios.js',
|
2015-03-03 01:31:26 +00:00
|
|
|
'../Libraries/Image/Image.ios.js',
|
2015-02-12 22:43:41 +00:00
|
|
|
'../Libraries/Components/ListView/ListView.js',
|
|
|
|
'../Libraries/Components/Navigation/NavigatorIOS.ios.js',
|
|
|
|
'../Libraries/Components/ScrollView/ScrollView.ios.js',
|
2015-03-03 01:31:26 +00:00
|
|
|
'../Libraries/Text/Text.js',
|
2015-03-05 02:10:12 +00:00
|
|
|
'../Libraries/Image/Image.ios.js',
|
2015-02-12 22:43:41 +00:00
|
|
|
'../Libraries/Components/TextInput/TextInput.ios.js',
|
|
|
|
'../Libraries/Components/Touchable/TouchableHighlight.js',
|
|
|
|
'../Libraries/Components/Touchable/TouchableWithoutFeedback.js',
|
2015-02-19 00:39:28 +00:00
|
|
|
'../Libraries/Components/View/View.js',
|
2015-02-12 22:43:41 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
module.exports = function() {
|
|
|
|
return components.map(docsToMarkdown);
|
|
|
|
};
|