Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix jsDoc visibleName support #289

Merged
merged 1 commit into from
Aug 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -328,9 +328,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