Skip to content
This repository has been archived by the owner on Mar 8, 2019. It is now read-only.

Commit

Permalink
fix: allow documenting of propTypes and vueTypes props (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
elevatebart committed Jan 28, 2019
1 parent 14ad5f5 commit 7801fdf
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/script-handlers/__tests__/propHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,39 @@ describe('propHandler', () => {
type: { name: 'boolean' },
})
})

it('should still return props with vue-types', () => {
const src = [
'export default {',
' props:{',
' test: VueTypes.shape({',
' line1: String,',
' line2: String,',
' })',
' }',
'}',
].join('\n')
tester(src, {
type: {
func: true,
},
})
})

it('should still return props with prop-types', () => {
const src = [
'export default {',
' props:{',
" test: PropTypes.oneOf(['News', 'Photos'])",
' }',
'}',
].join('\n')
tester(src, {
type: {
func: true,
},
})
})
})

describe('required', () => {
Expand Down
5 changes: 5 additions & 0 deletions src/script-handlers/propHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ export default function propHandler(documentation: Documentation, path: NodePath
} else if (bt.isIdentifier(propValuePath.node)) {
// contents of the prop is it's type
propDescriptor.type = getTypeFromTypePath(propValuePath)
} else {
propDescriptor.type = {
name: recast.print(prop.get('value')).code,
func: true,
}
}
})
} else if (bt.isArrayExpression(propsValuePath.node)) {
Expand Down

0 comments on commit 7801fdf

Please sign in to comment.