From 564fad86f40eb8b5b3f6a5dcb04a07c02878d61e Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Fri, 11 Nov 2011 16:40:43 -0800 Subject: [PATCH 1/4] feat(docs): allow custom attributes on Allow any attributes, not only jsfiddle... --- docs/spec/ngdocSpec.js | 8 ++++++++ docs/src/ngdoc.js | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/spec/ngdocSpec.js b/docs/spec/ngdocSpec.js index 72ad69ff4442..367f91b4fbbb 100644 --- a/docs/spec/ngdocSpec.js +++ b/docs/spec/ngdocSpec.js @@ -89,6 +89,14 @@ describe('ngdoc', function() { '
\n<>\n

after

'); }); + it('should preserve the source attribute', function() { + var doc = new Doc('@description before ' + + 'lala after'); + doc.parse(); + expect(doc.description).toContain('

before

' + + '
lala

after

'); + }); + it('should preserve the jsfiddle attribute', function() { var doc = new Doc('@description before ' + 'lala after'); diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js index c5da18e68d85..3ed9198aa231 100644 --- a/docs/src/ngdoc.js +++ b/docs/src/ngdoc.js @@ -117,9 +117,9 @@ Doc.prototype = { ''; }); } else if (isDocWidget('example')) { - text = text.replace(/([\s\S]*)<\/doc:source>/mi, - function(_, jsfiddle, content){ - return '
' +
+        text = text.replace(/]*)?>([\s\S]*)<\/doc:source>/mi,
+          function(_, attrs, content){
+            return '
' +
                       htmlEscape(content) +
                    '
'; }); From 3137e56ca0ddcd510fe03a1854ef719e06f63acb Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Fri, 11 Nov 2011 16:50:19 -0800 Subject: [PATCH 2/4] feat(docs): allow examples with hidden source code --- docs/src/templates/doc_widgets.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/src/templates/doc_widgets.js b/docs/src/templates/doc_widgets.js index 1890e93a2520..6ae829175f26 100644 --- a/docs/src/templates/doc_widgets.js +++ b/docs/src/templates/doc_widgets.js @@ -28,19 +28,28 @@ //jqlite instead. jqlite's find() method currently supports onlt getElementsByTagName! var example = element.find('pre').eq(0), //doc-source exampleSrc = example.text(), + showSource = example.attr('source') !== 'false', jsfiddle = example.attr('jsfiddle') || true, scenario = element.find('pre').eq(1); //doc-scenario var code = indent(exampleSrc); var tabHtml = - '
    ' + + '
      '; + + // show source tab, if not disabled + if (showSource) { + tabHtml += '
    • Source

    • ' + '
    • ' + jsFiddleButton(jsfiddle) + // may or may not have value '
    • ' + + code.hilite + ']; toolbar: false;">
'; + } + // show live preview tab + tabHtml += '
  • Live Preview

  • ' + '
  • ' + exampleSrc +'
  • '; + // show scenario tab, if present if (scenario.text()) { tabHtml += '
  • Scenario Test

  • ' + From 25e291c229a91fb4aab3631aff023590a41b5297 Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Fri, 11 Nov 2011 17:08:25 -0800 Subject: [PATCH 3/4] fix(docs.guide): fix $location example --- .../guide/dev_guide.services.$location.ngdoc | 24 +++++++++++-------- docs/src/templates/docs.css | 11 --------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/docs/content/guide/dev_guide.services.$location.ngdoc b/docs/content/guide/dev_guide.services.$location.ngdoc index 5bce8b0c4fbc..5174751669e7 100644 --- a/docs/content/guide/dev_guide.services.$location.ngdoc +++ b/docs/content/guide/dev_guide.services.$location.ngdoc @@ -369,8 +369,10 @@ redirect to regular / hashbang url, as this conversion happens only during parsi In this examples we use `` - + +
    + + # Caveats diff --git a/docs/src/templates/docs.css b/docs/src/templates/docs.css index 7f1cea8ea689..d42ec093ebaa 100644 --- a/docs/src/templates/docs.css +++ b/docs/src/templates/docs.css @@ -467,17 +467,6 @@ td.empty-corner-lt { } /* service.$location Html5 mode example */ -.html5-hashbang-example { - height: 255px; - margin-left: -40px; - padding-left: 30px; -} - -.html5-hashbang-example div { - float: left; - width: 375px; -} - .html5-hashbang-example div input { width: 360px; } From bd5c69150fe45c63e4e69ade588e8fb6864187fb Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Fri, 11 Nov 2011 17:15:22 -0800 Subject: [PATCH 4/4] style(docs): make jslint happy - fix some warnings --- docs/src/ngdoc.js | 30 +++++++++++++++--------------- docs/src/templates/doc_widgets.js | 16 +++++++++------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js index 3ed9198aa231..562144b517c2 100644 --- a/docs/src/ngdoc.js +++ b/docs/src/ngdoc.js @@ -138,11 +138,11 @@ Doc.prototype = { if (!isFullUrl) self.links.push(absUrl); - return '' - + (isAngular ? '' : '') - + (title || url).replace(/\n/g, ' ') - + (isAngular ? '' : '') - + ''; + return '' + + (isAngular ? '' : '') + + (title || url).replace(/\n/g, ' ') + + (isAngular ? '' : '') + + ''; }); text = new Showdown.converter().makeHtml(text); } @@ -157,7 +157,7 @@ Doc.prototype = { var match; var self = this; self.text.split(NEW_LINE).forEach(function(line){ - if (match = line.match(/^\s*@(\w+)(\s+(.*))?/)) { + if ((match = line.match(/^\s*@(\w+)(\s+(.*))?/))) { // we found @name ... // if we have existing name flush(); @@ -172,9 +172,9 @@ Doc.prototype = { }); flush(); this.shortName = (this.name || '').split(/[\.#]/).pop(); - this.id = this.id // if we have an id just use it - || (((this.file||'').match(/.*\/([^\/]*)\.ngdoc/)||{})[1]) // try to extract it from file name - || this.name; // default to name + this.id = this.id || // if we have an id just use it + (((this.file||'').match(/.*\/([^\/]*)\.ngdoc/)||{})[1]) || // try to extract it from file name + this.name; // default to name this.description = this.markdown(this.description); this.example = this.markdown(this.example); this['this'] = this.markdown(this['this']); @@ -182,9 +182,9 @@ Doc.prototype = { function flush() { if (atName) { - var text = trim(atText.join('\n')); + var text = trim(atText.join('\n')), match; if (atName == 'param') { - var match = text.match(/^{([^}=]+)(=)?}\s+(([^\s=]+)|\[(\S+)=([^\]]+)\])\s+(.*)/); + match = text.match(/^\{([^}=]+)(=)?\}\s+(([^\s=]+)|\[(\S+)=([^\]]+)\])\s+(.*)/); // 1 12 2 34 4 5 5 6 6 3 7 7 if (!match) { throw new Error("Not a valid 'param' format: " + text); @@ -198,7 +198,7 @@ Doc.prototype = { }; self.param.push(param); } else if (atName == 'returns') { - var match = text.match(/^{([^}=]+)}\s+(.*)/); + match = text.match(/^\{([^}=]+)\}\s+(.*)/); if (!match) { throw new Error("Not a valid 'returns' format: " + text); } @@ -207,13 +207,13 @@ Doc.prototype = { description: self.markdown(text.replace(match[0], match[2])) }; } else if(atName == 'requires') { - var match = text.match(/^([^\s]*)\s*([\S\s]*)/); + match = text.match(/^([^\s]*)\s*([\S\s]*)/); self.requires.push({ name: match[1], text: self.markdown(match[2]) }); } else if(atName == 'property') { - var match = text.match(/^{(\S+)}\s+(\S+)(\s+(.*))?/); + match = text.match(/^\{(\S+)\}\s+(\S+)(\s+(.*))?/); if (!match) { throw new Error("Not a valid 'property' format: " + text); } @@ -224,7 +224,7 @@ Doc.prototype = { }; self.properties.push(property); } else if(atName == 'eventType') { - var match = text.match(/^([^\s]*)\s+on\s+([\S\s]*)/); + match = text.match(/^([^\s]*)\s+on\s+([\S\s]*)/); self.type = match[1]; self.target = match[2]; } else { diff --git a/docs/src/templates/doc_widgets.js b/docs/src/templates/doc_widgets.js index 6ae829175f26..56ef5bcf4ffb 100644 --- a/docs/src/templates/doc_widgets.js +++ b/docs/src/templates/doc_widgets.js @@ -78,14 +78,14 @@ function jsFiddleButton(jsfiddle) { if (jsfiddle !== 'false') { - if(jsfiddle == true) { + if(jsfiddle === true) { //dynamically generate a fiddle var fiddleUrl = 'http://jsfiddle.net/api/post/library/pure/', fiddleSrc = exampleSrc, stripIndent = fiddleSrc.match(/^(\s*)/)[1].length; //escape closing textarea - fiddleSrc = fiddleSrc.replace(/<\/textarea>/gi,'</textarea>') + fiddleSrc = fiddleSrc.replace(/<\/textarea>/gi,'</textarea>'); //strip extra indentation fiddleSrc = fiddleSrc.replace(new RegExp('^\\s{' + stripIndent + '}', 'gm'), ''); @@ -122,12 +122,14 @@ if (!text) return text; var lines = text.split(/\r?\n/); var lineNo = []; + var i; + // remove any leading blank lines while (lines[0].match(/^\s*$/)) lines.shift(); // remove any trailing blank lines while (lines[lines.length - 1].match(/^\s*$/)) lines.pop(); var minIndent = 999; - for ( var i = 0; i < lines.length; i++) { + for (i = 0; i < lines.length; i++) { var line = lines[0]; var indent = line.match(/^\s*/)[0]; if (indent !== line && indent.length < minIndent) { @@ -135,12 +137,12 @@ } } - for ( var i = 0; i < lines.length; i++) { + for (i = 0; i < lines.length; i++) { lines[i] = ' ' + lines[i].substring(minIndent); lineNo.push(5 + i); } return {html: lines.join('\n'), hilite: lineNo.join(',') }; - }; + } var HTML_TPL = '

    Workspace Reset Instructions  ➤

    ' + @@ -208,8 +210,8 @@ if (children.length) { // load custom content angular.forEach(element.children(), function(elm) { - var elm = angular.element(elm), - id = elm.attr('id'); + elm = angular.element(elm); + var id = elm.attr('id'); nav.append(HTML_NAV.replace('{title}', elm.attr('title')).replace(/\{id\}/g, id)); content.append(HTML_CONTENT.replace('{id}', id).replace('{content}', elm.html())); pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy