Skip to content

Commit b5f15ad

Browse files
devversionjelbourn
authored andcommitted
build: dgeni add deprecated marker (#4028)
* build: dgeni add deprecated marker * Adds a class to property rows in the template that can be used to distinguish between deprecated and stable APIs. Fixes #3981. * Address feedback
1 parent 85391ca commit b5f15ad

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

tools/dgeni/processors/categorizer.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ module.exports = function categorizer() {
2828
classDoc.methods.forEach(doc => decorateMethodDoc(doc));
2929
classDoc.properties.forEach(doc => decoratePropertyDoc(doc));
3030

31+
decoratePublicDoc(classDoc);
32+
3133
// Categorize the current visited classDoc into its Angular type.
3234
if (isDirective(classDoc)) {
3335
classDoc.isDirective = true;
@@ -45,6 +47,7 @@ module.exports = function categorizer() {
4547
*/
4648
function decorateMethodDoc(methodDoc) {
4749
normalizeMethodParameters(methodDoc);
50+
decoratePublicDoc(methodDoc);
4851

4952
// Mark methods with a `void` return type so we can omit show the return type in the docs.
5053
methodDoc.showReturns = methodDoc.returnType && methodDoc.returnType != 'void';
@@ -55,12 +58,22 @@ module.exports = function categorizer() {
5558
* outputs will be marked. Aliases for the inputs or outputs will be stored as well.
5659
*/
5760
function decoratePropertyDoc(propertyDoc) {
61+
decoratePublicDoc(propertyDoc);
62+
5863
propertyDoc.isDirectiveInput = isDirectiveInput(propertyDoc);
5964
propertyDoc.directiveInputAlias = getDirectiveInputAlias(propertyDoc);
6065

6166
propertyDoc.isDirectiveOutput = isDirectiveOutput(propertyDoc);
6267
propertyDoc.directiveOutputAlias = getDirectiveOutputAlias(propertyDoc);
6368
}
69+
70+
/**
71+
* Decorates public exposed docs. Creates a property on the doc that indicates whether
72+
* the item is deprecated or not.
73+
**/
74+
function decoratePublicDoc(doc) {
75+
doc.isDeprecated = isDeprecatedDoc(doc);
76+
}
6477
};
6578

6679
/** Function that walks through all inherited docs and collects public methods. */
@@ -146,6 +159,10 @@ function isDirectiveInput(doc) {
146159
return hasMemberDecorator(doc, 'Input');
147160
}
148161

162+
function isDeprecatedDoc(doc) {
163+
return (doc.tags && doc.tags.tags || []).some(tag => tag.tagName === 'deprecated');
164+
}
165+
149166
function getDirectiveInputAlias(doc) {
150167
return isDirectiveInput(doc) ? doc.decorators.find(d => d.name == 'Input').arguments[0] : '';
151168
}

tools/dgeni/templates/class.template.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ <h4 class="docs-api-h4 docs-api-class-name">
88
<span class="docs-api-class-export-name">{$ class.directiveExportAs $}</span>
99
{%- endif -%}
1010

11+
{%- if class.isDeprecated -%}
12+
<div class="docs-api-class-deprecated-marker">Deprecated</div>
13+
{%- endif -%}
14+
1115
{$ propertyList(class.properties) $}
1216

1317
{$ methodList(class.methods) $}

tools/dgeni/templates/method.template.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
<table class="docs-api-method-table">
22
<thead>
33
<tr class="docs-api-method-name-row">
4-
<th colspan="2" class="docs-api-method-name-cell">{$ method.name $}</th>
4+
<th colspan="2" class="docs-api-method-name-cell">
5+
{%- if method.isDeprecated -%}
6+
<div class="docs-api-deprecated-marker">Deprecated</div>
7+
{%- endif -%}
8+
{$ method.name $}
9+
</th>
510
</tr>
611
</thead>
712
<tr class="docs-api-method-description-row">

tools/dgeni/templates/property.template.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
{%- endif -%}
1919
</div>
2020
{%- endif -%}
21+
{%- if property.isDeprecated -%}
22+
<div class="docs-api-deprecated-marker">Deprecated</div>
23+
{%- endif -%}
2124

2225
<p class="docs-api-property-name">
2326
{$ property.name $}

0 commit comments

Comments
 (0)