diff --git a/tools/dgeni/processors/docs-private-filter.ts b/tools/dgeni/processors/docs-private-filter.ts index 279f41c3037e..c8d00d716975 100644 --- a/tools/dgeni/processors/docs-private-filter.ts +++ b/tools/dgeni/processors/docs-private-filter.ts @@ -9,6 +9,7 @@ import {getDocsPublicTag, isPublicDoc} from '../common/private-docs'; export class DocsPrivateFilter implements Processor { name = 'docs-private-filter'; $runBefore = ['categorizer']; + $runAfter = ['merge-inherited-properties']; $process(docs: DocCollection) { return docs.filter(doc => { diff --git a/tools/dgeni/processors/merge-inherited-properties.ts b/tools/dgeni/processors/merge-inherited-properties.ts index 6925cf5356f3..429e35b059db 100644 --- a/tools/dgeni/processors/merge-inherited-properties.ts +++ b/tools/dgeni/processors/merge-inherited-properties.ts @@ -1,5 +1,6 @@ import {DocCollection, Processor} from 'dgeni'; import {ClassExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassExportDoc'; +import {ClassLikeExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassLikeExportDoc'; import {MemberDoc} from 'dgeni-packages/typescript/api-doc-types/MemberDoc'; /** @@ -11,18 +12,30 @@ export class MergeInheritedProperties implements Processor { $runBefore = ['categorizer']; $process(docs: DocCollection) { - return docs - .filter(doc => doc.docType === 'class') - .forEach(doc => this._addInheritedProperties(doc)); + return docs.filter(doc => doc.docType === 'class') + .forEach(doc => this._addInheritedProperties(doc)); } - private _addInheritedProperties(doc: ClassExportDoc) { - doc.implementsClauses.filter(clause => clause.doc).forEach(clause => { - clause.doc!.members.forEach(member => this._addMemberDocIfNotPresent(doc, member)); - }); + /** Gets all class like export documents which the given doc inherits from. */ + private _getBaseDocuments(doc: ClassLikeExportDoc): ClassLikeExportDoc[] { + const directBaseDocs = [ + ...doc.implementsClauses.filter(clause => clause.doc).map(d => d.doc!), + ...doc.extendsClauses.filter(clause => clause.doc).map(d => d.doc!), + ]; - doc.extendsClauses.filter(clause => clause.doc).forEach(clause => { - clause.doc!.members.forEach(member => this._addMemberDocIfNotPresent(doc, member)); + return [ + ...directBaseDocs, + // recursively collect base documents of direct base documents. + ...directBaseDocs.reduce( + (res: ClassLikeExportDoc[], d) => res.concat(this._getBaseDocuments(d)), []), + ]; + } + + private _addInheritedProperties(doc: ClassExportDoc) { + // Note that we need to get check all base documents. We cannot assume + // that directive base documents already have merged inherited members. + this._getBaseDocuments(doc).forEach(d => { + d.members.forEach(member => this._addMemberDocIfNotPresent(doc, member)); }); }