aboutsummaryrefslogtreecommitdiffstats
path: root/docs/src/ngdoc.js
diff options
context:
space:
mode:
authorVojta Jina2011-05-24 00:49:33 +0200
committerIgor Minar2011-06-06 22:52:01 -0700
commit2da07127e45312ce22d894aa771b8797e9a301a1 (patch)
treecc588b8fbdb5792c908b2b216bc9b9ab12c84663 /docs/src/ngdoc.js
parentd05e83992023c0aa8c663ac187529abf45dfe533 (diff)
downloadangular.js-2da07127e45312ce22d894aa771b8797e9a301a1.tar.bz2
Add doc:tutorial-instructions widget
Diffstat (limited to 'docs/src/ngdoc.js')
-rw-r--r--docs/src/ngdoc.js27
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, '&lt;').replace(/>/g, '&gt;') +
'</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>&lt;angular/&gt;</tt>');
text = text.replace(/{@link\s+([^\s}]+)\s*([^}]*?)\s*}/g,
function(_all, url, title){