1
1
import { DocCollection , Processor } from 'dgeni' ;
2
- import { ExportDoc } from 'dgeni-packages/typescript/api-doc-types/ExportDoc' ;
3
- import { ModuleDoc } from 'dgeni-packages/typescript/api-doc-types/ModuleDoc' ;
4
2
5
3
/**
6
4
* Processor to filter out Dgeni documents that are export aliases. Keeping them means
@@ -22,27 +20,12 @@ export class FilterExportAliases implements Processor {
22
20
$runBefore = [ 'categorizer' ] ;
23
21
24
22
$process ( docs : DocCollection ) {
25
- return docs . filter ( doc => this . filterAliasExport ( doc ) ) ;
23
+ return docs . filter ( doc => {
24
+ // If the alias symbol and the actual resolved symbol have the same name, then this doc
25
+ // shouldn't be filtered. This check is necessary, because technically as per TypeScript,
26
+ // explicit and individual re-exports are being considered as aliases.
27
+ // For example: export {Test} from './my-file`;
28
+ return ! ( doc . aliasSymbol && doc . aliasSymbol . name !== doc . symbol . name ) ;
29
+ } ) ;
26
30
}
27
-
28
- private filterAliasExport ( doc : ExportDoc ) {
29
- if ( ! doc . moduleDoc ) {
30
- return true ;
31
- }
32
-
33
- const moduleDoc = doc . moduleDoc as ModuleDoc ;
34
- const duplicateDocs = moduleDoc . exports . filter ( exportDoc => exportDoc . id === doc . id ) ;
35
-
36
- // Remove the current export document if there are multiple Dgeni export documents with the
37
- // same document id. If there are multiple docs with the same id, we can assume that this doc
38
- // is an alias export.
39
- if ( duplicateDocs && duplicateDocs . length > 1 ) {
40
- moduleDoc . exports . splice (
41
- moduleDoc . exports . findIndex ( exportDoc => exportDoc . id === doc . id ) , 1 ) ;
42
- return false ;
43
- }
44
-
45
- return true ;
46
- }
47
-
48
31
}
0 commit comments