aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDi Peng2011-08-19 12:06:59 -0700
committerIgor Minar2011-08-19 13:29:26 -0700
commitac6e1306ec2126f9c8e67b4a26d8f03001abf73d (patch)
treece76b6bda2e7ce8b6eeb8b67dc26b54a2ff40622
parente004378d100ce767a1107180102790a9a360644e (diff)
downloadangular.js-ac6e1306ec2126f9c8e67b4a26d8f03001abf73d.tar.bz2
fix(sample): Fix for jsFiddle integration
-rw-r--r--docs/spec/ngdocSpec.js8
-rw-r--r--docs/src/ngdoc.js8
-rw-r--r--docs/src/templates/doc_widgets.js2
3 files changed, 14 insertions, 4 deletions
diff --git a/docs/spec/ngdocSpec.js b/docs/spec/ngdocSpec.js
index a184c5df..f16bef46 100644
--- a/docs/spec/ngdocSpec.js
+++ b/docs/spec/ngdocSpec.js
@@ -89,6 +89,14 @@ describe('ngdoc', function(){
'<pre class="doc-source">\n&lt;&gt;\n</pre></doc:example><p>after</p>');
});
+ it('should preserve the jsfiddle attribute', function(){
+ var doc = new Doc('@description before <doc:example>' +
+ '<doc:source jsfiddle="foo">lala</doc:source></doc:example> after');
+ doc.parse();
+ expect(doc.description).toContain('<p>before </p><doc:example>' +
+ '<pre class="doc-source" jsfiddle="foo">lala</pre></doc:example><p>after</p>');
+ });
+
it('should escape <doc:scenario> element', function(){
var doc = new Doc('@description before <doc:example>' +
'<doc:scenario>\n<>\n</doc:scenario></doc:example> after');
diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js
index 91c4662a..8fcf3cd5 100644
--- a/docs/src/ngdoc.js
+++ b/docs/src/ngdoc.js
@@ -111,9 +111,11 @@ Doc.prototype = {
'</pre></div>';
});
} 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>';
+ text = text.replace(/<doc:source(\s+jsfiddle="[^"]+")?>([\s\S]*)<\/doc:source>/mi,
+ function(_, jsfiddle, content){
+ return '<pre class="doc-source"' + (jsfiddle || '') +'>' +
+ htmlEscape(content) +
+ '</pre>';
});
text = text.replace(/(<doc:scenario>)([\s\S]*)(<\/doc:scenario>)/mi,
function(_, before, content, after){
diff --git a/docs/src/templates/doc_widgets.js b/docs/src/templates/doc_widgets.js
index 31600ccc..a5579720 100644
--- a/docs/src/templates/doc_widgets.js
+++ b/docs/src/templates/doc_widgets.js
@@ -28,7 +28,7 @@
//jqlite instead. jqlite's find() method currently supports onlt getElementsByTagName!
var example = element.find('pre').eq(0), //doc-source
exampleSrc = example.text(),
- jsfiddle = element.find('doc:source').attr('jsfiddle') || true,
+ jsfiddle = example.attr('jsfiddle') || true,
scenario = element.find('pre').eq(1); //doc-scenario
var code = indent(exampleSrc);