UNPKG

react-native-ui-lib

Version:

UI Components Library for React Native ###### Lateset version support RN44

29 lines (24 loc) 852 B
const _ = require('lodash'); const {utils} = require('react-docgen'); // eslint-disable-line const {getMemberValuePath, docblock} = utils; const {getDocblock} = docblock; /** * Extract info on the component props */ function propTypesDocsHandler(documentation, path) { const propTypesPath = getMemberValuePath(path, 'propTypes'); const docComment = getDocblock(propTypesPath.parent); const statementPattern = /@.*\:/; const info = {}; if (docComment) { const infoRaw = _.split(docComment, '\n'); _.forEach(infoRaw, (statement) => { if (statement && statementPattern.test(statement)) { const key = statement.match(statementPattern)[0].slice(1, -1); info[key] = statement.split(statementPattern)[1].trim(); } }); } documentation.set('propsInfo', info); } module.exports = propTypesDocsHandler;