Skip to content

Commit

Permalink
Merge pull request #289 from hipstersmoothie/visibleName
Browse files Browse the repository at this point in the history
fix jsDoc visibleName support
  • Loading branch information
pvasek authored Aug 30, 2020
2 parents dc9ba09 + efe624a commit 39e9625
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/__tests__/data/FunctionDeclarationVisibleName.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as React from 'react';

/** JumbotronProps props */
export interface JumbotronProps {
/** prop1 description */
prop1: string;
}

/**
* Awesome Jumbotron description
*
* @visibleName Awesome Jumbotron
*/
export function Jumbotron(props: JumbotronProps) {
return <div>Test</div>;
}
8 changes: 8 additions & 0 deletions src/__tests__/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,14 @@ describe('parser', () => {
});
});

it('should parse functional component component defined as const', () => {
check('FunctionDeclarationVisibleName', {
'Awesome Jumbotron': {
prop1: { type: 'string', required: true }
}
});
});

it('should parse React.SFC component defined as const', () => {
check('ReactSFCAsConst', {
Jumbotron: {
Expand Down
4 changes: 2 additions & 2 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ export class Parser {

const nameSource = originalName === 'default' ? rootExp : commentSource;
const resolvedComponentName = componentNameResolver(nameSource, source);
const { description, tags } = this.findDocComment(commentSource);
const displayName =
resolvedComponentName || computeComponentName(nameSource, source);
const { description } = this.findDocComment(commentSource);
resolvedComponentName || tags.visibleName || computeComponentName(nameSource, source);
const methods = this.getMethodsInfo(type);

if (propsType) {
Expand Down

0 comments on commit 39e9625

Please sign in to comment.