Skip to content

Commit 321c01d

Browse files
devversionvivian-hu-zz
authored andcommitted
build(docs): deprecated state of type alias not showing up (#13449)
* Currently if a type alias is marked as `@deprecated`, we don't add an indication as for the constants. Now a similar indication will be added if a type alias is deprecated. * Similarly to the constants and `angular.io`, we will display the actual type of the `type-alias` in a better-looking & more clear way. * Also fixes that the constant code "overview" does not include the trailing semicolon (Angular.io also adds a trailing semicolon)
1 parent b8c1024 commit 321c01d

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

tools/dgeni/common/dgeni-definitions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {ClassExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassExpor
33
import {ClassLikeExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassLikeExportDoc';
44
import {ConstExportDoc} from 'dgeni-packages/typescript/api-doc-types/ConstExportDoc';
55
import {PropertyMemberDoc} from 'dgeni-packages/typescript/api-doc-types/PropertyMemberDoc';
6+
import {TypeAliasExportDoc} from 'dgeni-packages/typescript/api-doc-types/TypeAliasExportDoc';
67
import {ParsedDecorator} from 'dgeni-packages/typescript/services/TsParser/getDecorators';
78
import {FunctionExportDoc} from 'dgeni-packages/typescript/api-doc-types/FunctionExportDoc';
89
import {MethodMemberDoc} from 'dgeni-packages/typescript/api-doc-types/MethodMemberDoc';
@@ -55,3 +56,6 @@ export interface CategorizedFunctionExportDoc
5556

5657
/** Extended Dgeni const export document that simplifies logic for the Dgeni template. */
5758
export interface CategorizedConstExportDoc extends ConstExportDoc, DeprecationDoc {}
59+
60+
/** Extended Dgeni type alias document that includes more information when rendering. */
61+
export interface CategorizedTypeAliasExportDoc extends TypeAliasExportDoc, DeprecationDoc {}

tools/dgeni/processors/categorizer.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
CategorizedFunctionExportDoc,
1717
CategorizedMethodMemberDoc,
1818
CategorizedPropertyMemberDoc,
19+
CategorizedTypeAliasExportDoc,
1920
} from '../common/dgeni-definitions';
2021
import {getDirectiveMetadata} from '../common/directive-metadata';
2122
import {normalizeFunctionParameters} from '../common/normalize-function-parameters';
@@ -47,6 +48,10 @@ export class Categorizer implements Processor {
4748
docs
4849
.filter(doc => doc.docType === 'const')
4950
.forEach(doc => this.decorateConstExportDoc(doc));
51+
52+
docs
53+
.filter(doc => doc.docType === 'type-alias')
54+
.forEach(doc => this.decorateTypeAliasExportDoc(doc));
5055
}
5156

5257
/**
@@ -130,6 +135,14 @@ export class Categorizer implements Processor {
130135
decorateDeprecatedDoc(doc);
131136
}
132137

138+
/**
139+
* Method that will be called for each type-alias export document. We decorate the type-alias
140+
* documents with a property that states whether the type-alias is deprecated or not.
141+
*/
142+
private decorateTypeAliasExportDoc(doc: CategorizedTypeAliasExportDoc) {
143+
decorateDeprecatedDoc(doc);
144+
}
145+
133146
/**
134147
* Method that will be called for each property doc. Properties that are Angular inputs or
135148
* outputs will be marked. Aliases for the inputs or outputs will be stored as well.

tools/dgeni/templates/constant.template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ <h4 id="{$ constant.name $}" class="docs-header-link docs-api-h4 docs-api-consta
1818
<pre class="docs-markdown-pre">
1919
<code class="docs-markdown-code">
2020
{%- highlight "typescript" -%}
21-
const {$ constant.name | safe $}: {$ constant.type | safe $}
21+
const {$ constant.name | safe $}: {$ constant.type | safe $};
2222
{%- end_highlight -%}
2323
</code>
2424
</pre>

tools/dgeni/templates/type-alias.template.html

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,20 @@ <h4 id="{$ alias.name $}" class="docs-header-link docs-api-h4 docs-api-type-alia
55
<code>{$ alias.name $}</code>
66
</h4>
77

8+
{%- if alias.isDeprecated -%}
9+
<div class="docs-api-type-alias-deprecated-marker" {$ macros.deprecationTitle(alias) $}>
10+
Deprecated
11+
</div>
12+
{%- endif -%}
13+
814
{%- if alias.description -%}
915
<p class="docs-api-type-alias-description">{$ alias.description | marked | safe $}</p>
1016
{%- endif -%}
1117

12-
<p class="docs-api-type-alias-value">
13-
<span class="docs-api-type-alias-value-label">Type:</span>
14-
<code class="docs-api-type-alias-value">{$ alias.typeDefinition $}</code>
15-
</p>
18+
<pre class="docs-markdown-pre">
19+
<code class="docs-markdown-code">
20+
{%- highlight "typescript" -%}
21+
type {$ alias.name | safe $} = {$ alias.typeDefinition | safe $};
22+
{%- end_highlight -%}
23+
</code>
24+
</pre>

0 commit comments

Comments
 (0)