Skip to content

Commit f0c693e

Browse files
devversionandrewseguin
authored andcommitted
docs(dgeni): simplify filtering of alias exports (#9893)
Simplifies the processor that filters alias exports. This is now possible with angular/dgeni-packages@f703414
1 parent 4ba0277 commit f0c693e

File tree

1 file changed

+7
-24
lines changed

1 file changed

+7
-24
lines changed
Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
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';
42

53
/**
64
* Processor to filter out Dgeni documents that are export aliases. Keeping them means
@@ -22,27 +20,12 @@ export class FilterExportAliases implements Processor {
2220
$runBefore = ['categorizer'];
2321

2422
$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+
});
2630
}
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-
4831
}

0 commit comments

Comments
 (0)