Skip to content

Commit 5d794b1

Browse files
committed
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.
1 parent c38c9c3 commit 5d794b1

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

tools/dgeni/processors/categorizer.js

Lines changed: 20 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,25 @@ 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 with CSS classes that will be
72+
* added to the template.
73+
**/
74+
function decoratePublicDoc(doc) {
75+
// Specific classes that will can added to the Dgeni doc template.
76+
doc.docClasses = [
77+
isDeprecatedDoc(doc) ? 'docs-api-deprecated' : ''
78+
].join(' ');
79+
}
6480
};
6581

6682
/** Function that walks through all inherited docs and collects public methods. */
@@ -146,6 +162,10 @@ function isDirectiveInput(doc) {
146162
return hasMemberDecorator(doc, 'Input');
147163
}
148164

165+
function isDeprecatedDoc(doc) {
166+
return (doc.tags && doc.tags.tags || []).some(tag => tag.tagName === 'deprecated');
167+
}
168+
149169
function getDirectiveInputAlias(doc) {
150170
return isDirectiveInput(doc) ? doc.decorators.find(d => d.name == 'Input').arguments[0] : '';
151171
}
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
<h4 class="docs-api-h4 docs-api-class-name">
2-
<code>{$ class.name $}</code>
3-
</h4>
4-
<p class="docs-api-class-description">{$ class.description $}</p>
1+
<div class="{$ class.docClasses $}">
2+
<h4 class="docs-api-h4 docs-api-class-name">
3+
<code>{$ class.name $}</code>
4+
</h4>
5+
<p class="docs-api-class-description">{$ class.description $}</p>
56

6-
{%- if class.directiveExportAs -%}
7-
<span class="docs-api-h4 docs-api-class-export-label">Exported as:</span>
8-
<span class="docs-api-class-export-name">{$ class.directiveExportAs $}</span>
9-
{%- endif -%}
7+
{%- if class.directiveExportAs -%}
8+
<span class="docs-api-h4 docs-api-class-export-label">Exported as:</span>
9+
<span class="docs-api-class-export-name">{$ class.directiveExportAs $}</span>
10+
{%- endif -%}
1011

11-
{$ propertyList(class.properties) $}
12+
{$ propertyList(class.properties) $}
1213

13-
{$ methodList(class.methods) $}
14+
{$ methodList(class.methods) $}
15+
</div>

tools/dgeni/templates/method.template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<table class="docs-api-method-table">
1+
<table class="docs-api-method-table {$ method.docClasses $}">
22
<thead>
33
<tr class="docs-api-method-name-row">
44
<th colspan="2" class="docs-api-method-name-cell">{$ method.name $}</th>

tools/dgeni/templates/property.template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<tr class="docs-api-properties-row">
1+
<tr class="docs-api-properties-row {$ property.docClasses $}">
22
<td class="docs-api-properties-name-cell">
33
{%- if property.isDirectiveInput -%}
44
<div class="docs-api-input-marker">

0 commit comments

Comments
 (0)