Skip to content

Commit 125a577

Browse files
committed
fix: regression in toc causing crash
1 parent 5bdbf1f commit 125a577

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

__tests__/__snapshots__/test.js.snap

+11
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ This function is third
5050
5151
This function is first
5252
53+
### first
54+
55+
forgot a memberof here... sure hope that doesn't crash anything!
56+
5357
## Bravo
5458
5559
Contains a subsection!
@@ -80,6 +84,13 @@ second::bar
8084
8185
- \`beans\`
8286
- \`rice\`
87+
88+
## AClass
89+
90+
### second
91+
92+
shares a name with a top level item referenced in the TOC... sure hope
93+
that doesn't crash anything!
8394
"
8495
`;
8596

__tests__/fixture/sections.input.js

+15
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@
33
*/
44
function first() {}
55

6+
/** */
7+
class AClass {
8+
/**
9+
* forgot a memberof here... sure hope that doesn't crash anything!
10+
* @method first
11+
*/
12+
first(x, y) {}
13+
14+
/**
15+
* shares a name with a top level item referenced in the TOC... sure hope
16+
* that doesn't crash anything!
17+
*/
18+
second() {}
19+
}
20+
621
/**
722
* This class has some members
823
*/

src/sort.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ module.exports = function sortDocs(comments: Array<Comment>, options: Object) {
6464
options.toc.forEach(walk.bind(null, []));
6565
var unfixed = [];
6666
comments.forEach(function(comment) {
67-
const commentPath = paths[comment.name];
68-
if (commentPath) {
67+
let commentPath;
68+
if (!comment.memberof && (commentPath = paths[comment.name])) {
6969
comment.path = commentPath;
70+
delete paths[comment.name];
7071
}
7172

7273
// If comment is of kind 'note', this means that we must be _re_ sorting

0 commit comments

Comments
 (0)