Skip to content

Commit

Permalink
feat: Add event members to md output (#1336)
Browse files Browse the repository at this point in the history
Co-authored-by: Allart Kooiman <akooiman@nieuwland.nl>
  • Loading branch information
allartk and Allart Kooiman committed Oct 24, 2020
1 parent a366d95 commit bc3233f
Show file tree
Hide file tree
Showing 3 changed files with 382 additions and 0 deletions.
362 changes: 362 additions & 0 deletions __tests__/__snapshots__/test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -29619,6 +29619,368 @@ Object {
}
`;

exports[`outputs nest_events.input.js JSON 1`] = `
Array [
Object {
"augments": Array [],
"context": Object {
"loc": Object {
"end": Object {
"column": 6,
"line": 13,
},
"start": Object {
"column": 0,
"line": 13,
},
},
},
"description": Object {
"children": Array [
Object {
"children": Array [
Object {
"position": Object {
"end": Object {
"column": 18,
"line": 1,
"offset": 17,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "text",
"value": "Klass description",
},
],
"position": Object {
"end": Object {
"column": 18,
"line": 1,
"offset": 17,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "paragraph",
},
],
"position": Object {
"end": Object {
"column": 18,
"line": 1,
"offset": 17,
},
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "root",
},
"errors": Array [],
"examples": Array [],
"implements": Array [],
"kind": "class",
"loc": Object {
"end": Object {
"column": 3,
"line": 5,
},
"start": Object {
"column": 0,
"line": 1,
},
},
"members": Object {
"events": Array [
Object {
"augments": Array [],
"context": Object {
"loc": Object {
"end": Object {
"column": 6,
"line": 13,
},
"start": Object {
"column": 0,
"line": 13,
},
},
},
"description": Object {
"children": Array [
Object {
"children": Array [
Object {
"position": Object {
"end": Object {
"column": 12,
"line": 1,
"offset": 11,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "text",
"value": "Klass event",
},
],
"position": Object {
"end": Object {
"column": 12,
"line": 1,
"offset": 11,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "paragraph",
},
],
"position": Object {
"end": Object {
"column": 12,
"line": 1,
"offset": 11,
},
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "root",
},
"errors": Array [],
"examples": Array [],
"implements": Array [],
"kind": "event",
"loc": Object {
"end": Object {
"column": 3,
"line": 12,
},
"start": Object {
"column": 1,
"line": 8,
},
},
"memberof": "Klass",
"members": Object {
"events": Array [],
"global": Array [],
"inner": Array [],
"instance": Array [],
"static": Array [],
},
"name": "bar",
"namespace": "Klass.event:bar",
"params": Array [],
"path": Array [
Object {
"kind": "class",
"name": "Klass",
},
Object {
"kind": "event",
"name": "bar",
},
],
"properties": Array [],
"returns": Array [],
"sees": Array [],
"tags": Array [
Object {
"description": "bar",
"lineNumber": 2,
"title": "event",
},
Object {
"description": "Klass",
"lineNumber": 3,
"title": "memberof",
},
],
"throws": Array [],
"todos": Array [],
"yields": Array [],
},
],
"global": Array [],
"inner": Array [],
"instance": Array [],
"static": Array [],
},
"name": "Klass",
"namespace": "Klass",
"params": Array [],
"path": Array [
Object {
"kind": "class",
"name": "Klass",
},
],
"properties": Array [],
"returns": Array [],
"sees": Array [],
"tags": Array [
Object {
"description": null,
"lineNumber": 3,
"name": "Klass",
"title": "class",
"type": null,
},
],
"throws": Array [],
"todos": Array [],
"yields": Array [],
},
]
`;

exports[`outputs nest_events.input.js markdown 1`] = `
"<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

- [Klass][1]
- [bar][2]

## Klass

Klass description

### bar

Klass event

[1]: #klass

[2]: #bar
"
`;

exports[`outputs nest_events.input.js markdown AST 1`] = `
Object {
"children": Array [
Object {
"type": "html",
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->",
},
Object {
"children": Array [
Object {
"type": "text",
"value": "Klass",
},
],
"depth": 2,
"type": "heading",
},
Object {
"children": Array [
Object {
"position": Position {
"end": Object {
"column": 18,
"line": 1,
"offset": 17,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "text",
"value": "Klass description",
},
],
"position": Position {
"end": Object {
"column": 18,
"line": 1,
"offset": 17,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "paragraph",
},
Object {
"children": Array [
Object {
"type": "text",
"value": "bar",
},
],
"depth": 3,
"type": "heading",
},
Object {
"children": Array [
Object {
"position": Position {
"end": Object {
"column": 12,
"line": 1,
"offset": 11,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "text",
"value": "Klass event",
},
],
"position": Position {
"end": Object {
"column": 12,
"line": 1,
"offset": 11,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "paragraph",
},
],
"type": "root",
}
`;

exports[`outputs nest_params.input.js JSON 1`] = `
Array [
Object {
Expand Down
13 changes: 13 additions & 0 deletions __tests__/fixture/nest_events.input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Klass description
*
* @class Klass
*/


/**
* Klass event
* @event bar
* @memberof Klass
*/
bar();
7 changes: 7 additions & 0 deletions src/output/markdown_ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,13 @@ function buildMarkdownAST(comments, config) {
[]
)
)
.concat(
!!comment.members.events.length &&
comment.members.events.reduce(
(memo, child) => memo.concat(generate(depth + 1, child)),
[]
)
)
.filter(Boolean);
}

Expand Down

0 comments on commit bc3233f

Please sign in to comment.