Skip to content

Commit e21015d

Browse files
devversiontinayuangao
authored andcommitted
build: update dgeni packages (#10144)
* Updates dgeni-packages to the latest version (to include angular/dgeni-packages#262) * Cleans up the logic for removing duplicate exports and aliases from Dgeni. Right now, it can happen that parameter Dgeni docs are being filtered out.
1 parent e51fc4e commit e21015d

File tree

4 files changed

+40
-53
lines changed

4 files changed

+40
-53
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"axe-webdriverjs": "^1.1.1",
6565
"chalk": "^1.1.3",
6666
"dgeni": "^0.4.9",
67-
"dgeni-packages": "^0.24.1",
67+
"dgeni-packages": "^0.24.3",
6868
"firebase": "^4.0.0",
6969
"firebase-admin": "^5.0.0",
7070
"firebase-tools": "^3.11.0",

tools/dgeni/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {patchLogService} from './patch-log-service';
33
import {DocsPrivateFilter} from './processors/docs-private-filter';
44
import {Categorizer} from './processors/categorizer';
55
import {FilterDuplicateExports} from './processors/filter-duplicate-exports';
6-
import {FilterExportAliases} from './processors/filter-export-aliases';
76
import {MergeInheritedProperties} from './processors/merge-inherited-properties';
87
import {ComponentGrouper} from './processors/component-grouper';
98
import {ReadTypeScriptModules} from 'dgeni-packages/typescript/processors/readTypeScriptModules';
@@ -53,9 +52,6 @@ export const apiDocsPackage = new Package('material2-api-docs', [
5352
// Processor that filters out duplicate exports that should not be shown in the docs.
5453
apiDocsPackage.processor(new FilterDuplicateExports());
5554

56-
// Processor that filters out aliased exports that should not be shown in the docs.
57-
apiDocsPackage.processor(new FilterExportAliases());
58-
5955
// Processor that merges inherited properties of a class with the class doc.
6056
apiDocsPackage.processor(new MergeInheritedProperties());
6157

tools/dgeni/processors/filter-duplicate-exports.ts

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,58 @@ import {ExportDoc} from 'dgeni-packages/typescript/api-doc-types/ExportDoc';
77
*
88
* ```ts
99
* // Some file in @angular/cdk/scrolling
10-
* export {ScrollDispatcher} from './scroll-dispatcher.ts';
10+
* export {ScrollDispatcher} from './scroll-dispatcher';
1111
*
1212
* // Other file in @angular/cdk/overlay
1313
* export {ScrollDispatcher} from '@angular/cdk/scrolling';
14+
*
15+
* // Re-export of the same export with a different name (alias).
16+
* export {ScrollDispatcher as X} from './scroll-dispatcher';
1417
* ```
1518
*
16-
* This issue occurs sometimes in the Angular Material repository, if specific imports are
17-
* re-exported from a different secondary entry-point (e.g. ScrollDispatcher in the overlay).
19+
* This issue occurs sometimes in the Angular Material repository, because some imports are
20+
* re-exported with a different name (for deprecation), or from a different secondary entry-point.
1821
*/
1922
export class FilterDuplicateExports implements Processor {
2023
name = 'filter-duplicate-exports';
21-
$runBefore = ['filter-export-aliases'];
24+
$runBefore = ['categorizer'];
2225

2326
$process(docs: DocCollection) {
24-
return docs.forEach(this.checkForDuplicateExports);
27+
const duplicateDocs = this.findDuplicateExports(docs);
28+
return docs.filter(d => !duplicateDocs.has(d));
2529
}
2630

27-
checkForDuplicateExports = (doc: ExportDoc, index: number, docs: DocCollection) => {
28-
if (!(doc instanceof ExportDoc)) {
29-
return;
30-
}
31+
findDuplicateExports(docs: DocCollection) {
32+
const duplicates = new Set<ExportDoc>();
3133

32-
// Checks for export documents that have the same name, originate from the same module, but
33-
// have a different Dgeni document id. Those documents can be considered as duplicates.
34-
const duplicateDocs = docs.filter(d => doc.name === d.name &&
35-
doc.originalModule === d.originalModule && doc.id !== d.id);
34+
docs.forEach(doc => {
35+
if (!(doc instanceof ExportDoc)) {
36+
return;
37+
}
3638

37-
if (duplicateDocs.length > 0) {
38-
docs.splice(index, 1);
39-
}
40-
}
39+
// Check for Dgeni documents that refer to the same TypeScript symbol. Those can be
40+
// considered as duplicates of the current document.
41+
const similarDocs = docs.filter(d => d.symbol === doc.symbol);
42+
43+
if (similarDocs.length > 1) {
44+
// If there are multiple docs that refer to the same TypeScript symbol, but have a
45+
// different name than the resolved symbol, we can remove those documents, since they
46+
// are just aliasing an already existing export.
47+
similarDocs
48+
.filter(d => d.symbol.name !== d.name)
49+
.forEach(d => duplicates.add(d));
4150

51+
const docsWithSameName = similarDocs
52+
.filter(d => d.symbol.name === d.name);
53+
54+
// If there are multiple docs that refer to the same TypeScript symbol and have
55+
// the same name, we need to remove all of those duplicates except one.
56+
if (docsWithSameName.length > 1) {
57+
docsWithSameName.slice(1).forEach(d => duplicates.add(d));
58+
}
59+
}
60+
});
61+
62+
return duplicates;
63+
}
4264
}

tools/dgeni/processors/filter-export-aliases.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)