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

Commit f0fa5e6

Browse files
committed
doc(AUTO, NG_MOCK): Documenting the AUTO and NG_MOCK module
1 parent c283bf6 commit f0fa5e6

28 files changed

+626
-205
lines changed
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@ngdoc overview
2+
@name angular.module.NG
3+
@description
4+
5+
The `NG` is an angular module which contains all of the core angular services.

docs/content/api/angular.module.ngdoc

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
@ngdoc overview
2+
@name angular.module
3+
@description
4+
5+
The angular.module namespace is a global place for registering angular modules. All modules
6+
(angular core or 3rd party) that should be available to an application must be registered in this
7+
namespace.
8+
9+
# Module
10+
11+
A module is a function that is used to register new service providers and configure existing
12+
providers. Once a provider is registered, {@link angular.module.AUTO.$injector $injector} will use
13+
it to ask for a service instance when it is resolving a dependency for the first time.
14+
15+
<pre>
16+
// Declare the module configuration function.
17+
// The function arguments are fully injectable so that the module function
18+
// can create new providers or configure existing ones.
19+
function MyModule($provide, $locationProvider){
20+
// see $provide for more information.
21+
$provide.value('appName', 'MyCoolApp');
22+
23+
// Configure existing providers
24+
$locationProvider.hashPrefix = '!';
25+
};
26+
</pre>
27+
28+
See: {@link angular.module.NG.$provide $provide}, {@link angular.module.NG.$locationProvider $locationProvider}.
29+
30+
# Registering Module Function
31+
32+
In your JavaScript file:
33+
<pre>
34+
// Create the angular.module namespace if one does not exist
35+
// This allows the module code to be loaded before angular.js code.
36+
if (!window.angular) window.angular = {};
37+
if (!angular.module) angular.module = {};
38+
39+
angular.module.MyModule = function(){
40+
// add configuration code here.
41+
};
42+
</pre>
43+
44+
Then you can refer to your module like this:
45+
46+
<pre>
47+
var injector = angular.injector('NG', 'MyModule')
48+
</pre>
49+
50+
Or
51+
52+
<pre>
53+
var injector = angular.injector('NG', angular.module.MyModule)
54+
</pre>

docs/spec/domSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('dom', function() {
2424
dom.h('heading', function() {
2525
this.html('<h1>sub-heading</h1>');
2626
});
27-
expect(dom.toString()).toContain('<h1>heading</h1>');
27+
expect(dom.toString()).toContain('<h1 id="heading">heading</h1>');
2828
expect(dom.toString()).toContain('<h2>sub-heading</h2>');
2929
});
3030

docs/spec/ngdocSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ describe('ngdoc', function() {
528528
returns: {type: 'number', description: 'return desc'}
529529
});
530530
doc.html_usage_function(dom);
531-
expect(dom).toContain('some.name([a][, b], c)'); //TODO(i) the comma position here is lame
531+
expect(dom).toContain('name([a][, b], c)'); //TODO(i) the comma position here is lame
532532
expect(dom).toContain('param desc');
533533
expect(dom).toContain('(optional="xxx")');
534534
expect(dom).toContain('return desc');

docs/src/dom.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,18 @@ DOM.prototype = {
7777
h: function(heading, content, fn){
7878
if (content==undefined || (content instanceof Array && content.length == 0)) return;
7979
this.headingDepth++;
80-
this.tag('h' + this.headingDepth, heading);
81-
var className = typeof heading == 'string'
82-
? {'class': heading.toLowerCase().replace(/[^\d\w_]/mg, '-').replace(/-+/gm, '-')}
83-
: null;
80+
var className = null,
81+
anchor = null;
82+
if (typeof heading == 'string') {
83+
var id = heading.
84+
replace(/\(.*\)/mg, '').
85+
replace(/[^\d\w]/mg, '.').
86+
replace(/-+/gm, '-').
87+
replace(/-*$/gm, '');
88+
anchor = {'id': id};
89+
className = {'class': id.toLowerCase().replace(/[._]/mg, '-')};
90+
}
91+
this.tag('h' + this.headingDepth, anchor, heading);
8492
if (content instanceof Array) {
8593
this.ul(content, className, fn);
8694
} else if (fn) {

docs/src/ngdoc.js

+20-6
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Doc.prototype = {
8989
var self = this,
9090
IS_URL = /^(https?:\/\/|ftps?:\/\/|mailto:|\.|\/)/,
9191
IS_ANGULAR = /^(api\/)?angular\./,
92+
IS_HASH = /^#/,
9293
parts = trim(text).split(/(<pre>[\s\S]*?<\/pre>|<doc:(\S*).*?>[\s\S]*?<\/doc:\2>)/);
9394

9495
parts.forEach(function(text, i) {
@@ -134,13 +135,16 @@ Doc.prototype = {
134135
function(_all, url, title){
135136
var isFullUrl = url.match(IS_URL),
136137
isAngular = url.match(IS_ANGULAR),
137-
absUrl = isFullUrl ? url : self.convertUrlToAbsolute(url);
138+
isHash = url.match(IS_HASH),
139+
absUrl = isHash
140+
? url
141+
: (isFullUrl ? url : self.convertUrlToAbsolute(url));
138142

139143
if (!isFullUrl) self.links.push(absUrl);
140144

141145
return '<a href="' + absUrl + '">' +
142146
(isAngular ? '<code>' : '') +
143-
(title || url).replace(/\n/g, ' ') +
147+
(title || url.replace(/^#/g, '')).replace(/\n/g, ' ') +
144148
(isAngular ? '</code>' : '') +
145149
'</a>';
146150
});
@@ -171,7 +175,8 @@ Doc.prototype = {
171175
}
172176
});
173177
flush();
174-
this.shortName = (this.name || '').split(/[\.#]/).pop();
178+
this.name = this.name || '';
179+
this.shortName = this.name.split(this.name.match(/#/) ? /#/ : /\./ ).pop();
175180
this.id = this.id || // if we have an id just use it
176181
(((this.file||'').match(/.*\/([^\/]*)\.ngdoc/)||{})[1]) || // try to extract it from file name
177182
this.name; // default to name
@@ -319,7 +324,7 @@ Doc.prototype = {
319324
var self = this;
320325
dom.h('Usage', function() {
321326
dom.code(function() {
322-
dom.text(self.name.split('service.').pop());
327+
dom.text(self.name.split(/\./).pop());
323328
dom.text('(');
324329
self.parameters(dom, ', ');
325330
dom.text(');');
@@ -329,6 +334,7 @@ Doc.prototype = {
329334
self.html_usage_this(dom);
330335
self.html_usage_returns(dom);
331336
});
337+
this.method_properties_events(dom);
332338
},
333339

334340
html_usage_property: function(dom){
@@ -450,7 +456,7 @@ Doc.prototype = {
450456
dom.html(this.description);
451457
},
452458

453-
html_usage_service: function(dom){
459+
html_usage_object: function(dom){
454460
var self = this;
455461

456462
if (this.param.length) {
@@ -467,7 +473,15 @@ Doc.prototype = {
467473
self.html_usage_returns(dom);
468474
});
469475
}
476+
this.method_properties_events(dom);
477+
},
478+
479+
html_usage_service: function(dom) {
480+
this.html_usage_object(dom)
481+
},
470482

483+
method_properties_events: function(dom) {
484+
var self = this;
471485
dom.h('Methods', this.methods, function(method){
472486
var signature = (method.param || []).map(property('name'));
473487
dom.h(method.shortName + '(' + signature.join(', ') + ')', method, function() {
@@ -480,7 +494,7 @@ Doc.prototype = {
480494
});
481495
});
482496
dom.h('Properties', this.properties, function(property){
483-
dom.h(property.name, function() {
497+
dom.h(property.shortName, function() {
484498
dom.html(property.description);
485499
dom.h('Example', property.example, dom.html);
486500
});

docs/src/templates/docs.css

+8-6
Original file line numberDiff line numberDiff line change
@@ -240,23 +240,25 @@ li {
240240
}
241241

242242
#content-list .level-1 {
243-
font-size: 1.1em;
244-
font-weight: bold;
243+
margin-left: 0em;
245244
}
246245

247-
#content-list .level-2,
248-
#content-list .level-3 {
246+
#content-list .level-2 {
249247
margin-left: 1em;
250248
}
251249

252-
#content-list .level-4 {
250+
#content-list .level-3 {
253251
margin-left: 2em;
254252
}
255253

256-
#content-list .level-5 {
254+
#content-list .level-4 {
257255
margin-left: 3em;
258256
}
259257

258+
#content-list .level-5 {
259+
margin-left: 4em;
260+
}
261+
260262

261263
#content-list a.current {
262264
font-weight: bold;

src/Browser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var XHR = window.XMLHttpRequest || function() {
2424
* - hide all the global state in the browser caused by the window object
2525
* - abstract away all the browser specific features and inconsistencies
2626
*
27-
* For tests we provide {@link angular.mock.service.$browser mock implementation} of the `$browser`
27+
* For tests we provide {@link angular.module.NG_MOCK.$browser mock implementation} of the `$browser`
2828
* service, which can be used for convenient testing of the application without the interaction with
2929
* the real browser apis.
3030
*/

0 commit comments

Comments
 (0)