From 2da07127e45312ce22d894aa771b8797e9a301a1 Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Tue, 24 May 2011 00:49:33 +0200 Subject: Add doc:tutorial-instructions widget --- docs/src/ngdoc.js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'docs/src/ngdoc.js') 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(/(
[\s\S]*?<\/pre>|[\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(/(
[\s\S]*?<\/pre>|[\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(/^
/)) {
         text = text.replace(/^
([\s\S]*)<\/pre>/mi, function(_, content){
           var clazz = 'brush: js;';
@@ -99,7 +110,7 @@ Doc.prototype = {
                   content.replace(//g, '>') +
                  '
'; }); - } else if (text.match(/^/)) { + } else if (isDocWidget('example')) { text = text.replace(/()([\s\S]*)(<\/doc:source>)/mi, function(_, before, content, after){ return '
' + htmlEscape(content) + '
'; @@ -109,7 +120,7 @@ Doc.prototype = { self.scenarios.push(content); return '
' + htmlEscape(content) + '
'; }); - } else { + } else if (!isDocWidget()) { text = text.replace(//gm, '<angular/>'); text = text.replace(/{@link\s+([^\s}]+)\s*([^}]*?)\s*}/g, function(_all, url, title){ -- cgit v1.2.3