diff options
| author | Misko Hevery | 2011-11-09 21:18:34 -0800 |
|---|---|---|
| committer | Misko Hevery | 2011-11-14 20:31:16 -0800 |
| commit | f0fa5e63762e80fd4ee60ff6d365fca5f886292a (patch) | |
| tree | 7c294714922118c49ec5f37bcd8b2733f13d1e7d /docs | |
| parent | c283bf6035566aa8ff3178676a133de6878b5d1b (diff) | |
| download | angular.js-f0fa5e63762e80fd4ee60ff6d365fca5f886292a.tar.bz2 | |
doc(AUTO, NG_MOCK): Documenting the AUTO and NG_MOCK module
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/content/api/angular.module.NG.ngdoc | 5 | ||||
| -rw-r--r-- | docs/content/api/angular.module.ngdoc | 54 | ||||
| -rw-r--r-- | docs/spec/domSpec.js | 2 | ||||
| -rw-r--r-- | docs/spec/ngdocSpec.js | 2 | ||||
| -rw-r--r-- | docs/src/dom.js | 16 | ||||
| -rw-r--r-- | docs/src/ngdoc.js | 26 | ||||
| -rw-r--r-- | docs/src/templates/docs.css | 14 |
7 files changed, 101 insertions, 18 deletions
diff --git a/docs/content/api/angular.module.NG.ngdoc b/docs/content/api/angular.module.NG.ngdoc new file mode 100644 index 00000000..84bb574b --- /dev/null +++ b/docs/content/api/angular.module.NG.ngdoc @@ -0,0 +1,5 @@ +@ngdoc overview +@name angular.module.NG +@description + +The `NG` is an angular module which contains all of the core angular services. diff --git a/docs/content/api/angular.module.ngdoc b/docs/content/api/angular.module.ngdoc new file mode 100644 index 00000000..91cd311d --- /dev/null +++ b/docs/content/api/angular.module.ngdoc @@ -0,0 +1,54 @@ +@ngdoc overview +@name angular.module +@description + +The angular.module namespace is a global place for registering angular modules. All modules +(angular core or 3rd party) that should be available to an application must be registered in this +namespace. + +# Module + +A module is a function that is used to register new service providers and configure existing +providers. Once a provider is registered, {@link angular.module.AUTO.$injector $injector} will use +it to ask for a service instance when it is resolving a dependency for the first time. + +<pre> +// Declare the module configuration function. +// The function arguments are fully injectable so that the module function +// can create new providers or configure existing ones. +function MyModule($provide, $locationProvider){ + // see $provide for more information. + $provide.value('appName', 'MyCoolApp'); + + // Configure existing providers + $locationProvider.hashPrefix = '!'; +}; +</pre> + +See: {@link angular.module.NG.$provide $provide}, {@link angular.module.NG.$locationProvider $locationProvider}. + +# Registering Module Function + +In your JavaScript file: +<pre> +// Create the angular.module namespace if one does not exist +// This allows the module code to be loaded before angular.js code. +if (!window.angular) window.angular = {}; +if (!angular.module) angular.module = {}; + +angular.module.MyModule = function(){ + // add configuration code here. +}; +</pre> + +Then you can refer to your module like this: + +<pre> +var injector = angular.injector('NG', 'MyModule') +</pre> + +Or + +<pre> +var injector = angular.injector('NG', angular.module.MyModule) +</pre> diff --git a/docs/spec/domSpec.js b/docs/spec/domSpec.js index a967645e..5175b91a 100644 --- a/docs/spec/domSpec.js +++ b/docs/spec/domSpec.js @@ -24,7 +24,7 @@ describe('dom', function() { dom.h('heading', function() { this.html('<h1>sub-heading</h1>'); }); - expect(dom.toString()).toContain('<h1>heading</h1>'); + expect(dom.toString()).toContain('<h1 id="heading">heading</h1>'); expect(dom.toString()).toContain('<h2>sub-heading</h2>'); }); diff --git a/docs/spec/ngdocSpec.js b/docs/spec/ngdocSpec.js index 367f91b4..bc2bb2ee 100644 --- a/docs/spec/ngdocSpec.js +++ b/docs/spec/ngdocSpec.js @@ -528,7 +528,7 @@ describe('ngdoc', function() { returns: {type: 'number', description: 'return desc'} }); doc.html_usage_function(dom); - expect(dom).toContain('some.name([a][, b], c)'); //TODO(i) the comma position here is lame + expect(dom).toContain('name([a][, b], c)'); //TODO(i) the comma position here is lame expect(dom).toContain('param desc'); expect(dom).toContain('(optional="xxx")'); expect(dom).toContain('return desc'); diff --git a/docs/src/dom.js b/docs/src/dom.js index ccfee7ac..11330a02 100644 --- a/docs/src/dom.js +++ b/docs/src/dom.js @@ -77,10 +77,18 @@ DOM.prototype = { h: function(heading, content, fn){ if (content==undefined || (content instanceof Array && content.length == 0)) return; this.headingDepth++; - this.tag('h' + this.headingDepth, heading); - var className = typeof heading == 'string' - ? {'class': heading.toLowerCase().replace(/[^\d\w_]/mg, '-').replace(/-+/gm, '-')} - : null; + var className = null, + anchor = null; + if (typeof heading == 'string') { + var id = heading. + replace(/\(.*\)/mg, ''). + replace(/[^\d\w]/mg, '.'). + replace(/-+/gm, '-'). + replace(/-*$/gm, ''); + anchor = {'id': id}; + className = {'class': id.toLowerCase().replace(/[._]/mg, '-')}; + } + this.tag('h' + this.headingDepth, anchor, heading); if (content instanceof Array) { this.ul(content, className, fn); } else if (fn) { diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js index 562144b5..7f97b906 100644 --- a/docs/src/ngdoc.js +++ b/docs/src/ngdoc.js @@ -89,6 +89,7 @@ Doc.prototype = { var self = this, IS_URL = /^(https?:\/\/|ftps?:\/\/|mailto:|\.|\/)/, IS_ANGULAR = /^(api\/)?angular\./, + IS_HASH = /^#/, parts = trim(text).split(/(<pre>[\s\S]*?<\/pre>|<doc:(\S*).*?>[\s\S]*?<\/doc:\2>)/); parts.forEach(function(text, i) { @@ -134,13 +135,16 @@ Doc.prototype = { function(_all, url, title){ var isFullUrl = url.match(IS_URL), isAngular = url.match(IS_ANGULAR), - absUrl = isFullUrl ? url : self.convertUrlToAbsolute(url); + isHash = url.match(IS_HASH), + absUrl = isHash + ? url + : (isFullUrl ? url : self.convertUrlToAbsolute(url)); if (!isFullUrl) self.links.push(absUrl); return '<a href="' + absUrl + '">' + (isAngular ? '<code>' : '') + - (title || url).replace(/\n/g, ' ') + + (title || url.replace(/^#/g, '')).replace(/\n/g, ' ') + (isAngular ? '</code>' : '') + '</a>'; }); @@ -171,7 +175,8 @@ Doc.prototype = { } }); flush(); - this.shortName = (this.name || '').split(/[\.#]/).pop(); + this.name = this.name || ''; + this.shortName = this.name.split(this.name.match(/#/) ? /#/ : /\./ ).pop(); this.id = this.id || // if we have an id just use it (((this.file||'').match(/.*\/([^\/]*)\.ngdoc/)||{})[1]) || // try to extract it from file name this.name; // default to name @@ -319,7 +324,7 @@ Doc.prototype = { var self = this; dom.h('Usage', function() { dom.code(function() { - dom.text(self.name.split('service.').pop()); + dom.text(self.name.split(/\./).pop()); dom.text('('); self.parameters(dom, ', '); dom.text(');'); @@ -329,6 +334,7 @@ Doc.prototype = { self.html_usage_this(dom); self.html_usage_returns(dom); }); + this.method_properties_events(dom); }, html_usage_property: function(dom){ @@ -450,7 +456,7 @@ Doc.prototype = { dom.html(this.description); }, - html_usage_service: function(dom){ + html_usage_object: function(dom){ var self = this; if (this.param.length) { @@ -467,7 +473,15 @@ Doc.prototype = { self.html_usage_returns(dom); }); } + this.method_properties_events(dom); + }, + + html_usage_service: function(dom) { + this.html_usage_object(dom) + }, + method_properties_events: function(dom) { + var self = this; dom.h('Methods', this.methods, function(method){ var signature = (method.param || []).map(property('name')); dom.h(method.shortName + '(' + signature.join(', ') + ')', method, function() { @@ -480,7 +494,7 @@ Doc.prototype = { }); }); dom.h('Properties', this.properties, function(property){ - dom.h(property.name, function() { + dom.h(property.shortName, function() { dom.html(property.description); dom.h('Example', property.example, dom.html); }); diff --git a/docs/src/templates/docs.css b/docs/src/templates/docs.css index 5c7a064a..fd77970c 100644 --- a/docs/src/templates/docs.css +++ b/docs/src/templates/docs.css @@ -240,23 +240,25 @@ li { } #content-list .level-1 { - font-size: 1.1em; - font-weight: bold; + margin-left: 0em; } -#content-list .level-2, -#content-list .level-3 { +#content-list .level-2 { margin-left: 1em; } -#content-list .level-4 { +#content-list .level-3 { margin-left: 2em; } -#content-list .level-5 { +#content-list .level-4 { margin-left: 3em; } +#content-list .level-5 { + margin-left: 4em; +} + #content-list a.current { font-weight: bold; |
