Skip to content

docs: incorrect descriptions for inherited class members #22766

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
May 24, 2021
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
1 change: 1 addition & 0 deletions tools/dgeni/common/dgeni-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface CategorizedClassDoc extends ClassExportDoc, CategorizedClassLik

/** Extended Dgeni property-member document that includes extracted Angular metadata. */
export interface CategorizedPropertyMemberDoc extends PropertyMemberDoc, DeprecationInfo {
description: string;
isDirectiveInput: boolean;
isDirectiveOutput: boolean;
directiveInputAlias: string;
Expand Down
12 changes: 12 additions & 0 deletions tools/dgeni/processors/merge-inherited-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,20 @@ export class MergeInheritedProperties implements Processor {
// by using an instance comparison.
// tslint:disable-next-line:ban Need to use Object.assign to preserve the prototype.
const newMemberDoc = Object.assign(Object.create(memberDoc), memberDoc);

// Dgeni won't add the `description` if the member doc belongs to a class
// that isn't exported. If that's the case, we fall back to assigning it
// ourselves by stripping JSDoc tags from the raw description.
// TODO: figure out a more robust solution that will ensure that the description is
// always added.
newMemberDoc.description = newMemberDoc.description || stripJsDocTags(memberDoc.content);
newMemberDoc.containerDoc = destination;
destination.members.push(newMemberDoc);
}
}
}

/** Strips all of the content after the first JSDoc tag from a string. */
function stripJsDocTags(text: string): string {
return text.split(/\s@[a-zA-Z-]*\s/)[0];
}
4 changes: 2 additions & 2 deletions tools/dgeni/templates/method.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
</th>
</tr>
</thead>
{%- if method.content -%}
{%- if method.description -%}
<tr class="docs-api-method-description-row">
<td colspan="2" class="docs-api-method-description-cell">
{$ method.content | marked | safe $}
{$ method.description | marked | safe $}
</td>
</tr>
{%- endif -%}
Expand Down
2 changes: 1 addition & 1 deletion tools/dgeni/templates/property.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
<code>{$ property.name $}: {$ property.type $}</code>
</p>
</td>
<td class="docs-api-property-description">{$ property.content | marked | safe $}</td>
<td class="docs-api-property-description">{$ property.description | marked | safe $}</td>
</tr>