File tree Expand file tree Collapse file tree 3 files changed +58
-1
lines changed Expand file tree Collapse file tree 3 files changed +58
-1
lines changed Original file line number Diff line number Diff line change @@ -290,7 +290,7 @@ exports.astNodeVisitor = {
290290 comment . value . indexOf ( '@classdesc' ) !== - 1 ||
291291 ! noClassdescRegEx . test ( comment . value )
292292 ) {
293- node . leadingComments . push ( comment ) ;
293+ node . leadingComments . unshift ( comment ) ;
294294 node . parent . leadingComments . splice ( i , 1 ) ;
295295 const ignore =
296296 parser . astBuilder . build ( '/** @ignore */' ) . comments [ 0 ] ;
Original file line number Diff line number Diff line change 237237 "scope" : " inner" ,
238238 "memberof" : " module:test"
239239 },
240+ {
241+ "comment" : " /** @ignore */" ,
242+ "meta" : {
243+ "range" : [
244+ 434 ,
245+ 465
246+ ],
247+ "filename" : " LeadingComments.js" ,
248+ "lineno" : 14 ,
249+ "columnno" : 0 ,
250+ "code" : {
251+ "name" : " exports.LeadingComments" ,
252+ "type" : " ClassDeclaration"
253+ }
254+ },
255+ "ignore" : true ,
256+ "name" : " LeadingComments" ,
257+ "longname" : " LeadingComments" ,
258+ "kind" : " class" ,
259+ "scope" : " global"
260+ },
261+ {
262+ "comment" : " /**\n * Doclet\n */" ,
263+ "meta" : {
264+ "range" : [
265+ 441 ,
266+ 465
267+ ],
268+ "filename" : " LeadingComments.js" ,
269+ "lineno" : 14 ,
270+ "columnno" : 7 ,
271+ "code" : {
272+ "name" : " LeadingComments" ,
273+ "type" : " ClassDeclaration" ,
274+ "paramnames" : []
275+ }
276+ },
277+ "classdesc" : " Doclet" ,
278+ "name" : " LeadingComments" ,
279+ "longname" : " LeadingComments" ,
280+ "kind" : " class" ,
281+ "scope" : " global"
282+ },
240283 {
241284 "comment" : " /**\n * @module test/sub/NumberStore\n */" ,
242285 "meta" : {
Original file line number Diff line number Diff line change 1+ // Import statement required for JSDoc to include first comment as leading comment of the class.
2+ // Otherwise, it gets moved in the AST to the `Program` node from the `ExportNamedDeclaration` class node:
3+ // https://github.com/jsdoc/jsdoc/blob/main/packages/jsdoc-ast/lib/walker.js#L465
4+ // This itself may be a bug, as it seems to be intended for @module comments.
5+ import '' ; // eslint-disable-line
6+
7+ /*
8+ Comment
9+ */
10+
11+ /**
12+ * Doclet
13+ */
14+ export class LeadingComments { }
You can’t perform that action at this time.
0 commit comments