Skip to content

Commit 6d29b8f

Browse files
committed
Basic event hierarchization
1 parent ebce170 commit 6d29b8f

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

streams/hierarchy.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ function inferHierarchy(comments) {
4646
for (i = 0; i < comments.length; i++) {
4747
nameIndex[comments[i].name] = comments[i];
4848
comments[i].members = { instance: [], static: [] };
49+
comments[i].events = [];
4950
}
5051

5152
for (i = comments.length - 1; i >= 0; i--) {
@@ -62,13 +63,20 @@ function inferHierarchy(comments) {
6263
continue;
6364
}
6465

65-
if (!comment.scope) {
66-
console.error(error(comment, 'found memberof but no @scope, @static, or @instance tag'));
67-
continue;
66+
switch (comment.kind) {
67+
case 'event':
68+
parent.events.push(comment);
69+
break;
70+
71+
default:
72+
if (!comment.scope) {
73+
console.error(error(comment, 'found memberof but no @scope, @static, or @instance tag'));
74+
continue;
75+
}
76+
parent.members[comment.scope].push(comment);
77+
break;
6878
}
6979

70-
parent.members[comment.scope].push(comment);
71-
7280
// remove non-root nodes from the lowest level: these are reachable
7381
// as members of other docs.
7482
comments.splice(i, 1);
@@ -95,6 +103,9 @@ function inferHierarchy(comments) {
95103
comment.members.static.forEach(function (member) {
96104
addPath(member, comment.path);
97105
});
106+
comment.events.forEach(function (member) {
107+
addPath(member, comment.path);
108+
});
98109
}
99110

100111
for (i = 0; i < comments.length; i++) addPath(comments[i], []);

test/streams/hierarchy.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,26 @@ test('hierarchy', function (t) {
5858
* A magic number that identifies this Klass.
5959
*/
6060
Klass.MAGIC_NUMBER = 42;
61+
62+
/**
63+
* Klass event
64+
* @event event
65+
* @memberof Klass
66+
*/
67+
68+
return Klass;
6169
}, function (result) {
6270
t.equal(result.length, 1);
71+
6372
t.equal(result[0].members.static.length, 2);
73+
t.deepEqual(result[0].members.static[0].path, ['Klass', 'isClass']);
74+
6475
t.equal(result[0].members.instance.length, 1);
76+
t.deepEqual(result[0].members.instance[0].path, ['Klass', 'getFoo']);
77+
78+
t.equal(result[0].events.length, 1);
79+
t.deepEqual(result[0].events[0].path, ['Klass', 'event']);
80+
6581
t.end();
6682
});
6783
});

0 commit comments

Comments
 (0)