Skip to content

Commit c2f2587

Browse files
committed
fixed example rendering, add tests for it.
1 parent 5d0d34a commit c2f2587

46 files changed

Lines changed: 512 additions & 477 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/angular.formatter.ngdoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ The formatters are responsible for translating user readable text in an input wi
88
data model stored in an application.
99

1010
# Writting your own Formatter
11-
Writing your own formatter is easy. Just register a pair of JavaScript functions with
12-
`angular.formatter`. One function for parsing user input text to the stored form,
11+
Writing your own formatter is easy. Just register a pair of JavaScript functions with
12+
`angular.formatter`. One function for parsing user input text to the stored form,
1313
and one for formatting the stored data to user-visible text.
1414

15-
Here is an example of a "reverse" formatter: The data is stored in uppercase and in
16-
reverse, while it is displayed in lower case and non-reversed. User edits are
17-
automatically parsed into the internal form and data changes are automatically
15+
Here is an example of a "reverse" formatter: The data is stored in uppercase and in
16+
reverse, while it is displayed in lower case and non-reversed. User edits are
17+
automatically parsed into the internal form and data changes are automatically
1818
formatted to the viewed form.
1919

2020
<pre>
@@ -56,11 +56,11 @@ angular.formatter('reverse', {
5656
});
5757
</script>
5858

59-
Formatted:
59+
Formatted:
6060
<input type="text" name="data" value="angular" ng:format="reverse"/>
6161
<br/>
6262

63-
Stored:
63+
Stored:
6464
<input type="text" name="data"/><br/>
6565
<pre>{{data}}</pre>
6666

@@ -69,7 +69,7 @@ Stored:
6969
it('should store reverse', function(){
7070
expect(element('.doc-example input:first').val()).toEqual('angular');
7171
expect(element('.doc-example input:last').val()).toEqual('RALUGNA');
72-
72+
7373
this.addFutureAction('change to XYZ', function($window, $document, done){
7474
$document.elements('.doc-example input:last').val('XYZ').trigger('change');
7575
done();

docs/angular.service.ngdoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ window alert.
7676
};
7777
}, {$inject: ['$window']});
7878
</pre>
79-
79+
8080
And here is a unit test for this service. We use Jasmine spy (mock) instead of real browser's alert.
8181
<pre>
8282
var mock, notify;
@@ -85,7 +85,7 @@ beforeEach(function() {
8585
mock = {alert: jasmine.createSpy()};
8686
notify = angular.service('notify')(mock);
8787
});
88-
88+
8989
it('should not alert first two notifications', function() {
9090
notify('one');
9191
notify('two');
@@ -134,7 +134,7 @@ function myController($loc, $log) {
134134
};
135135
}
136136
// which services to inject ?
137-
myController.$inject = ['$location', '$log'];
137+
myController.$inject = ['$location', '$log'];
138138
</pre>
139139

140140
@example
@@ -149,13 +149,13 @@ myController.$inject = ['$location', '$log'];
149149
}
150150
};
151151
}, {$inject: ['$window']});
152-
152+
153153
function myController(notifyService) {
154154
this.callNotify = function(msg) {
155155
notifyService(msg);
156156
};
157157
}
158-
158+
159159
myController.$inject = ['notify'];
160160
</script>
161161

docs/angular.validator.ngdoc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@namespace Namespace for all filters.
55
@description
66
# Overview
7-
Validators are a standard way to check the user input against a specific criteria. For
7+
Validators are a standard way to check the user input against a specific criteria. For
88
example, you might need to check that an input field contains a well-formed phone number.
99

1010
# Syntax
@@ -29,20 +29,20 @@ Attach a validator on user input widgets using the `ng:validate` attribute.
2929

3030

3131
# Writing your own Validators
32-
Writing your own validator is easy. To make a function available as a
33-
validator, just define the JavaScript function on the `angular.validator`
34-
object. <angular/> passes in the input to validate as the first argument
35-
to your function. Any additional validator arguments are passed in as
32+
Writing your own validator is easy. To make a function available as a
33+
validator, just define the JavaScript function on the `angular.validator`
34+
object. <angular/> passes in the input to validate as the first argument
35+
to your function. Any additional validator arguments are passed in as
3636
additional arguments to your function.
3737

3838
You can use these variables in the function:
3939

4040
* `this` — The current scope.
4141
* `this.$element` — The DOM element containing the binding. This allows the filter to manipulate
4242
the DOM in addition to transforming the input.
43-
44-
In this example we have written a upsTrackingNo validator.
45-
It marks the input text "valid" only when the user enters a well-formed
43+
44+
In this example we have written a upsTrackingNo validator.
45+
It marks the input text "valid" only when the user enters a well-formed
4646
UPS tracking number.
4747

4848
@css ng-validation-error
@@ -57,7 +57,7 @@ UPS tracking number.
5757
});
5858
</script>
5959
<input type="text" name="trackNo" size="40"
60-
ng:validate="upsTrackingNo:'1Z 999 999 99 9999 999 9'"
60+
ng:validate="upsTrackingNo:'1Z 999 999 99 9999 999 9'"
6161
value="1Z 123 456 78 9012 345 6"/>
6262

6363
@scenario

docs/angular.widget.ngdoc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
@namespace Namespace for all widgets.
55
@description
66
# Overview
7-
Widgets allow you to create DOM elements that the browser doesn't
8-
already understand. You create the widget in your namespace and
9-
assign it behavior. You can only bind one widget per DOM element
10-
(unlike directives, in which you can use any number per DOM
11-
element). Widgets are expected to manipulate the DOM tree by
7+
Widgets allow you to create DOM elements that the browser doesn't
8+
already understand. You create the widget in your namespace and
9+
assign it behavior. You can only bind one widget per DOM element
10+
(unlike directives, in which you can use any number per DOM
11+
element). Widgets are expected to manipulate the DOM tree by
1212
adding new elements whereas directives are expected to only modify
1313
element properties.
1414

1515
Widgets come in two flavors: element and attribute.
1616

1717
# Element Widget
18-
Let's say we would like to create a new element type in the
19-
namespace `my` that can watch an expression and alert() the user
18+
Let's say we would like to create a new element type in the
19+
namespace `my` that can watch an expression and alert() the user
2020
with each new value.
2121

2222
<pre>
@@ -38,7 +38,7 @@ angular.widget('my:watch', function(compileElement) {
3838
</pre>
3939

4040
# Attribute Widget
41-
Let's implement the same widget, but this time as an attribute
41+
Let's implement the same widget, but this time as an attribute
4242
that can be added to any existing DOM element.
4343
<pre>
4444
&lt;div my-watch="name"&gt;text&lt;/div&gt;
@@ -70,4 +70,4 @@ angular.widget('@my:watch', function(expression, compileElement) {
7070
});
7171
</script>
7272
<my:time></my:time>
73-
73+

docs/service.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@
5454
</doc:source>
5555
{{#scenario}}<doc:scenario>{{{scenario}}}</doc:scenario>{{/scenario}}
5656
</doc:example>
57-
{{/example}}
57+
{{/example}}

docs/spec/domSpec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var DOM = require('dom.js').DOM;
2+
3+
describe('dom', function(){
4+
describe('example', function(){
5+
it('should render code, live, test', function(){
6+
var dom = new DOM();
7+
dom.example('desc', 'src', 'scenario');
8+
expect(dom.toString()).toEqual('<h1>Example</h1>\ndesc<doc:example><doc:source>src</doc:source>\n<doc:scenario>scenario</doc:scenario>\n</doc:example>\n');
9+
});
10+
11+
it('should render non-live, test with description', function(){
12+
var dom = new DOM();
13+
dom.example('desc', 'src', false);
14+
expect(dom.toString()).toEqual('<h1>Example</h1>\ndesc<div ng:non-bindable=""><pre class="brush: js; html-script: true;">src</pre>\n</div>\n');
15+
});
16+
17+
it('should render non-live, test', function(){
18+
var dom = new DOM();
19+
dom.example('desc', 'src', false);
20+
expect(dom.toString()).toContain('<pre class="brush: js; html-script: true;">src</pre>');
21+
});
22+
23+
});
24+
});

docs/spec/ngdocSpec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,16 @@ describe('ngdoc', function(){
279279
doc.parse();
280280
expect(doc.html()).toContain('<p>some\n text');
281281
});
282+
283+
it('should render description in related method', function(){
284+
var doc = new Doc();
285+
doc.ngdoc = 'service';
286+
doc.methods = [new Doc('@ngdoc method\n@exampleDescription MDesc\n@example MExmp').parse()];
287+
doc.properties = [new Doc('@ngdoc property\n@exampleDescription PDesc\n@example PExmp').parse()];
288+
expect(doc.html()).toContain('<p>MDesc</p><div ng:non-bindable=""><pre class="brush: js; html-script: true;">MExmp</pre>');
289+
expect(doc.html()).toContain('<p>PDesc</p><div ng:non-bindable=""><pre class="brush: js; html-script: true;">PExmp</pre>');
290+
});
291+
282292
});
283293

284294
describe('@deprecated', function() {

docs/spec/writerSpec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ var writer = require('writer.js');
22
describe('writer', function(){
33
describe('toString', function(){
44
var toString = writer.toString;
5-
5+
66
it('should merge string', function(){
77
expect(toString('abc')).toEqual('abc');
88
});
9-
9+
1010
it('should merge obj', function(){
1111
expect(toString({a:1})).toEqual('{"a":1}');
1212
});
13-
13+
1414
it('should merge array', function(){
1515
expect(toString(['abc',{}])).toEqual('abc{}');
1616
});
1717
});
18-
});
18+
});

docs/src/gen-docs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var writes = callback.chain(function(){
3838
writer.copy('jquery.min.js', writes.waitFor());
3939
});
4040
writes.onDone(function(){
41-
console.log('DONE. Generated ' + docs.length + ' pages in ' +
41+
console.log('DONE. Generated ' + docs.length + ' pages in ' +
4242
(now()-start) + 'ms.' );
4343
});
4444
work.onDone(writes);

docs/src/ngdoc.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Doc.prototype = {
7676
this.description = markdown(this.description);
7777
this['this'] = markdown(this['this']);
7878
this.exampleDescription = markdown(this.exampleDescription || this.exampleDesc);
79+
return this;
7980

8081
function flush(){
8182
if (atName) {
@@ -144,13 +145,13 @@ Doc.prototype = {
144145
dom.h(method.shortName + '(' + signature.join(', ') + ')', method, function(){
145146
dom.html(method.description);
146147
method.html_usage_parameters(dom);
147-
dom.example(method.example, false);
148+
dom.example(method.exampleDescription, method.example, false);
148149
});
149150
});
150151
dom.h('Properties', self.properties, function(property){
151152
dom.h(property.name, function(){
152153
dom.text(property.description);
153-
dom.example(property.example, false);
154+
dom.example(property.exampleDescription, property.example, false);
154155
});
155156
});
156157

0 commit comments

Comments
 (0)