Skip to content

Commit ce6c0e8

Browse files
committed
build: update dgeni templates to include deprecated tag description
changes how deprecated fields are generated for docs content, before this commit deprecated related text was shown via `title` attribute on hover and the `deprecated` tag description was never shown unless user check it manually via code. this commit exports `deprecated` tag description to reflect it directly in docs using `material/tooltip` on doc site
1 parent 371446a commit ce6c0e8

File tree

9 files changed

+25
-25
lines changed

9 files changed

+25
-25
lines changed

tools/dgeni/common/decorators.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,19 @@ export function getBreakingChange(doc: ApiDoc): string | null {
8585
return breakingChange ? breakingChange.description : null;
8686
}
8787

88+
export function getDeprecationMessage(doc: ApiDoc): string | null {
89+
const deprecatedMessage = findJsDocTag(doc, 'deprecated');
90+
return deprecatedMessage ? deprecatedMessage.description : null;
91+
}
92+
8893
/**
8994
* Decorates public exposed docs. Creates a property on the doc that indicates whether
90-
* the item is deprecated or not.
95+
* the item is deprecated or not and set deprecation message.
9196
*/
9297
export function decorateDeprecatedDoc(doc: ApiDoc & DeprecationInfo) {
9398
doc.isDeprecated = isDeprecatedDoc(doc);
9499
doc.breakingChange = getBreakingChange(doc);
100+
doc.deprecatedMessage = getDeprecationMessage(doc);
95101

96102
if (doc.isDeprecated && !doc.breakingChange) {
97103
console.warn('Warning: There is a deprecated item without a @breaking-change tag.', doc.id);

tools/dgeni/common/dgeni-definitions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {NormalizedFunctionParameters} from './normalize-function-parameters';
1212
export interface DeprecationInfo {
1313
isDeprecated: boolean;
1414
breakingChange: string | null;
15+
deprecatedMessage: string | null;
1516
}
1617

1718
/** Interface that describes Dgeni documents that have decorators. */

tools/dgeni/templates/class.template.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
{% import "macros.html" as macros %}
22

33
<h4 id="{$ class.name $}" class="docs-header-link docs-api-h4 docs-api-class-name">
4+
{%- if class.isDeprecated -%}
5+
<span header-link="{$ class.name $}"></span>
6+
<code class="docs-api-class-deprecated-marker" {$ macros.deprecationTitle(class, class.name) $}></code>
7+
{% else %}
48
<span header-link="{$ class.name $}"></span>
59
<code>{$ class.name $}</code>
10+
{%- endif -%}
611
{% if class.extendedDoc %}
712
<span class="docs-api-class-extends-clauses">
813
<span class="docs-api-class-extends-label">extends</span>
@@ -31,12 +36,6 @@ <h4 id="{$ class.name $}" class="docs-header-link docs-api-h4 docs-api-class-nam
3136
<span class="docs-api-class-export-name">{$ class.directiveExportAs $}</span>
3237
{%- endif -%}
3338

34-
{%- if class.isDeprecated -%}
35-
<div class="docs-api-class-deprecated-marker" {$ macros.deprecationTitle(class) $}>
36-
Deprecated
37-
</div>
38-
{%- endif -%}
39-
4039
{$ propertyList(class.properties) $}
4140

4241
{$ methodList(class.methods) $}

tools/dgeni/templates/constant.template.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ <h4 id="{$ constant.name $}" class="docs-header-link docs-api-h4 docs-api-consta
66
</h4>
77

88
{%- if constant.isDeprecated -%}
9-
<div class="docs-api-constant-deprecated-marker" {$ macros.deprecationTitle(constant) $}>
10-
Deprecated
11-
</div>
9+
<div class="docs-api-constant-deprecated-marker" {$ macros.deprecationTitle(constant, "Deprecated") $}></div>
1210
{%- endif -%}
1311

1412
{%- if constant.description -%}

tools/dgeni/templates/interface.template.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ <h4 id="{$ interface.name $}" class="docs-header-link docs-api-h4 docs-api-inter
1010
{%- endif -%}
1111

1212
{%- if interface.isDeprecated -%}
13-
<div class="docs-api-interface-deprecated-marker" {$ macros.deprecationTitle(interface) $}>
14-
Deprecated
15-
</div>
13+
<div class="docs-api-interface-deprecated-marker" {$ macros.deprecationTitle(interface, "Deprecated") $}></div>
1614
{%- endif -%}
1715

1816
{$ propertyList(interface.properties) $}

tools/dgeni/templates/macros.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
{% macro deprecationTitle(doc) %}
2-
{%- if doc.breakingChange -%}
3-
title="Will be removed in v{$ doc.breakingChange $} or later"
1+
{% macro deprecationTitle(doc, innerText) %}
2+
{%- if doc.breakingChange and doc.deprecatedMessage -%}
3+
depreciation-title="{$ doc.deprecatedMessage $} Will be removed in v{$ doc.breakingChange $} or later."
4+
inner-text="{$ innerText $}"
5+
{% else %}
6+
depreciation-title="{$ doc.deprecatedMessage $}"
7+
inner-text="{$ innerText $}"
48
{%- endif -%}
59
{% endmacro %}

tools/dgeni/templates/method.template.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
<tr class="docs-api-method-name-row">
66
<th colspan="2" class="docs-api-method-name-cell">
77
{%- if method.isDeprecated -%}
8-
<div class="docs-api-deprecated-marker" {$ macros.deprecationTitle(method) $}>
9-
Deprecated
10-
</div>
8+
<div class="docs-api-deprecated-marker" {$ macros.deprecationTitle(method, "Deprecated") $}></div>
119
{%- endif -%}
1210
{%- if method.isStatic -%}
1311
<div class="docs-api-modifier-method-marker">

tools/dgeni/templates/property.template.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
</div>
2222
{%- endif -%}
2323
{%- if property.isDeprecated -%}
24-
<div class="docs-api-deprecated-marker" {$ macros.deprecationTitle(property) $}>
25-
Deprecated
26-
</div>
24+
<div class="docs-api-deprecated-marker" {$ macros.deprecationTitle(property, "Deprecated") $}></div>
2725
{%- endif -%}
2826

2927
<p class="docs-api-property-name">

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ <h4 id="{$ alias.name $}" class="docs-header-link docs-api-h4 docs-api-type-alia
66
</h4>
77

88
{%- if alias.isDeprecated -%}
9-
<div class="docs-api-type-alias-deprecated-marker" {$ macros.deprecationTitle(alias) $}>
10-
Deprecated
11-
</div>
9+
<div class="docs-api-type-alias-deprecated-marker" {$ macros.deprecationTitle(alias, "Deprecated") $}></div>
1210
{%- endif -%}
1311

1412
{%- if alias.description -%}

0 commit comments

Comments
 (0)