Skip to content

Commit bc3233f

Browse files
allartkAllart Kooiman
and
Allart Kooiman
authoredOct 24, 2020
feat: Add event members to md output (#1336)
Co-authored-by: Allart Kooiman <akooiman@nieuwland.nl>
1 parent a366d95 commit bc3233f

File tree

3 files changed

+382
-0
lines changed

3 files changed

+382
-0
lines changed
 

‎__tests__/__snapshots__/test.js.snap

+362
Original file line numberDiff line numberDiff line change
@@ -29619,6 +29619,368 @@ Object {
2961929619
}
2962029620
`;
2962129621

29622+
exports[`outputs nest_events.input.js JSON 1`] = `
29623+
Array [
29624+
Object {
29625+
"augments": Array [],
29626+
"context": Object {
29627+
"loc": Object {
29628+
"end": Object {
29629+
"column": 6,
29630+
"line": 13,
29631+
},
29632+
"start": Object {
29633+
"column": 0,
29634+
"line": 13,
29635+
},
29636+
},
29637+
},
29638+
"description": Object {
29639+
"children": Array [
29640+
Object {
29641+
"children": Array [
29642+
Object {
29643+
"position": Object {
29644+
"end": Object {
29645+
"column": 18,
29646+
"line": 1,
29647+
"offset": 17,
29648+
},
29649+
"indent": Array [],
29650+
"start": Object {
29651+
"column": 1,
29652+
"line": 1,
29653+
"offset": 0,
29654+
},
29655+
},
29656+
"type": "text",
29657+
"value": "Klass description",
29658+
},
29659+
],
29660+
"position": Object {
29661+
"end": Object {
29662+
"column": 18,
29663+
"line": 1,
29664+
"offset": 17,
29665+
},
29666+
"indent": Array [],
29667+
"start": Object {
29668+
"column": 1,
29669+
"line": 1,
29670+
"offset": 0,
29671+
},
29672+
},
29673+
"type": "paragraph",
29674+
},
29675+
],
29676+
"position": Object {
29677+
"end": Object {
29678+
"column": 18,
29679+
"line": 1,
29680+
"offset": 17,
29681+
},
29682+
"start": Object {
29683+
"column": 1,
29684+
"line": 1,
29685+
"offset": 0,
29686+
},
29687+
},
29688+
"type": "root",
29689+
},
29690+
"errors": Array [],
29691+
"examples": Array [],
29692+
"implements": Array [],
29693+
"kind": "class",
29694+
"loc": Object {
29695+
"end": Object {
29696+
"column": 3,
29697+
"line": 5,
29698+
},
29699+
"start": Object {
29700+
"column": 0,
29701+
"line": 1,
29702+
},
29703+
},
29704+
"members": Object {
29705+
"events": Array [
29706+
Object {
29707+
"augments": Array [],
29708+
"context": Object {
29709+
"loc": Object {
29710+
"end": Object {
29711+
"column": 6,
29712+
"line": 13,
29713+
},
29714+
"start": Object {
29715+
"column": 0,
29716+
"line": 13,
29717+
},
29718+
},
29719+
},
29720+
"description": Object {
29721+
"children": Array [
29722+
Object {
29723+
"children": Array [
29724+
Object {
29725+
"position": Object {
29726+
"end": Object {
29727+
"column": 12,
29728+
"line": 1,
29729+
"offset": 11,
29730+
},
29731+
"indent": Array [],
29732+
"start": Object {
29733+
"column": 1,
29734+
"line": 1,
29735+
"offset": 0,
29736+
},
29737+
},
29738+
"type": "text",
29739+
"value": "Klass event",
29740+
},
29741+
],
29742+
"position": Object {
29743+
"end": Object {
29744+
"column": 12,
29745+
"line": 1,
29746+
"offset": 11,
29747+
},
29748+
"indent": Array [],
29749+
"start": Object {
29750+
"column": 1,
29751+
"line": 1,
29752+
"offset": 0,
29753+
},
29754+
},
29755+
"type": "paragraph",
29756+
},
29757+
],
29758+
"position": Object {
29759+
"end": Object {
29760+
"column": 12,
29761+
"line": 1,
29762+
"offset": 11,
29763+
},
29764+
"start": Object {
29765+
"column": 1,
29766+
"line": 1,
29767+
"offset": 0,
29768+
},
29769+
},
29770+
"type": "root",
29771+
},
29772+
"errors": Array [],
29773+
"examples": Array [],
29774+
"implements": Array [],
29775+
"kind": "event",
29776+
"loc": Object {
29777+
"end": Object {
29778+
"column": 3,
29779+
"line": 12,
29780+
},
29781+
"start": Object {
29782+
"column": 1,
29783+
"line": 8,
29784+
},
29785+
},
29786+
"memberof": "Klass",
29787+
"members": Object {
29788+
"events": Array [],
29789+
"global": Array [],
29790+
"inner": Array [],
29791+
"instance": Array [],
29792+
"static": Array [],
29793+
},
29794+
"name": "bar",
29795+
"namespace": "Klass.event:bar",
29796+
"params": Array [],
29797+
"path": Array [
29798+
Object {
29799+
"kind": "class",
29800+
"name": "Klass",
29801+
},
29802+
Object {
29803+
"kind": "event",
29804+
"name": "bar",
29805+
},
29806+
],
29807+
"properties": Array [],
29808+
"returns": Array [],
29809+
"sees": Array [],
29810+
"tags": Array [
29811+
Object {
29812+
"description": "bar",
29813+
"lineNumber": 2,
29814+
"title": "event",
29815+
},
29816+
Object {
29817+
"description": "Klass",
29818+
"lineNumber": 3,
29819+
"title": "memberof",
29820+
},
29821+
],
29822+
"throws": Array [],
29823+
"todos": Array [],
29824+
"yields": Array [],
29825+
},
29826+
],
29827+
"global": Array [],
29828+
"inner": Array [],
29829+
"instance": Array [],
29830+
"static": Array [],
29831+
},
29832+
"name": "Klass",
29833+
"namespace": "Klass",
29834+
"params": Array [],
29835+
"path": Array [
29836+
Object {
29837+
"kind": "class",
29838+
"name": "Klass",
29839+
},
29840+
],
29841+
"properties": Array [],
29842+
"returns": Array [],
29843+
"sees": Array [],
29844+
"tags": Array [
29845+
Object {
29846+
"description": null,
29847+
"lineNumber": 3,
29848+
"name": "Klass",
29849+
"title": "class",
29850+
"type": null,
29851+
},
29852+
],
29853+
"throws": Array [],
29854+
"todos": Array [],
29855+
"yields": Array [],
29856+
},
29857+
]
29858+
`;
29859+
29860+
exports[`outputs nest_events.input.js markdown 1`] = `
29861+
"<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
29862+
29863+
### Table of Contents
29864+
29865+
- [Klass][1]
29866+
- [bar][2]
29867+
29868+
## Klass
29869+
29870+
Klass description
29871+
29872+
### bar
29873+
29874+
Klass event
29875+
29876+
[1]: #klass
29877+
29878+
[2]: #bar
29879+
"
29880+
`;
29881+
29882+
exports[`outputs nest_events.input.js markdown AST 1`] = `
29883+
Object {
29884+
"children": Array [
29885+
Object {
29886+
"type": "html",
29887+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->",
29888+
},
29889+
Object {
29890+
"children": Array [
29891+
Object {
29892+
"type": "text",
29893+
"value": "Klass",
29894+
},
29895+
],
29896+
"depth": 2,
29897+
"type": "heading",
29898+
},
29899+
Object {
29900+
"children": Array [
29901+
Object {
29902+
"position": Position {
29903+
"end": Object {
29904+
"column": 18,
29905+
"line": 1,
29906+
"offset": 17,
29907+
},
29908+
"indent": Array [],
29909+
"start": Object {
29910+
"column": 1,
29911+
"line": 1,
29912+
"offset": 0,
29913+
},
29914+
},
29915+
"type": "text",
29916+
"value": "Klass description",
29917+
},
29918+
],
29919+
"position": Position {
29920+
"end": Object {
29921+
"column": 18,
29922+
"line": 1,
29923+
"offset": 17,
29924+
},
29925+
"indent": Array [],
29926+
"start": Object {
29927+
"column": 1,
29928+
"line": 1,
29929+
"offset": 0,
29930+
},
29931+
},
29932+
"type": "paragraph",
29933+
},
29934+
Object {
29935+
"children": Array [
29936+
Object {
29937+
"type": "text",
29938+
"value": "bar",
29939+
},
29940+
],
29941+
"depth": 3,
29942+
"type": "heading",
29943+
},
29944+
Object {
29945+
"children": Array [
29946+
Object {
29947+
"position": Position {
29948+
"end": Object {
29949+
"column": 12,
29950+
"line": 1,
29951+
"offset": 11,
29952+
},
29953+
"indent": Array [],
29954+
"start": Object {
29955+
"column": 1,
29956+
"line": 1,
29957+
"offset": 0,
29958+
},
29959+
},
29960+
"type": "text",
29961+
"value": "Klass event",
29962+
},
29963+
],
29964+
"position": Position {
29965+
"end": Object {
29966+
"column": 12,
29967+
"line": 1,
29968+
"offset": 11,
29969+
},
29970+
"indent": Array [],
29971+
"start": Object {
29972+
"column": 1,
29973+
"line": 1,
29974+
"offset": 0,
29975+
},
29976+
},
29977+
"type": "paragraph",
29978+
},
29979+
],
29980+
"type": "root",
29981+
}
29982+
`;
29983+
2962229984
exports[`outputs nest_params.input.js JSON 1`] = `
2962329985
Array [
2962429986
Object {
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Klass description
3+
*
4+
* @class Klass
5+
*/
6+
7+
8+
/**
9+
* Klass event
10+
* @event bar
11+
* @memberof Klass
12+
*/
13+
bar();

‎src/output/markdown_ast.js

+7
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,13 @@ function buildMarkdownAST(comments, config) {
352352
[]
353353
)
354354
)
355+
.concat(
356+
!!comment.members.events.length &&
357+
comment.members.events.reduce(
358+
(memo, child) => memo.concat(generate(depth + 1, child)),
359+
[]
360+
)
361+
)
355362
.filter(Boolean);
356363
}
357364

0 commit comments

Comments
 (0)
Please sign in to comment.