Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 6855c4f

Browse files
chore(docs): deprecation notices for methods and properties
Closes #15351 Closes #15394
1 parent 75938d6 commit 6855c4f

16 files changed

+163
-140
lines changed

docs/app/assets/css/docs.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,11 @@ ul.events > li {
662662
max-width: 100%;
663663
}
664664

665+
.deprecation .title {
666+
float: left;
667+
margin-right: 5px;
668+
}
669+
665670
@media only screen and (min-width: 769px) {
666671
[ng-include="partialPath"].ng-hide {
667672
display: block !important;

docs/config/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ module.exports = new Package('angularjs', [
5252

5353

5454
.config(function(parseTagsProcessor) {
55+
parseTagsProcessor.tagDefinitions.push(require('./tag-defs/deprecated')); // this will override the jsdoc version
5556
parseTagsProcessor.tagDefinitions.push(require('./tag-defs/tutorial-step'));
5657
parseTagsProcessor.tagDefinitions.push(require('./tag-defs/sortOrder'));
5758
parseTagsProcessor.tagDefinitions.push(require('./tag-defs/installation'));
5859
parseTagsProcessor.tagDefinitions.push(require('./tag-defs/this'));
60+
5961
})
6062

6163

@@ -69,7 +71,6 @@ module.exports = new Package('angularjs', [
6971
templateFinder.templateFolders.length = 0;
7072
templateFinder.templateFolders.unshift(path.resolve(packagePath, 'templates/examples'));
7173
templateFinder.templateFolders.unshift(path.resolve(packagePath, 'templates/ngdoc'));
72-
templateFinder.templateFolders.unshift(path.resolve(packagePath, 'templates/git'));
7374
templateFinder.templateFolders.unshift(path.resolve(packagePath, 'templates/app'));
7475
renderDocsProcessor.extraData.git = gitData;
7576
})

docs/config/tag-defs/deprecated.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
'use strict';
2+
3+
var OPTION_MATCHER = /^\s*([\w-]+)="([^"]+)"\s+([\s\S]*)/;
4+
var VALID_OPTIONS = ['sinceVersion', 'removeVersion'];
5+
6+
module.exports = {
7+
name: 'deprecated',
8+
transforms: function(doc, tag, value) {
9+
var result = {};
10+
var invalidOptions = [];
11+
value = value.trim();
12+
while (OPTION_MATCHER.test(value)) {
13+
value = value.replace(OPTION_MATCHER, function(_, key, value, rest) {
14+
if (VALID_OPTIONS.indexOf(key) !== -1) {
15+
result[key] = value;
16+
} else {
17+
invalidOptions.push(key);
18+
}
19+
return rest;
20+
});
21+
}
22+
if (invalidOptions.length > 0) {
23+
throw new Error('Invalid options: ' + humanList(invalidOptions) + '. Value options are: ' + humanList(VALID_OPTIONS));
24+
}
25+
result.description = value;
26+
return result;
27+
}
28+
};
29+
30+
function humanList(values, sep, lastSep) {
31+
if (sep === undefined) sep = ', ';
32+
if (lastSep === undefined) lastSep = ' and ';
33+
34+
return values.reduce(function(output, value, index, list) {
35+
output += '"' + value + '"';
36+
switch (list.length - index) {
37+
case 1: return output;
38+
case 2: return output + lastSep;
39+
default: return output + sep;
40+
}
41+
}, '');
42+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'use strict';
2+
3+
/* globals describe, it, expect */
4+
var tagDef = require('./deprecated');
5+
6+
describe('deprecated tag', function() {
7+
describe('transforms', function() {
8+
it('should return the trimmed value if no options', function() {
9+
var tag = tagDef.transforms({}, {}, 'This is the description');
10+
expect(tag.description).toEqual('This is the description');
11+
});
12+
13+
it('should read options', function() {
14+
var tag = tagDef.transforms({}, {}, ' sinceVersion="v1.3.4" removeVersion="v1.4.5" what is left is description');
15+
expect(tag.description).toEqual('what is left is description');
16+
expect(tag.sinceVersion).toEqual('v1.3.4');
17+
expect(tag.removeVersion).toEqual('v1.4.5');
18+
});
19+
20+
it('should cope with carriage returns', function() {
21+
var tag = tagDef.transforms({}, {}, '\nsinceVersion="v1.3.4"\nremoveVersion="v1.4.5"\nwhat is left is description');
22+
expect(tag.description).toEqual('what is left is description');
23+
expect(tag.sinceVersion).toEqual('v1.3.4');
24+
expect(tag.removeVersion).toEqual('v1.4.5');
25+
});
26+
27+
it('should error if there is an invalid option', function() {
28+
expect(function() {
29+
tagDef.transforms({}, {}, ' fromVersion="v1.3.4" toVersion="v1.4.5" what is left is description');
30+
}).toThrowError('Invalid options: "fromVersion" and "toVersion". Value options are: "sinceVersion" and "removeVersion"');
31+
});
32+
});
33+
});

docs/config/templates/app/runnableExample.template.html

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
{# Be aware that we need these extra new lines here or marked will not realise that the <div>
1+
{# Be aware that we need these extra new lines here or marked will not realize that the <div>
22
is HTML and wrap each line in a <p> - thus breaking the HTML #}
33

4+
<div>
5+
<plnkr-opener example-path="{$ doc.path $}"></plnkr-opener>
46

5-
<div class="runnable-example"
6-
path="{$ doc.example.deployments.default.path $}"
7-
{%- for attrName, attrValue in doc.example.attributes %}
8-
{$ attrName $}="{$ attrValue $}"{% endfor %}>
7+
<div class="runnable-example"
8+
path="{$ doc.example.deployments.default.path $}"
9+
{%- for attrName, attrValue in doc.example.attributes %}
10+
{$ attrName $}="{$ attrValue $}"{% endfor %}>
911

10-
{% for fileName, file in doc.example.files %}
11-
<div class="runnable-example-file" {% for attrName, attrValue in file.attributes %}
12-
{$ attrName $}="{$ attrValue $}"{% endfor %}>
13-
{% code -%}
14-
{$ file.fileContents $}
15-
{%- endcode %}
16-
</div>
17-
{% endfor %}
12+
{% for fileName, file in doc.example.files %}
13+
<div class="runnable-example-file" {% for attrName, attrValue in file.attributes %}
14+
{$ attrName $}="{$ attrValue $}"{% endfor %}>
15+
{% code -%}
16+
{$ file.fileContents $}
17+
{%- endcode %}
18+
</div>
19+
{% endfor %}
1820

19-
<iframe class="runnable-example-frame" src="{$ doc.example.deployments.default.outputPath $}" name="{$ doc.example.id $}"></iframe>
21+
<iframe class="runnable-example-frame" src="{$ doc.example.deployments.default.outputPath $}" name="{$ doc.example.id $}"></iframe>
22+
</div>
2023
</div>
2124

22-
23-
{# Be aware that we need these extra new lines here or marked will not realise that the <div>
24-
above is HTML and wrap each line in a <p> - thus breaking the HTML #}
25+
{# Be aware that we need these extra new lines here or marked will not realize that the <div>
26+
above is HTML and wrap each line in a <p> - thus breaking the HTML #}

docs/config/templates/git/api/api.template.html

Lines changed: 0 additions & 66 deletions
This file was deleted.

docs/config/templates/git/base.template.html

Lines changed: 0 additions & 4 deletions
This file was deleted.

docs/config/templates/ngdoc/api/api.template.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
{% extends "base.template.html" %}
2+
{% import "lib/deprecated.html" as x -%}
23

34
{% block content %}
45

6+
<a href='https://github.com/{$ git.info.owner $}/{$ git.info.repo $}/tree/{$ git.version.isSnapshot and 'master' or git.version.raw $}/{$ doc.fileInfo.projectRelativePath $}#L{$ doc.startingLine $}' class='view-source pull-right btn btn-primary'>
7+
<i class="glyphicon glyphicon-zoom-in">&nbsp;</i>View Source
8+
</a>
9+
510
{% block header %}
611
<header class="api-profile-header">
712
<h1 class="api-profile-header-heading">{$ doc.name $}</h1>
813
<ol class="api-profile-header-structure naked-list step-list">
914
{% block related_components %}{% endblock %}
1015
<li>
11-
- {$ doc.docType $} in module {$ doc.moduleDoc.id | link(doc.moduleDoc.name, doc.moduleDoc) $}
16+
- {$ doc.docType $} in module <a href="{$ doc.moduleDoc.path $}">{$ doc.moduleDoc.name $}</a>
1217
</li>
1318
</ol>
1419
</header>
1520
{% endblock %}
1621

22+
{$ x.deprecatedBlock(doc) $}
23+
1724
{% block description %}
1825
<div class="api-profile-description">
1926
{$ doc.description | marked $}
@@ -29,13 +36,6 @@ <h2 id="known-issues">Known Issues</h2>
2936
{% endfor -%}
3037
{% endif %}
3138

32-
{% if doc.deprecated %}
33-
<fieldset class="deprecated">
34-
<legend>Deprecated API</legend>
35-
{$ doc.deprecated| marked $}
36-
</fieldset>
37-
{% endif %}
38-
3939
<div>
4040
{% block dependencies %}
4141
{%- if doc.requires %}

docs/config/templates/ngdoc/api/module.template.html

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,48 @@
11
{% extends "base.template.html" %}
2+
{% import "lib/deprecated.html" as x %}
23

34
{% block content %}
45
<h1>
56
{% if doc.title %}{$ doc.title | marked $}{% else %}{$ doc.name | code $}{% endif %}
67
</h1>
78

8-
{% if doc.name != 'ng' and doc.name != 'auto' %}
9-
<h2>Installation</h2>
9+
{$ x.deprecatedBlock(doc) $}
1010

11-
<p>First include {$ doc.packageFile | code $} in your HTML:</p>
11+
<h2>Installation</h2>
12+
{% if doc.installation or doc.installation == '' %}
13+
{$ doc.installation | marked $}
14+
{% else %}
1215

13-
{% code %}
14-
<script src="angular.js">
15-
<script src="{$ doc.packageFile $}">
16-
{% endcode %}
17-
18-
<p>You can download this file from the following places:</p>
16+
<p>First, get the file:</p>
1917
<ul>
2018
<li>
21-
<a href="https://developers.google.com/speed/libraries/devguide#angularjs">Google CDN</a><br>
22-
e.g. {$ ("//ajax.googleapis.com/ajax/libs/angularjs/X.Y.Z/" + doc.packageFile) | code $}
19+
<a href="https://developers.google.com/speed/libraries/devguide#angularjs">Google CDN</a> e.g.
20+
{% code %}"//ajax.googleapis.com/ajax/libs/angularjs/X.Y.Z/{$ doc.packageFile $}"{% endcode %}
2321
</li>
2422
<li>
25-
<a href="http://bower.io">Bower</a><br>
26-
e.g. {% code %}bower install {$ doc.packageName $}@X.Y.Z{% endcode %}
23+
<a href="https://www.npmjs.com/">NPM</a> e.g.
24+
{% code %}npm install {$ doc.packageName $}@X.Y.Z{% endcode %}
2725
</li>
2826
<li>
29-
<a href="http://code.angularjs.org/">code.angularjs.org</a><br>
30-
e.g. {% code %}"//code.angularjs.org/X.Y.Z/{$ doc.packageFile $}"{% endcode %}
27+
<a href="http://bower.io">Bower</a> e.g.
28+
{% code %}bower install {$ doc.packageName $}#X.Y.Z{% endcode %}
29+
</li>
30+
<li>
31+
<a href="https://code.angularjs.org/">code.angularjs.org</a>
32+
(discouraged for production use) e.g.
33+
{% code %}"//code.angularjs.org/X.Y.Z/{$ doc.packageFile $}"{% endcode %}
3134
</li>
3235
</ul>
3336
<p>where X.Y.Z is the AngularJS version you are running.</p>
34-
<p>Then load the module in your application by adding it as a dependent module:</p>
37+
38+
<p>Then, include {$ doc.packageFile | code $} in your HTML:</p>
39+
40+
{% code %}
41+
<script src="path/to/angular.js"></script>
42+
<script src="path/to/{$ doc.packageFile $}"></script>
43+
{% endcode %}
44+
45+
<p>Finally, load the module in your application by adding it as a dependent module:</p>
3546
{% code %}
3647
angular.module('app', ['{$ doc.name $}']);
3748
{% endcode %}
@@ -51,7 +62,7 @@ <h2 id="known-issues">Known Issues</h2>
5162
<td>{$ issueDoc.id | link(issueDoc.name, issueDoc) $}</td>
5263
<td>
5364
{% for issue in issueDoc.knownIssues -%}
54-
{$ issue | marked $}
65+
{$ issue | marked $} {% if not loop.last %}<hr>{% endif %}
5566
{% endfor -%}
5667
</td>
5768
</tr>
@@ -61,6 +72,7 @@ <h2 id="known-issues">Known Issues</h2>
6172
{% endif %}
6273

6374

75+
{% if doc.componentGroups.length %}
6476
<div class="component-breakdown">
6577
<h2>Module Components</h2>
6678
{% for componentGroup in doc.componentGroups %}
@@ -81,6 +93,7 @@ <h3 class="component-heading" id="{$ componentGroup.groupType | dashCase $}">{$
8193
</div>
8294
{% endfor %}
8395
</div>
96+
{% endif %}
8497

8598
{% if doc.usage %}
8699
<h2>Usage</h2>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
<a href='https://github.com/angular/angular.js/edit/{$ git.version.branch $}/{$ doc.fileInfo.projectRelativePath $}?message=docs({$ (doc.area != "api") and (doc.area + "%2F") or "" $}{$ doc.name $})%3A%20describe%20your%20change...{$ (doc.area == "api") and ("#L" + doc.startingLine) or "" $}' class='improve-docs btn btn-primary'><i class="glyphicon glyphicon-edit">&nbsp;</i>Improve this Doc</a>
2+
13
{% block content %}
24
{% endblock %}

0 commit comments

Comments
 (0)