diff options
| author | Misko Hevery | 2011-04-29 15:18:27 -0700 |
|---|---|---|
| committer | Igor Minar | 2011-06-06 22:28:38 -0700 |
| commit | 11e9572b952e49b01035e956c412d6095533031a (patch) | |
| tree | 04dbf96802f552693d44c541c0d825a2769e3d57 /docs/src/ngdoc.js | |
| parent | b6bc6c2ddf1ae1523ec7e4cb92db209cd6501181 (diff) | |
| download | angular.js-11e9572b952e49b01035e956c412d6095533031a.tar.bz2 | |
Move documentation under individual headings
Diffstat (limited to 'docs/src/ngdoc.js')
| -rw-r--r-- | docs/src/ngdoc.js | 43 |
1 files changed, 38 insertions, 5 deletions
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(/^<pre>/)) { text = text.replace(/^<pre>([\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(/<angular\/>/gm, '<tt><angular/></tt>'); text = text.replace(/{@link\s+([^\s}]+)\s*([^}]*?)\s*}/g, function(_all, url, title){ - return '<a href="' + (url.match(IS_URL) ? '' : '#!') + url + '">' + var isFullUrl = url.match(IS_URL); + return '<a href="' + (isFullUrl ? '' + url : '#!' + self.sectionHuristic(url)) + '">' + (url.match(IS_ANGULAR) ? '<code>' : '') + (title || url).replace(/\n/g, ' ') + (url.match(IS_ANGULAR) ? '</code>' : '') @@ -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); |
