Skip to content

chore(docs): show extends clauses for classes #8078

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 2 commits into from
Oct 28, 2017
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
7 changes: 7 additions & 0 deletions tools/dgeni/processors/categorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
isProperty,
isService
} from '../common/decorators';
import {ClassLikeExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassLikeExportDoc';
import {MethodMemberDoc} from 'dgeni-packages/typescript/api-doc-types/MethodMemberDoc';
import {sortCategorizedMembers} from '../common/sort-members';

Expand All @@ -31,6 +32,7 @@ export interface CategorizedClassDoc extends ClassExportDoc {
isDeprecated: boolean;
directiveExportAs?: string | null;
directiveSelectors?: string[];
extendedDoc: ClassLikeExportDoc | null;
}

export interface CategorizedPropertyMemberDoc extends PropertyMemberDoc {
Expand Down Expand Up @@ -88,6 +90,11 @@ export class Categorizer implements Processor {
classDoc.methods.sort(sortCategorizedMembers);
classDoc.properties.sort(sortCategorizedMembers);

// Classes can only extend a single class. This means that there can't be multiple extend
// clauses for the Dgeni document. To make the template syntax simpler and more readable,
// store the extended class in a variable.
classDoc.extendedDoc = classDoc.extendsClauses[0] ? classDoc.extendsClauses[0].doc! : null;

// Categorize the current visited classDoc into its Angular type.
if (isDirective(classDoc)) {
classDoc.isDirective = true;
Expand Down
6 changes: 6 additions & 0 deletions tools/dgeni/templates/class.template.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<h4 class="docs-api-h4 docs-api-class-name">
<code>{$ class.name $}</code>
{% if class.extendedDoc %}
<span class="docs-api-class-extends-clauses">
<span class="docs-api-class-extends-label">extends</span>
<span class="docs-api-class-extends-type">{$ class.extendedDoc.name $}</span>
</span>
{% endif %}
</h4>

{%- if class.description -%}
Expand Down