From b8e41a12c1ee548edd559a61fb80e4db7f849171 Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Fri, 14 Aug 2020 11:37:32 -0700 Subject: [PATCH] use just the description for JSDoc comment instead of full comment --- src/__tests__/data/JSDocWithParam.tsx | 19 +++++++++++++++++++ src/__tests__/parser.ts | 13 +++++++++++++ src/parser.ts | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/__tests__/data/JSDocWithParam.tsx diff --git a/src/__tests__/data/JSDocWithParam.tsx b/src/__tests__/data/JSDocWithParam.tsx new file mode 100644 index 00000000..8a82ae4f --- /dev/null +++ b/src/__tests__/data/JSDocWithParam.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; + +/** JSDocWithParamProps props */ +export interface JSDocWithParamProps { + /** prop1 description */ + prop1: string; +} + +/** + * JSDocWithParamProps description + * + * NOTE: If a parent element of this control is `overflow: hidden` then the + * balloon may not show up. + * + * @param props Control properties (defined in `SimpleDropdownProps` interface) + */ +export const JSDocWithParam = (props: JSDocWithParamProps) => { + return
Test
; +}; diff --git a/src/__tests__/parser.ts b/src/__tests__/parser.ts index c1367515..2216f4e4 100644 --- a/src/__tests__/parser.ts +++ b/src/__tests__/parser.ts @@ -699,6 +699,19 @@ describe('parser', () => { }); }); + it('should parse JSDoc correctly', () => { + check( + 'JSDocWithParam', + { + JSDocWithParam: { + prop1: { type: 'string', required: true } + } + }, + true, + 'JSDocWithParamProps description\n\nNOTE: If a parent element of this control is `overflow: hidden` then the\nballoon may not show up.' + ); + }); + it('should parse functional component component defined as const as default export', () => { check( 'FunctionalComponentAsConstAsDefaultExport', diff --git a/src/parser.ts b/src/parser.ts index ebddffb3..b732523d 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -297,7 +297,7 @@ export class Parser { const resolvedComponentName = componentNameResolver(nameSource, source); const displayName = resolvedComponentName || computeComponentName(nameSource, source); - const description = this.findDocComment(commentSource).fullComment; + const { description } = this.findDocComment(commentSource); const methods = this.getMethodsInfo(type); if (propsType) {