diff options
| author | Igor Minar | 2011-05-10 11:16:00 -0700 |
|---|---|---|
| committer | Igor Minar | 2011-06-06 22:51:58 -0700 |
| commit | 0fb37b08e778c348199a8a4909fad5ed9d920cdd (patch) | |
| tree | b42c4e682f4028679b36ceb6d27be775b7c46988 /docs/src | |
| parent | 8fa598fa0076c2a0013302ccdbddb5b4bb28fc45 (diff) | |
| download | angular.js-0fb37b08e778c348199a8a4909fad5ed9d920cdd.tar.bz2 | |
add resource merging
Diffstat (limited to 'docs/src')
| -rw-r--r-- | docs/src/gen-docs.js | 26 | ||||
| -rw-r--r-- | docs/src/templates/index.html | 13 | ||||
| -rw-r--r-- | docs/src/writer.js | 13 |
3 files changed, 34 insertions, 18 deletions
diff --git a/docs/src/gen-docs.js b/docs/src/gen-docs.js index 9edfaceb..1e5a09c4 100644 --- a/docs/src/gen-docs.js +++ b/docs/src/gen-docs.js @@ -27,19 +27,27 @@ var writes = callback.chain(function(){ writer.copyDir('img', writes.waitFor()); writer.copyDir('examples', writes.waitFor()); writer.copyTpl('index.html', writes.waitFor()); - writer.copyTpl('docs.js', writes.waitFor()); - writer.copyTpl('docs.css', writes.waitFor()); - writer.copyTpl('doc_widgets.js', writes.waitFor()); - writer.copyTpl('doc_widgets.css', writes.waitFor()); + writer.merge(['docs.js', + 'doc_widgets.js'], + 'docs-combined.js', + writes.waitFor()); + writer.merge(['docs.css', + 'doc_widgets.css'], + 'docs-combined.css', + writes.waitFor()); writer.copyTpl('docs-scenario.html', writes.waitFor()); writer.output('docs-scenario.js', ngdoc.scenarios(docs), writes.waitFor()); writer.output('sitemap.xml', new SiteMap(docs).render(), writes.waitFor()); writer.output('robots.txt', 'Sitemap: http://docs.angularjs.org/sitemap.xml\n', writes.waitFor()); - writer.copyTpl('syntaxhighlighter/shBrushJScript.js', writes.waitFor()); - writer.copyTpl('syntaxhighlighter/shBrushXml.js', writes.waitFor()); - writer.copyTpl('syntaxhighlighter/shCore.css', writes.waitFor()); - writer.copyTpl('syntaxhighlighter/shCore.js', writes.waitFor()); - writer.copyTpl('syntaxhighlighter/shThemeDefault.css', writes.waitFor()); + writer.merge(['syntaxhighlighter/shCore.js', + 'syntaxhighlighter/shBrushJScript.js', + 'syntaxhighlighter/shBrushXml.js'], + 'syntaxhighlighter/syntaxhighlighter-combined.js', + writes.waitFor()); + writer.merge(['syntaxhighlighter/shCore.css', + 'syntaxhighlighter/shThemeDefault.css'], + 'syntaxhighlighter/syntaxhighlighter-combined.css', + writes.waitFor()); writer.copyTpl('jquery.min.js', writes.waitFor()); }); writes.onDone(function(){ diff --git a/docs/src/templates/index.html b/docs/src/templates/index.html index 3e792af0..49449517 100644 --- a/docs/src/templates/index.html +++ b/docs/src/templates/index.html @@ -5,10 +5,8 @@ <head> <title ng:bind-template="<angular/>: {{partialTitle}}"><angular/></title> <meta name="fragment" content="!"> - <link rel="stylesheet" href="doc_widgets.css" type="text/css" /> - <link rel="stylesheet" href="docs.css" type="text/css"/> - <link rel="stylesheet" href="syntaxhighlighter/shCore.css" type="text/css"/> - <link rel="stylesheet" href="syntaxhighlighter/shThemeDefault.css" type="text/css"/> + <link rel="stylesheet" href="docs-combined.css" type="text/css"/> + <link rel="stylesheet" href="syntaxhighlighter/syntaxhighlighter-combined.css" type="text/css"/> <script> /*! * $script.js v1.3 @@ -20,14 +18,11 @@ !function(a,b,c){function w(a,c){var e=b.createElement("script"),f=0;e.onload=e[r]=function(){e[p]&&!!h.test(e[p])||f||(e.onload=e[r]=null,f=1,c())},e.async=1,e.src=a,d.parentNode.insertBefore(e,d)}function t(a,b){s(a,function(a){return!b(a)})}var d=b.getElementsByTagName("script")[0],e={},f={},g={},h=/^i|c/,i={},k="string",l=!1,m,n="push",o="DOMContentLoaded",p="readyState",q="addEventListener",r="onreadystatechange",s=function(a,b){for(m=0,j=a.length;m<j;++m)if(!b(a[m]))return 0;return 1};!b[p]&&b[q]&&(b[q](o,function u(){b.removeEventListener(o,u,l),b[p]="complete"},l),b[p]="loading");var v=function(a,b,d){function o(){if(!--l){e[k]=1,j&&j();for(var a in g)s(a.split("|"),m)&&!t(g[a],m)&&(g[a]=[])}}function m(a){return a.call?a():e[a]}a=a[n]?a:[a];var h=b&&b.call,j=h?b:d,k=h?a.join(""):b,l=a.length;c(function(){t(a,function(a){i[a]?(k&&(f[k]=1),o()):(i[a]=1,k&&(f[k]=1),w(v.path?v.path+a+".js":a,o))})},0);return v};v.get=w,v.ready=function(a,b,c){a=a[n]?a:[a];var d=[];!t(a,function(a){e[a]||d[n](a)})&&s(a,function(a){return e[a]})?b():!function(a){g[a]=g[a]||[],g[a][n](b),c&&c(d)}(a.join("|"));return v};var x=a.$script;v.noConflict=function(){a.$script=x;return this},typeof module!="undefined"&&module.exports?module.exports=v:a.$script=v}(this,document,setTimeout) $script([ 'jquery.min.js', - 'syntaxhighlighter/shCore.js'], function(){ + 'syntaxhighlighter/syntaxhighlighter-combined.js'], function(){ $script([ - 'syntaxhighlighter/shBrushJScript.js', - 'syntaxhighlighter/shBrushXml.js', '../angular.min.js'], function(){ $script([ - 'docs.js', - 'doc_widgets.js', + 'docs-combined.js', 'docs-keywords.js'], function(){ angular.compile(document)(); }); diff --git a/docs/src/writer.js b/docs/src/writer.js index 58d6a01d..48d42162 100644 --- a/docs/src/writer.js +++ b/docs/src/writer.js @@ -89,3 +89,16 @@ exports.copyDir = function copyDir(dir, callback) { })); })); }; + + +exports.merge = function(srcs, to, callback){ + merge(srcs.map(function(src) { return 'docs/src/templates/' + src }), OUTPUT_DIR + to, callback); +}; + +function merge(srcs, to, callback) { + var content = []; + srcs.forEach(function (src) { + content.push(fs.readFileSync(src)); + }); + fs.writeFile(to, content.join('\n'), callback.waitFor()); +} |
