File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,15 @@ describe('docblock', () => {
74
74
expect ( getDocblock ( node ) ) . toEqual ( comment . join ( '\n' ) ) ;
75
75
} ) ;
76
76
} ) ;
77
+
78
+ it ( 'supports "short" docblocks' , ( ) => {
79
+ let source = [ // eslint-disable-line no-shadow
80
+ '/** bar */' ,
81
+ 'foo;' ,
82
+ ] ;
83
+ let node = statement ( source . join ( '\n' ) ) ;
84
+ expect ( getDocblock ( node ) ) . toEqual ( 'bar' ) ;
85
+ } ) ;
77
86
} ) ;
78
87
79
88
} ) ;
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ function parseDocblock(str) {
23
23
return lines . join ( '\n' ) . trim ( ) ;
24
24
}
25
25
26
+ let DOCBLOCK_HEADER = / ^ \* \s / ;
27
+
26
28
/**
27
29
* Given a path, this function returns the closest preceding docblock if it
28
30
* exists.
@@ -32,7 +34,7 @@ export function getDocblock(path: NodePath): ?string {
32
34
var comments = path . node . comments . filter ( function ( comment ) {
33
35
return comment . leading &&
34
36
comment . type === 'CommentBlock' &&
35
- comment . value . indexOf ( '*\n' ) === 0 ;
37
+ DOCBLOCK_HEADER . test ( comment . value ) ;
36
38
} ) ;
37
39
if ( comments . length > 0 ) {
38
40
return parseDocblock ( comments [ comments . length - 1 ] . value ) ;
You can’t perform that action at this time.
0 commit comments