Commit dfac27e6 authored by Qiu Xiang's avatar Qiu Xiang

移除 docgen

parent 3cc70dfd
{ {
"name": "react-native-amap3d", "name": "react-native-amap3d",
"version": "0.1.0", "version": "0.2.0-alpha.7",
"description": "react-native 高德地图组件", "description": "react-native 高德地图组件",
"main": "components/MapView.js", "main": "components/MapView.js",
"author": "Qiu Xiang <i@7c00.cc>", "author": "Qiu Xiang <i@7c00.cc>",
...@@ -14,14 +14,8 @@ ...@@ -14,14 +14,8 @@
"type": "git", "type": "git",
"url": "https://github.com/qiuxiang/react-native-amap3d" "url": "https://github.com/qiuxiang/react-native-amap3d"
}, },
"scripts": {
"docgen": "react-docgen components 2>/dev/null | node scripts/docgen.js"
},
"peerDependencies": { "peerDependencies": {
"react": "*", "react": "*",
"react-native": "*" "react-native": "*"
},
"devDependencies": {
"react-docgen": "^2.16.0"
} }
} }
const stdin = process.openStdin()
let data = ''
stdin.on('data', chunk => data += chunk)
stdin.on('end', () => docgen(JSON.parse(data)))
function docgen(docs) {
const components = [
'MapView',
'Marker',
'Polyline',
'Polygon',
'Circle',
]
let markdown = ''
components.forEach(componentName => {
const doc = docs[`components/${componentName}.js`]
markdown += `## ${componentName}\n`
markdown += '### Props\n'
for (let propName in doc.props) {
const prop = doc.props[propName]
const type = formatPropName(prop)
markdown += `#### ${propName}: ${type} ${prop.required ? '`required`' : ''} ${prop.description}\n`
}
markdown += '\n'
})
console.log(markdown)
}
function formatPropName(prop) {
let type = propNameFromCustomType(prop.type)
if (type.indexOf('isRequired') !== -1) {
type = type.replace('.isRequired', '')
prop.required = true
}
if (type === 'arrayOf') {
type += `(${propNameFromCustomType(prop.type.value)})`
}
return type
}
function propNameFromCustomType(type) {
return type.raw || type.name
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment