Skip to content

build: update dgeni packages #10144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"axe-webdriverjs": "^1.1.1",
"chalk": "^1.1.3",
"dgeni": "^0.4.9",
"dgeni-packages": "^0.24.1",
"dgeni-packages": "^0.24.3",
"firebase": "^4.0.0",
"firebase-admin": "^5.0.0",
"firebase-tools": "^3.11.0",
Expand Down
4 changes: 0 additions & 4 deletions tools/dgeni/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {patchLogService} from './patch-log-service';
import {DocsPrivateFilter} from './processors/docs-private-filter';
import {Categorizer} from './processors/categorizer';
import {FilterDuplicateExports} from './processors/filter-duplicate-exports';
import {FilterExportAliases} from './processors/filter-export-aliases';
import {MergeInheritedProperties} from './processors/merge-inherited-properties';
import {ComponentGrouper} from './processors/component-grouper';
import {ReadTypeScriptModules} from 'dgeni-packages/typescript/processors/readTypeScriptModules';
Expand Down Expand Up @@ -53,9 +52,6 @@ export const apiDocsPackage = new Package('material2-api-docs', [
// Processor that filters out duplicate exports that should not be shown in the docs.
apiDocsPackage.processor(new FilterDuplicateExports());

// Processor that filters out aliased exports that should not be shown in the docs.
apiDocsPackage.processor(new FilterExportAliases());

// Processor that merges inherited properties of a class with the class doc.
apiDocsPackage.processor(new MergeInheritedProperties());

Expand Down
56 changes: 39 additions & 17 deletions tools/dgeni/processors/filter-duplicate-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,58 @@ import {ExportDoc} from 'dgeni-packages/typescript/api-doc-types/ExportDoc';
*
* ```ts
* // Some file in @angular/cdk/scrolling
* export {ScrollDispatcher} from './scroll-dispatcher.ts';
* export {ScrollDispatcher} from './scroll-dispatcher';
*
* // Other file in @angular/cdk/overlay
* export {ScrollDispatcher} from '@angular/cdk/scrolling';
*
* // Re-export of the same export with a different name (alias).
* export {ScrollDispatcher as X} from './scroll-dispatcher';
* ```
*
* This issue occurs sometimes in the Angular Material repository, if specific imports are
* re-exported from a different secondary entry-point (e.g. ScrollDispatcher in the overlay).
* This issue occurs sometimes in the Angular Material repository, because some imports are
* re-exported with a different name (for deprecation), or from a different secondary entry-point.
*/
export class FilterDuplicateExports implements Processor {
name = 'filter-duplicate-exports';
$runBefore = ['filter-export-aliases'];
$runBefore = ['categorizer'];

$process(docs: DocCollection) {
return docs.forEach(this.checkForDuplicateExports);
const duplicateDocs = this.findDuplicateExports(docs);
return docs.filter(d => !duplicateDocs.has(d));
}

checkForDuplicateExports = (doc: ExportDoc, index: number, docs: DocCollection) => {
if (!(doc instanceof ExportDoc)) {
return;
}
findDuplicateExports(docs: DocCollection) {
const duplicates = new Set<ExportDoc>();

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

if (duplicateDocs.length > 0) {
docs.splice(index, 1);
}
}
// Check for Dgeni documents that refer to the same TypeScript symbol. Those can be
// considered as duplicates of the current document.
const similarDocs = docs.filter(d => d.symbol === doc.symbol);

if (similarDocs.length > 1) {
// If there are multiple docs that refer to the same TypeScript symbol, but have a
// different name than the resolved symbol, we can remove those documents, since they
// are just aliasing an already existing export.
similarDocs
.filter(d => d.symbol.name !== d.name)
.forEach(d => duplicates.add(d));

const docsWithSameName = similarDocs
.filter(d => d.symbol.name === d.name);

// If there are multiple docs that refer to the same TypeScript symbol and have
// the same name, we need to remove all of those duplicates except one.
if (docsWithSameName.length > 1) {
docsWithSameName.slice(1).forEach(d => duplicates.add(d));
}
}
});

return duplicates;
}
}
31 changes: 0 additions & 31 deletions tools/dgeni/processors/filter-export-aliases.ts

This file was deleted.