From 11e9572b952e49b01035e956c412d6095533031a Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 29 Apr 2011 15:18:27 -0700 Subject: Move documentation under individual headings --- docs/src/ngdoc.js | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'docs/src/ngdoc.js') diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js index 57202809..869fe4c5 100644 --- a/docs/src/ngdoc.js +++ b/docs/src/ngdoc.js @@ -36,7 +36,6 @@ Doc.METADATA_IGNORE = (function(){ })(); - Doc.prototype = { keywords: function keywords(){ var keywords = {}; @@ -57,6 +56,38 @@ Doc.prototype = { return words.join(' '); }, + + /* + * This function is here to act as a huristic based translator from the old style urls to + * the new style which use sections. + */ + sectionHuristic: function (url){ + // if we are new styl URL with section/id then just return; + if (url.match(/\//)) return url; + var match = url.match(/(\w+)(\.(.*))?/); + var section = match[1]; + var id = match[3] || 'index'; + switch(section) { + case 'angular': + section = 'api'; + id = 'angular.' + id; + break; + case 'api': + case 'cookbook': + case 'guide': + case 'intro': + case 'tutorial': + break; + default: + id = section + '.' + id; + section = 'intro'; + } + var newUrl = section + '/' + (id || 'index'); + console.log('WARNING:', 'found old style url', url, 'at', this.file, this.line, + 'converting to', newUrl); + return newUrl; + }, + markdown: function (text) { var self = this; var IS_URL = /^(https?:\/\/|ftps?:\/\/|mailto:|\.|\/)/; @@ -70,7 +101,7 @@ Doc.prototype = { parts.forEach(function(text, i){ if (text.match(/^
/)) {
         text = text.replace(/^
([\s\S]*)<\/pre>/mi, function(_, content){
-          var clazz = 'brush: js;'
+          var clazz = 'brush: js;';
           if (content.match(/\<\w/)) {
             // we are HTML
             clazz += ' html-script: true;';
@@ -93,7 +124,8 @@ Doc.prototype = {
         text = text.replace(//gm, '<angular/>');
         text = text.replace(/{@link\s+([^\s}]+)\s*([^}]*?)\s*}/g,
           function(_all, url, title){
-            return ''
+            var isFullUrl = url.match(IS_URL);
+            return ''
               + (url.match(IS_ANGULAR) ? '' : '')
               + (title || url).replace(/\n/g, ' ')
               + (url.match(IS_ANGULAR) ? '' : '')
@@ -525,6 +557,7 @@ function metadata(docs){
     var depth = path.length - 1;
     var shortName = path.pop();
     words.push({
+      section: doc.section,
       id: doc.id,
       name: doc.name,
       depth: depth,
@@ -538,7 +571,7 @@ function metadata(docs){
 }
 
 var KEYWORD_PRIORITY = {
-  '.started': 1,
+  '.index': 1,
   '.guide': 2,
   '.guide.overview': 1,
   '.angular': 7,
@@ -562,7 +595,7 @@ function keywordSort(a, b){
       mangled.push(KEYWORD_PRIORITY[partialName] || 5);
       mangled.push(name);
     });
-    return mangled.join('.');
+    return doc.section + '/' + mangled.join('.');
   }
   var nameA = mangleName(a);
   var nameB = mangleName(b);
-- 
cgit v1.2.3