Skip to content

Commit 7338fc5

Browse files
Class leading comments order test
1 parent 9b32556 commit 7338fc5

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

test/dest/expected.json

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,49 @@
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": {
@@ -465,4 +508,4 @@
465508
"longname": "module:test/sub/NumberStore",
466509
"kind": "member"
467510
}
468-
]
511+
]

test/src/sub/LeadingComments.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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 {}

0 commit comments

Comments
 (0)