Skip to content

Commit 411a900

Browse files
committed
fix: Remove sources from hidden signatures
1 parent 1c89283 commit 411a900

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

src/lib/converter/plugins/CommentPlugin.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { Component, ConverterComponent } from '../components';
1313
import { parseComment, getRawComment } from '../factories/comment';
1414
import { Converter } from '../converter';
1515
import { Context } from '../context';
16+
import { partition, uniq } from 'lodash';
17+
import { SourceReference } from '../../models';
1618

1719
/**
1820
* Structure used by [[ContainerCommentHandler]] to store discovered module comments.
@@ -226,12 +228,15 @@ export class CommentPlugin extends ConverterComponent {
226228
hidden.forEach(reflection => project.removeReflection(reflection, true));
227229

228230
// remove functions with empty signatures after their signatures have been removed
229-
const hiddenMethods = hidden.map(reflection => reflection.parent!)
230-
.filter(method =>
231-
method.kindOf(ReflectionKind.FunctionOrMethod)
232-
&& method instanceof DeclarationReflection
233-
&& method.signatures?.length === 0);
234-
hiddenMethods.forEach(reflection => project.removeReflection(reflection, true));
231+
const [ allRemoved, someRemoved ] = partition(
232+
hidden.map(reflection => reflection.parent!)
233+
.filter(method => method.kindOf(ReflectionKind.FunctionOrMethod)) as DeclarationReflection[],
234+
method => method.signatures?.length === 0
235+
);
236+
allRemoved.forEach(reflection => project.removeReflection(reflection, true));
237+
someRemoved.forEach(reflection => {
238+
reflection.sources = uniq(reflection.signatures!.reduce<SourceReference[]>((c, s) => c.concat(s.sources || []), []));
239+
});
235240
}
236241

237242
/**

src/test/converter/comment/specs.json

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,10 @@
118118
}
119119
],
120120
"sources": [
121-
{
122-
"fileName": "comment.ts",
123-
"line": 70,
124-
"character": 13
125-
},
126121
{
127122
"fileName": "comment.ts",
128123
"line": 74,
129124
"character": 13
130-
},
131-
{
132-
"fileName": "comment.ts",
133-
"line": 75,
134-
"character": 13
135125
}
136126
]
137127
}
@@ -339,4 +329,4 @@
339329
]
340330
}
341331
]
342-
}
332+
}

0 commit comments

Comments
 (0)