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

Commit 21c7072

Browse files
matskomhevery
authored andcommitted
feat(ngdocs): provide support for inline variable hinting
1 parent e46100f commit 21c7072

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

docs/spec/ngdocSpec.js

+5
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ describe('ngdoc', function() {
150150
toMatch('</pre>\n\n<h1 id="one">One</h1>\n\n<pre');
151151
});
152152

153+
it('should replace inline variable type hints', function() {
154+
expect(new Doc().markdown('{@type string}')).
155+
toMatch(/<a\s+.*?class=".*?type-hint type-hint-string.*?".*?>/);
156+
});
157+
153158
it('should ignore nested doc widgets', function() {
154159
expect(new Doc().markdown(
155160
'before<div class="tabbable">\n' +

docs/src/ngdoc.js

+4
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ Doc.prototype = {
214214
(title || url).replace(/^#/g, '').replace(/\n/g, ' ') +
215215
(isAngular ? '</code>' : '') +
216216
'</a>';
217+
}).
218+
replace(/{@type\s+(\S+)(?:\s+(\S+))?}/g, function(_, type, url) {
219+
url = url || '#';
220+
return '<a href="' + url + '" class="' + self.prepare_type_hint_class_name(type) + '">' + type + '</a>';
217221
});
218222
});
219223
text = parts.join('');

src/ng/directive/ngRepeat.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
*
1212
* Special properties are exposed on the local scope of each template instance, including:
1313
*
14-
* * `$index` – `{number}` – iterator offset of the repeated element (0..length-1)
15-
* * `$first` – `{boolean}` – true if the repeated element is first in the iterator.
16-
* * `$middle` – `{boolean}` – true if the repeated element is between the first and last in the iterator.
17-
* * `$last` – `{boolean}` – true if the repeated element is last in the iterator.
14+
* | Variable | Type | Details |
15+
* |===========|=================|=============================================================================|
16+
* | `$index` | {@type number} | iterator offset of the repeated element (0..length-1) |
17+
* | `$first` | {@type boolean} | true if the repeated element is first in the iterator. |
18+
* | `$middle` | {@type boolean} | true if the repeated element is between the first and last in the iterator. |
19+
* | `$last` | {@type boolean} | true if the repeated element is last in the iterator. |
1820
*
1921
* Additionally, you can also provide animations via the ngAnimate attribute to animate the **enter**,
2022
* **leave** and **move** effects.

0 commit comments

Comments
 (0)