Skip to content

Commit 20a3116

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 20a3116

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
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/macros.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{% macro deprecationTitle(doc) %}
2-
{%- if doc.breakingChange -%}
3-
title="Will be removed in v{$ doc.breakingChange $} or later"
2+
{%- if doc.breakingChange and doc.deprecatedMessage -%}
3+
deprecated-message="{$ doc.deprecatedMessage $} Will be removed in v{$ doc.breakingChange $} or later."
4+
{% else %}
5+
deprecated-message="{$ doc.deprecatedMessage $}"
46
{%- endif -%}
57
{% 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) $}></div>
119
{%- endif -%}
1210
{%- if method.isStatic -%}
1311
<div class="docs-api-modifier-method-marker">

0 commit comments

Comments
 (0)