File tree 2 files changed +27
-2
lines changed
2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -84,3 +84,24 @@ test('parse - document exported', function() {
84
84
) . length
85
85
) . toBe ( 2 ) ;
86
86
} ) ;
87
+
88
+ test ( 'parse - constructor comments' , function ( ) {
89
+ expect (
90
+ toComments ( `
91
+ class Test {
92
+ /** @hideconstructor */
93
+ constructor() {}
94
+ }
95
+ ` ) . length
96
+ ) . toBe ( 0 ) ;
97
+
98
+ expect (
99
+ toComments ( `
100
+ /** Test */
101
+ export class Test {
102
+ /** @hideconstructor */
103
+ constructor() {}
104
+ }
105
+ ` ) [ 0 ] . constructorComment
106
+ ) . toBeDefined ( ) ;
107
+ } ) ;
Original file line number Diff line number Diff line change @@ -6,7 +6,8 @@ var _ = require('lodash'),
6
6
walkComments = require ( '../extractors/comments' ) ,
7
7
walkExported = require ( '../extractors/exported' ) ,
8
8
util = require ( 'util' ) ,
9
- debuglog = util . debuglog ( 'documentation' ) ;
9
+ debuglog = util . debuglog ( 'documentation' ) ,
10
+ findTarget = require ( '../infer/finders' ) . findTarget ;
10
11
11
12
import { parseToAst } from './parse_to_ast' ;
12
13
@@ -98,7 +99,7 @@ function _addComment(
98
99
}
99
100
const comment = parse ( commentValue , commentLoc , context ) ;
100
101
if ( includeContext ) {
101
- commentsByNode . set ( path . node , comment ) ;
102
+ commentsByNode . set ( ( findTarget ( path ) || path ) . node , comment ) ;
102
103
103
104
if ( t . isClassMethod ( path ) && path . node . kind === 'constructor' ) {
104
105
// #689
@@ -115,6 +116,9 @@ function _addComment(
115
116
parentComment . constructorComment = comment ;
116
117
return ;
117
118
}
119
+ if ( comment . hideconstructor ) {
120
+ return ;
121
+ }
118
122
}
119
123
}
120
124
return comment ;
You can’t perform that action at this time.
0 commit comments