Skip to content

Commit ba6b68b

Browse files
committed
changed the documentation @example to use <doc:example>
1 parent ed768eb commit ba6b68b

20 files changed

Lines changed: 1880 additions & 1692 deletions

docs/angular.filter.ngdoc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ You can use these variables in the function:
4646
the DOM in addition to transforming the input.
4747

4848

49-
@exampleDescription
49+
@example
5050
The following example filter reverses a text string. In addition, it conditionally makes the
5151
text upper-case (to demonstrate optional arguments) and assigns color (to demonstrate DOM
5252
modification).
5353

54-
@example
54+
<doc:example>
55+
<doc:source>
5556
<script type="text/javascript">
5657
angular.filter('reverse', function(input, uppercase, color) {
5758
var out = "";
@@ -73,4 +74,14 @@ You can use these variables in the function:
7374
Reverse: {{text|reverse}}<br>
7475
Reverse + uppercase: {{text|reverse:true}}<br>
7576
Reverse + uppercase + blue: {{text|reverse:true:"blue"}}
77+
</doc:source>
78+
<doc:scenario>
79+
it('should reverse text', function(){
80+
expect(binding('text|reverse')).toEqual('olleh');
81+
input('text').enter('ABC');
82+
expect(binding('text|reverse')).toEqual('CBA');
83+
});
84+
</doc:scenario>
85+
</doc:example>
86+
7687

docs/angular.formatter.ngdoc

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,42 +37,46 @@ angular.formatter('reverse', {
3737
</pre>
3838

3939
@example
40-
<script type="text/javascript">
41-
function reverse(text) {
42-
var reversed = [];
43-
for (var i = 0; i < text.length; i++) {
44-
reversed.unshift(text.charAt(i));
45-
}
46-
return reversed.join('');
47-
}
48-
49-
angular.formatter('reverse', {
50-
parse: function(value){
51-
return reverse(value||'').toUpperCase();
52-
},
53-
format: function(value){
54-
return reverse(value||'').toLowerCase();
40+
<doc:example>
41+
<doc:source>
42+
<script type="text/javascript">
43+
function reverse(text) {
44+
var reversed = [];
45+
for (var i = 0; i < text.length; i++) {
46+
reversed.unshift(text.charAt(i));
47+
}
48+
return reversed.join('');
5549
}
56-
});
57-
</script>
5850

59-
Formatted:
60-
<input type="text" name="data" value="angular" ng:format="reverse"/>
61-
<br/>
51+
angular.formatter('reverse', {
52+
parse: function(value){
53+
return reverse(value||'').toUpperCase();
54+
},
55+
format: function(value){
56+
return reverse(value||'').toLowerCase();
57+
}
58+
});
59+
</script>
6260

63-
Stored:
64-
<input type="text" name="data"/><br/>
65-
<pre>{{data}}</pre>
61+
Formatted:
62+
<input type="text" name="data" value="angular" ng:format="reverse"/>
63+
<br/>
6664

65+
Stored:
66+
<input type="text" name="data"/><br/>
67+
<pre>{{data}}</pre>
68+
</doc:source>
69+
<doc:scenario>
70+
it('should store reverse', function(){
71+
expect(element('.doc-example input:first').val()).toEqual('angular');
72+
expect(element('.doc-example input:last').val()).toEqual('RALUGNA');
6773

68-
@scenario
69-
it('should store reverse', function(){
70-
expect(element('.doc-example input:first').val()).toEqual('angular');
71-
expect(element('.doc-example input:last').val()).toEqual('RALUGNA');
74+
this.addFutureAction('change to XYZ', function($window, $document, done){
75+
$document.elements('.doc-example input:last').val('XYZ').trigger('change');
76+
done();
77+
});
78+
expect(element('.doc-example input:first').val()).toEqual('zyx');
79+
});
80+
</doc:scenario>
81+
</doc:example>
7282

73-
this.addFutureAction('change to XYZ', function($window, $document, done){
74-
$document.elements('.doc-example input:last').val('XYZ').trigger('change');
75-
done();
76-
});
77-
expect(element('.doc-example input:first').val()).toEqual('zyx');
78-
});

docs/angular.service.ngdoc

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@ services if needed.
1717

1818
Like other core angular variables and identifiers, the built-in services always start with `$`.
1919

20-
* `{@link angular.service.$browser $browser}`
21-
* `{@link angular.service.$window $window}`
22-
* `{@link angular.service.$document $document}`
23-
* `{@link angular.service.$location $location}`
24-
* `{@link angular.service.$log $log}`
25-
* `{@link angular.service.$exceptionHandler $exceptionHandler}`
26-
* `{@link angular.service.$hover $hover}`
27-
* `{@link angular.service.$invalidWidgets $invalidWidgets}`
28-
* `{@link angular.service.$route $route}`
29-
* `{@link angular.service.$xhr $xhr}`
30-
* `{@link angular.service.$xhr.error $xhr.error}`
31-
* `{@link angular.service.$xhr.bulk $xhr.bulk}`
32-
* `{@link angular.service.$xhr.cache $xhr.cache}`
33-
* `{@link angular.service.$resource $resource}`
34-
* `{@link angular.service.$cookies $cookies}`
35-
* `{@link angular.service.$cookieStore $cookieStore}`
20+
* {@link angular.service.$browser $browser}
21+
* {@link angular.service.$window $window}
22+
* {@link angular.service.$document $document}
23+
* {@link angular.service.$location $location}
24+
* {@link angular.service.$log $log}
25+
* {@link angular.service.$exceptionHandler $exceptionHandler}
26+
* {@link angular.service.$hover $hover}
27+
* {@link angular.service.$invalidWidgets $invalidWidgets}
28+
* {@link angular.service.$route $route}
29+
* {@link angular.service.$xhr $xhr}
30+
* {@link angular.service.$xhr.error $xhr.error}
31+
* {@link angular.service.$xhr.bulk $xhr.bulk}
32+
* {@link angular.service.$xhr.cache $xhr.cache}
33+
* {@link angular.service.$resource $resource}
34+
* {@link angular.service.$cookies $cookies}
35+
* {@link angular.service.$cookieStore $cookieStore}
3636

3737
# Writing your own custom services
3838
angular provides only set of basic services, so for any nontrivial application it will be necessary
@@ -138,29 +138,38 @@ myController.$inject = ['$location', '$log'];
138138
</pre>
139139

140140
@example
141-
<script type="text/javascript">
142-
angular.service('notify', function(win) {
143-
var msgs = [];
144-
return function(msg) {
145-
msgs.push(msg);
146-
if (msgs.length == 3) {
147-
win.alert(msgs.join("\n"));
148-
msgs = [];
149-
}
150-
};
151-
}, {$inject: ['$window']});
152-
153-
function myController(notifyService) {
154-
this.callNotify = function(msg) {
155-
notifyService(msg);
156-
};
157-
}
158-
159-
myController.$inject = ['notify'];
160-
</script>
161-
162-
<div ng:controller="myController">
163-
<p>Let's try this simple notify service, injected into the controller...</p>
164-
<input ng:init="message='test'" type="text" name="message" />
165-
<button ng:click="callNotify(message);">NOTIFY</button>
166-
</div>
141+
<doc:example>
142+
<doc:source>
143+
<script type="text/javascript">
144+
angular.service('notify', function(win) {
145+
var msgs = [];
146+
return function(msg) {
147+
msgs.push(msg);
148+
if (msgs.length == 3) {
149+
win.alert(msgs.join("\n"));
150+
msgs = [];
151+
}
152+
};
153+
}, {$inject: ['$window']});
154+
155+
function myController(notifyService) {
156+
this.callNotify = function(msg) {
157+
notifyService(msg);
158+
};
159+
}
160+
161+
myController.$inject = ['notify'];
162+
</script>
163+
164+
<div ng:controller="myController">
165+
<p>Let's try this simple notify service, injected into the controller...</p>
166+
<input ng:init="message='test'" type="text" name="message" />
167+
<button ng:click="callNotify(message);">NOTIFY</button>
168+
</div>
169+
</doc:source>
170+
<doc:scenario>
171+
it('should test service', function(){
172+
expect(element(':input[name=message]').val()).toEqual('test');
173+
});
174+
</doc:scenario>
175+
</doc:example>

docs/angular.validator.ngdoc

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,28 @@ UPS tracking number.
5050
default.
5151

5252
@example
53-
<script>
54-
angular.validator('upsTrackingNo', function(input, format) {
55-
var regexp = new RegExp("^" + format.replace(/9/g, '\\d') + "$");
56-
return input.match(regexp)?"":"The format must match " + format;
57-
});
58-
</script>
59-
<input type="text" name="trackNo" size="40"
60-
ng:validate="upsTrackingNo:'1Z 999 999 99 9999 999 9'"
61-
value="1Z 123 456 78 9012 345 6"/>
62-
63-
@scenario
64-
it('should validate correct UPS tracking number', function() {
65-
expect(element('input[name=trackNo]').attr('class')).
66-
not().toMatch(/ng-validation-error/);
67-
});
53+
<doc:example>
54+
<doc:source>
55+
<script>
56+
angular.validator('upsTrackingNo', function(input, format) {
57+
var regexp = new RegExp("^" + format.replace(/9/g, '\\d') + "$");
58+
return input.match(regexp)?"":"The format must match " + format;
59+
});
60+
</script>
61+
<input type="text" name="trackNo" size="40"
62+
ng:validate="upsTrackingNo:'1Z 999 999 99 9999 999 9'"
63+
value="1Z 123 456 78 9012 345 6"/>
64+
</doc:source>
65+
<doc:scenario>
66+
it('should validate correct UPS tracking number', function() {
67+
expect(element('input[name=trackNo]').attr('class')).
68+
not().toMatch(/ng-validation-error/);
69+
});
6870

69-
it('should not validate in correct UPS tracking number', function() {
70-
input('trackNo').enter('foo');
71-
expect(element('input[name=trackNo]').attr('class')).
72-
toMatch(/ng-validation-error/);
73-
});
71+
it('should not validate in correct UPS tracking number', function() {
72+
input('trackNo').enter('foo');
73+
expect(element('input[name=trackNo]').attr('class')).
74+
toMatch(/ng-validation-error/);
75+
});
76+
</doc:scenario>
77+
</doc:example>

docs/angular.widget.ngdoc

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,22 @@ angular.widget('@my:watch', function(expression, compileElement) {
5757
</pre>
5858

5959
@example
60-
<script>
61-
angular.widget('my:time', function(compileElement){
62-
compileElement.css('display', 'block');
63-
return function(linkElement){
64-
function update(){
65-
linkElement.text('Current time is: ' + new Date());
66-
setTimeout(update, 1000);
67-
}
68-
update();
69-
};
70-
});
71-
</script>
72-
<my:time></my:time>
73-
60+
<doc:example>
61+
<doc:source>
62+
<script>
63+
angular.widget('my:time', function(compileElement){
64+
compileElement.css('display', 'block');
65+
return function(linkElement){
66+
function update(){
67+
linkElement.text('Current time is: ' + new Date());
68+
setTimeout(update, 1000);
69+
}
70+
update();
71+
};
72+
});
73+
</script>
74+
<my:time></my:time>
75+
</doc:source>
76+
<doc:scenario>
77+
</doc:scenario>
78+
</doc:example>

docs/spec/domSpec.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,6 @@ describe('dom', function(){
77
dom = new DOM();
88
});
99

10-
describe('example', function(){
11-
it('should render code, live, test', function(){
12-
dom.example('desc', 'src', 'scenario');
13-
expect(dom.toString()).toEqual(
14-
'<h1>Example</h1>\n' +
15-
'<div class="example">' +
16-
'desc<doc:example><doc:source>src</doc:source>\n' +
17-
'<doc:scenario>scenario</doc:scenario>\n'+
18-
'</doc:example>\n' +
19-
'</div>\n');
20-
});
21-
22-
it('should render non-live, test with description', function(){
23-
dom.example('desc', 'src', false);
24-
expect(dom.toString()).toEqual('<h1>Example</h1>\n' +
25-
'<div class="example">' +
26-
'desc<div ng:non-bindable="">' +
27-
'<pre class="brush: js; html-script: true;">src</pre>\n' +
28-
'</div>\n' +
29-
'</div>\n');
30-
});
31-
32-
it('should render non-live, test', function(){
33-
dom.example('desc', 'src', false);
34-
expect(dom.toString()).toContain('<pre class="brush: js; html-script: true;">src</pre>');
35-
});
36-
});
37-
3810
describe('h', function(){
3911

4012
it('should render using function', function(){

0 commit comments

Comments
 (0)