From f0fa5e63762e80fd4ee60ff6d365fca5f886292a Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Wed, 9 Nov 2011 21:18:34 -0800 Subject: doc(AUTO, NG_MOCK): Documenting the AUTO and NG_MOCK module --- docs/content/api/angular.module.NG.ngdoc | 5 +++ docs/content/api/angular.module.ngdoc | 54 ++++++++++++++++++++++++++++++++ docs/spec/domSpec.js | 2 +- docs/spec/ngdocSpec.js | 2 +- docs/src/dom.js | 16 +++++++--- docs/src/ngdoc.js | 26 +++++++++++---- docs/src/templates/docs.css | 14 +++++---- 7 files changed, 101 insertions(+), 18 deletions(-) create mode 100644 docs/content/api/angular.module.NG.ngdoc create mode 100644 docs/content/api/angular.module.ngdoc (limited to 'docs') 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. + +
+// 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 = '!';
+};
+
+ +See: {@link angular.module.NG.$provide $provide}, {@link angular.module.NG.$locationProvider $locationProvider}. + +# Registering Module Function + +In your JavaScript file: +
+// 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.
+};
+
+ +Then you can refer to your module like this: + +
+var injector = angular.injector('NG', 'MyModule')
+
+ +Or + +
+var injector = angular.injector('NG', angular.module.MyModule)
+
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('

sub-heading

'); }); - expect(dom.toString()).toContain('

heading

'); + expect(dom.toString()).toContain('

heading

'); expect(dom.toString()).toContain('

sub-heading

'); }); 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(/(
[\s\S]*?<\/pre>|[\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 '' +
               (isAngular ? '' : '') +
-              (title || url).replace(/\n/g, ' ') +
+              (title || url.replace(/^#/g, '')).replace(/\n/g, ' ') +
               (isAngular ? '' : '') +
               '';
           });
@@ -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;
-- 
cgit v1.2.3