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

Commit 7801fdf

Browse files
authored
fix: allow documenting of propTypes and vueTypes props (#90)
1 parent 14ad5f5 commit 7801fdf

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/script-handlers/__tests__/propHandler.ts

+33
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,39 @@ describe('propHandler', () => {
152152
type: { name: 'boolean' },
153153
})
154154
})
155+
156+
it('should still return props with vue-types', () => {
157+
const src = [
158+
'export default {',
159+
' props:{',
160+
' test: VueTypes.shape({',
161+
' line1: String,',
162+
' line2: String,',
163+
' })',
164+
' }',
165+
'}',
166+
].join('\n')
167+
tester(src, {
168+
type: {
169+
func: true,
170+
},
171+
})
172+
})
173+
174+
it('should still return props with prop-types', () => {
175+
const src = [
176+
'export default {',
177+
' props:{',
178+
" test: PropTypes.oneOf(['News', 'Photos'])",
179+
' }',
180+
'}',
181+
].join('\n')
182+
tester(src, {
183+
type: {
184+
func: true,
185+
},
186+
})
187+
})
155188
})
156189

157190
describe('required', () => {

src/script-handlers/propHandler.ts

+5
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ export default function propHandler(documentation: Documentation, path: NodePath
7070
} else if (bt.isIdentifier(propValuePath.node)) {
7171
// contents of the prop is it's type
7272
propDescriptor.type = getTypeFromTypePath(propValuePath)
73+
} else {
74+
propDescriptor.type = {
75+
name: recast.print(prop.get('value')).code,
76+
func: true,
77+
}
7378
}
7479
})
7580
} else if (bt.isArrayExpression(propsValuePath.node)) {

0 commit comments

Comments
 (0)