Skip to content

Commit 9973f1d

Browse files
devversionamysorto
authored andcommitted
build: fix errors due to unknown JSDoc tags in API doc generation
In order to be able to merge class members from extended classes, we currently have some special logic to resolve Dgeni API docs manually through the type checker and TypeScript AST. This logic works fine so far, but breaks the JSDoc parse processor after the recent dgeni-packages update. The JSDoc parser breaks because we resolved external source files (not part of our base path) that use other JSDoc tags/annotations which are not supported/known to our Angular Material docs generation. This commit filters out such docs before adding them to the Dgeni pipeline. Additionally adds a couple of tags/annotations which are not supported by Dgeni, but used in our generation.
1 parent 95ec091 commit 9973f1d

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

tools/dgeni/common/class-inheritance.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import * as ts from 'typescript';
88
import {MemberDoc} from 'dgeni-packages/typescript/api-doc-types/MemberDoc';
99

1010
/** Type describing class like documents which have been created through inheritance. */
11-
export type InheritanceCreatedClassLikeDoc = ClassLikeExportDoc & {_inheritanceCreated?: true};
11+
export type InheritanceCreatedClassLikeDoc = ClassLikeExportDoc & {
12+
_inheritanceCreated?: true;
13+
};
1214

1315
/** Whether the given API doc has been created through inheritance. */
1416
export function isInheritanceCreatedDoc(doc: ApiDoc): doc is ClassLikeExportDoc {

tools/dgeni/docs-package.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ apiDocsPackage.config(function (parseTagsProcessor: any) {
9595
{name: 'docs-public'},
9696
{name: 'docs-primary-export'},
9797
{name: 'breaking-change'},
98+
// Adds support for the `tsdoc` `@template` annotation/tag.
99+
// https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#template.
100+
{name: 'template', multi: true},
101+
// JSDoc annotations/tags which are not supported by default.
102+
{name: 'throws', multi: true},
98103
]);
99104
});
100105

tools/dgeni/processors/resolve-inherited-docs.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ export class ResolveInheritedDocs implements Processor {
4444
if (!isInheritanceCreatedDoc(apiDoc)) {
4545
return;
4646
}
47+
// If this is an external document not part of our sources, we will not add it to the
48+
// Dgeni API doc pipeline. Docs would be filtered regardless, but adding them to the
49+
// pipeline could cause e.g. the JSDoc parser to complain about tags/annotations which
50+
// are not known/relevant to our API docs. e.g. Framework uses `@nodoc` or `@usageNotes`.
51+
if (apiDoc.fileInfo.projectRelativePath.startsWith('../')) {
52+
return;
53+
}
54+
4755
// Add the member docs for the inherited doc to the Dgeni doc collection.
4856
this._getContainingMemberDocs(apiDoc).forEach(d => newDocs.add(d));
4957
// Add the class-like export doc to the Dgeni doc collection.

0 commit comments

Comments
 (0)