diff options
| author | Vojta Jina | 2011-05-24 00:49:33 +0200 | 
|---|---|---|
| committer | Igor Minar | 2011-06-06 22:52:01 -0700 | 
| commit | 2da07127e45312ce22d894aa771b8797e9a301a1 (patch) | |
| tree | cc588b8fbdb5792c908b2b216bc9b9ab12c84663 /docs/src/ngdoc.js | |
| parent | d05e83992023c0aa8c663ac187529abf45dfe533 (diff) | |
| download | angular.js-2da07127e45312ce22d894aa771b8797e9a301a1.tar.bz2 | |
Add doc:tutorial-instructions widget
Diffstat (limited to 'docs/src/ngdoc.js')
| -rw-r--r-- | docs/src/ngdoc.js | 27 | 
1 files changed, 19 insertions, 8 deletions
| diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js index fa3fbdac..61ac6f78 100644 --- a/docs/src/ngdoc.js +++ b/docs/src/ngdoc.js @@ -78,16 +78,27 @@ Doc.prototype = {    },    markdown: function (text) { -    var self = this; -    var IS_URL = /^(https?:\/\/|ftps?:\/\/|mailto:|\.|\/)/; -    var IS_ANGULAR = /^angular\./;      if (!text) return text; -    text = trim(text); +    var self = this, +        IS_URL = /^(https?:\/\/|ftps?:\/\/|mailto:|\.|\/)/, +        IS_ANGULAR = /^angular\./, +        parts = trim(text).split(/(<pre>[\s\S]*?<\/pre>|<doc:(\S*).*?>[\s\S]*?<\/doc:\2>)/); + +    parts.forEach(function(text, i) { + +      function isDocWidget(name) { +        if ((i + 1) % 3 != 2) return false; +        if (name) return parts[i+1] == name; +        return !!parts[i+1]; +      } -    var parts = text.split(/(<pre>[\s\S]*?<\/pre>|<doc:example>[\s\S]*?<\/doc:example>)/); +      // ignore each third item which is doc widget tag +      if (!((i + 1) % 3)) { +        parts[i] = ''; +        return; +      } -    parts.forEach(function(text, i){        if (text.match(/^<pre>/)) {          text = text.replace(/^<pre>([\s\S]*)<\/pre>/mi, function(_, content){            var clazz = 'brush: js;'; @@ -99,7 +110,7 @@ Doc.prototype = {                    content.replace(/</g, '<').replace(/>/g, '>') +                   '</pre></div>';          }); -      } else if (text.match(/^<doc:example>/)) { +      } else if (isDocWidget('example')) {          text = text.replace(/(<doc:source>)([\s\S]*)(<\/doc:source>)/mi,            function(_, before, content, after){              return '<pre class="doc-source">' + htmlEscape(content) + '</pre>'; @@ -109,7 +120,7 @@ Doc.prototype = {              self.scenarios.push(content);              return '<pre class="doc-scenario">' + htmlEscape(content) + '</pre>';            }); -      } else { +      } else if (!isDocWidget()) {          text = text.replace(/<angular\/>/gm, '<tt><angular/></tt>');          text = text.replace(/{@link\s+([^\s}]+)\s*([^}]*?)\s*}/g,            function(_all, url, title){ | 
