Skip to content

Commit

Permalink
fix(docgen): Vue.extends without comments
Browse files Browse the repository at this point in the history
closes #1027
  • Loading branch information
elevatebart committed Nov 27, 2020
1 parent 8206a4a commit bf42ccc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,31 @@ describe('componentHandler', () => {
}
expect(documentation.set).toHaveBeenCalledWith('description', 'Best Button Ever')
})

it('should extract all info when Vue.extends is assigned to a const and exported later', () => {
const src = `
/**
* @displayName Best Button Ever
*/
const button = Vue.extends({
})
export default button
`
const def = parse(src).get('default')
if (def) {
componentHandler(documentation, def)
}
expect(documentation.set).toHaveBeenCalledWith('displayName', 'Best Button Ever')
})

it('should not fail when no comments are on a Vue.extends', () => {
const src = `export default Vue.extends({})`
const def = parse(src).get('default')
expect(() => {
if (def) {
componentHandler(documentation, def)
}
}).not.toThrow()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ export default function propHandler(documentation: Documentation, path: NodePath
if (bt.isCallExpression(componentCommentedPath.node)) {
// look for leading comments in the parent structures
let i = 5
while (i-- && !componentCommentedPath.get('leadingComments').value) {
while (
i-- &&
!componentCommentedPath.get('leadingComments').value &&
componentCommentedPath.parentPath.node.type !== 'Program'
) {
componentCommentedPath = componentCommentedPath.parentPath
}
} else if (bt.isVariableDeclarator(componentCommentedPath.node)) {
Expand Down

0 comments on commit bf42ccc

Please sign in to comment.