From f16150d5f1b20b3d633b4402095ea89baa4be042 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 11 Jun 2012 23:49:24 -0700 Subject: docs(*): simplify doc urls we now have two types of namespaces: - true namespace: angular.* - used for all global apis - virtual namespace: ng.*, ngMock.*, ... - used for all DI modules the virual namespaces have services under the second namespace level (e.g. ng.) and filters and directives prefixed with filter: and directive: respectively (e.g. ng.filter:orderBy, ng.directive:ngRepeat) this simplifies urls and makes them a lot shorter while still avoiding name collisions --- docs/src/ngdoc.js | 25 ++++++++++++----------- docs/src/templates/js/docs.js | 46 ++++++++++++++++++++++--------------------- 2 files changed, 37 insertions(+), 34 deletions(-) (limited to 'docs/src') diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js index 441ea2c8..5517fa93 100644 --- a/docs/src/ngdoc.js +++ b/docs/src/ngdoc.js @@ -101,7 +101,7 @@ Doc.prototype = { var self = this, IS_URL = /^(https?:\/\/|ftps?:\/\/|mailto:|\.|\/)/, - IS_ANGULAR = /^(api\/)?angular\./, + IS_ANGULAR = /^(api\/)?(angular|ng|AUTO)\./, IS_HASH = /^#/, parts = trim(text).split(/(
[\s\S]*?<\/pre>|[\s\S]*?<\/doc:example>|]*>[\s\S]*?<\/example>)/),
       seq = 0,
@@ -201,7 +201,7 @@ Doc.prototype = {
       }
     });
     flush();
-    this.shortName = this.name.split(this.name.match(/#/) ? /#/ : /\./ ).pop();
+    this.shortName = this.name.split(/[\.:#]/).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
@@ -277,7 +277,7 @@ Doc.prototype = {
       }
       dom.h('Dependencies', self.requires, function(require){
         dom.tag('code', function() {
-          dom.tag('a', {href: 'api/angular.module.ng.' + require.name}, require.name);
+          dom.tag('a', {href: 'api/ng.' + require.name}, require.name);
         });
         dom.html(require.text);
       });
@@ -622,14 +622,15 @@ Doc.prototype = {
 
 
 //////////////////////////////////////////////////////////
-var GLOBALS = /^angular\.([^\.]*)$/,
-  MODULE = /^angular\.module\.([^\.]*)$/,
-  MODULE_MOCK = /^angular\.mock\.([^\.]*)$/,
-  MODULE_DIRECTIVE = /^angular\.module\.([^\.]*)(?:\.\$compileProvider)?\.directive\.([^\.]*)$/,
-  MODULE_DIRECTIVE_INPUT = /^angular\.module\.([^\.]*)\.\$compileProvider\.directive\.input\.([^\.]*)$/,
-  MODULE_FILTER = /^angular\.module\.([^\.]*)\.\$?filter\.([^\.]*)$/,
-  MODULE_SERVICE = /^angular\.module\.([^\.]*)\.([^\.]*?)(Provider)?$/,
-  MODULE_TYPE = /^angular\.module\.([^\.]*)\..*\.([A-Z][^\.]*)$/;
+var GLOBALS = /^angular\.([^\.]+)$/,
+    MODULE = /^((?:(?!^angular\.)[^\.])+)$/,
+    MODULE_MOCK = /^angular\.mock\.([^\.]+)$/,
+    MODULE_DIRECTIVE = /^((?:(?!^angular\.)[^\.])+)\.directive:([^\.]+)$/,
+    MODULE_DIRECTIVE_INPUT = /^((?:(?!^angular\.)[^\.])+)\.directive:input\.([^\.]+)$/,
+    MODULE_FILTER = /^((?:(?!^angular\.)[^\.])+)\.filter:([^\.]+)$/,
+    MODULE_SERVICE = /^((?:(?!^angular\.)[^\.])+)\.([^\.]+?)(Provider)?$/,
+    MODULE_TYPE = /^((?:(?!^angular\.)[^\.])+)\..+\.([A-Z][^\.]+)$/;
+
 
 function title(text) {
   if (!text) return text;
@@ -728,7 +729,7 @@ function scenarios(docs){
 function metadata(docs){
   var pages = [];
   docs.forEach(function(doc){
-    var path = (doc.name || '').split(/(\.|\:\s+)/);
+    var path = (doc.name || '').split(/(\.|\:)/);
     for ( var i = 1; i < path.length; i++) {
       path.splice(i, 1);
     }
diff --git a/docs/src/templates/js/docs.js b/docs/src/templates/js/docs.js
index 5bcb9f6d..2eaa7c29 100644
--- a/docs/src/templates/js/docs.js
+++ b/docs/src/templates/js/docs.js
@@ -229,18 +229,18 @@ docsApp.controller.DocsController = function($scope, $location, $window, $cookie
   var OFFLINE_COOKIE_NAME = 'ng-offline',
       DOCS_PATH = /^\/(api)|(guide)|(cookbook)|(misc)|(tutorial)/,
       INDEX_PATH = /^(\/|\/index[^\.]*.html)$/,
-      GLOBALS = /^angular\.([^\.]*)$/,
-      MODULE = /^angular\.module\.([^\.]*)$/,
-      MODULE_MOCK = /^angular\.mock\.([^\.]*)$/,
-      MODULE_DIRECTIVE = /^angular\.module\.([^\.]*)(?:\.\$compileProvider)?\.directive\.([^\.]*)$/,
-      MODULE_DIRECTIVE_INPUT = /^angular\.module\.([^\.]*)\.\$compileProvider\.directive\.input\.([^\.]*)$/,
-      MODULE_FILTER = /^angular\.module\.([^\.]*)\.\$?filter\.([^\.]*)$/,
-      MODULE_SERVICE = /^angular\.module\.([^\.]*)\.([^\.]*?)(Provider)?$/,
-      MODULE_TYPE = /^angular\.module\.([^\.]*)\..*\.([A-Z][^\.]*)$/,
+      GLOBALS = /^angular\.([^\.]+)$/,
+      MODULE = /^((?:(?!^angular\.)[^\.])+)$/,
+      MODULE_MOCK = /^angular\.mock\.([^\.]+)$/,
+      MODULE_DIRECTIVE = /^((?:(?!^angular\.)[^\.])+)\.directive:([^\.]+)$/,
+      MODULE_DIRECTIVE_INPUT = /^((?:(?!^angular\.)[^\.])+)\.directive:input\.([^\.]+)$/,
+      MODULE_FILTER = /^((?:(?!^angular\.)[^\.])+)\.filter:([^\.]+)$/,
+      MODULE_SERVICE = /^((?:(?!^angular\.)[^\.])+)\.([^\.]+?)(Provider)?$/,
+      MODULE_TYPE = /^((?:(?!^angular\.)[^\.])+)\..+\.([A-Z][^\.]+)$/,
       URL = {
         module: 'guide/module',
         directive: 'guide/directive',
-        input: 'api/angular.module.ng.$compileProvider.directive.input',
+        input: 'api/ng.directive:input',
         filter: 'guide/dev_guide.templates.filters',
         service: 'guide/dev_guide.services',
         type: 'guide/types'
@@ -325,22 +325,22 @@ docsApp.controller.DocsController = function($scope, $location, $window, $cookie
           breadcrumb.push({ name: partialId });
         } else if (match = partialId.match(MODULE)) {
           breadcrumb.push({ name: match[1] });
-        } else if (match = partialId.match(MODULE_SERVICE)) {
-          breadcrumb.push({ name: match[1], url: sectionId + '/angular.module.' + match[1] });
-          breadcrumb.push({ name: match[2] });
         } else if (match = partialId.match(MODULE_FILTER)) {
-          breadcrumb.push({ name: match[1], url: sectionId + '/angular.module.' + match[1] });
+          breadcrumb.push({ name: match[1], url: sectionId + '/' + match[1] });
           breadcrumb.push({ name: match[2] });
         } else if (match = partialId.match(MODULE_DIRECTIVE)) {
-          breadcrumb.push({ name: match[1], url: sectionId + '/angular.module.' + match[1] });
+          breadcrumb.push({ name: match[1], url: sectionId + '/' + match[1] });
           breadcrumb.push({ name: match[2] });
         } else if (match = partialId.match(MODULE_DIRECTIVE_INPUT)) {
-          breadcrumb.push({ name: match[1], url: sectionId + '/angular.module.' + match[1] });
+          breadcrumb.push({ name: match[1], url: sectionId + '/' + match[1] });
           breadcrumb.push({ name: 'input', url: URL.input });
           breadcrumb.push({ name: match[2] });
         } else if (match = partialId.match(MODULE_TYPE)) {
-          breadcrumb.push({ name: match[1], url: sectionId + '/angular.module.' + match[1] });
+          breadcrumb.push({ name: match[1], url: sectionId + '/' + match[1] });
           breadcrumb.push({ name: match[2] });
+        }  else if (match = partialId.match(MODULE_SERVICE)) {
+          breadcrumb.push({ name: match[1], url: sectionId + '/' + match[1] });
+          breadcrumb.push({ name: match[2] + (match[3] || '') });
         } else if (match = partialId.match(MODULE_MOCK)) {
           breadcrumb.push({ name: 'angular.mock.' + match[1] });
         } else {
@@ -405,26 +405,28 @@ docsApp.controller.DocsController = function($scope, $location, $window, $cookie
         bestMatch = match;
       }
 
-      if (id == 'angular.Module') {
+      if (page.id == 'index') {
+        //skip
+      } else if (page.section != 'api') {
+        otherPages.push(page);
+      } else if (id == 'angular.Module') {
         module('ng').types.push(page);
       } else if (match = id.match(GLOBALS)) {
         module('ng').globals.push(page);
       } else if (match = id.match(MODULE)) {
         module(match[1]);
-      } else if (match = id.match(MODULE_SERVICE)) {
-        module(match[1]).service(match[2])[match[3] ? 'provider' : 'instance'] = page;
       } else if (match = id.match(MODULE_FILTER)) {
         module(match[1]).filters.push(page);
       } else if (match = id.match(MODULE_DIRECTIVE)) {
         module(match[1]).directives.push(page);
       } else if (match = id.match(MODULE_DIRECTIVE_INPUT)) {
         module(match[1]).directives.push(page);
+      } else if (match = id.match(MODULE_SERVICE)) {
+        module(match[1]).service(match[2])[match[3] ? 'provider' : 'instance'] = page;
       } else if (match = id.match(MODULE_TYPE)) {
         module(match[1]).types.push(page);
       } else if (match = id.match(MODULE_MOCK)) {
         module('ngMock').globals.push(page);
-      } else if (page.section != 'api' && page.id != 'index'){
-        otherPages.push(page);
       }
 
     });
@@ -438,7 +440,7 @@ docsApp.controller.DocsController = function($scope, $location, $window, $cookie
       if (!module) {
         module = cache[name] = {
           name: name,
-          url: 'api/angular.module.' + name,
+          url: 'api/' + name,
           globals: [],
           directives: [],
           services: [],
-- 
cgit v1.2.3