aboutsummaryrefslogtreecommitdiffstats
path: root/docs/src/gen-docs.js
diff options
context:
space:
mode:
authorDi Peng2011-07-09 18:15:40 -0700
committerIgor Minar2011-07-20 17:33:18 -0700
commit8fa066190af2b2267a5e8111a41beb6e8af5c340 (patch)
tree221e9b67892b9b09047ae8a8b6b50f5cbc9e2ead /docs/src/gen-docs.js
parente90b741c9492a65e159c842afe49383f1868308e (diff)
downloadangular.js-8fa066190af2b2267a5e8111a41beb6e8af5c340.tar.bz2
refactor(gen-docs): use q, qq, q-fs (node modules) to write gen-docs
- re-write gendocs.js, reader.js and writer.js - all calls are asynchronous
Diffstat (limited to 'docs/src/gen-docs.js')
-rwxr-xr-xdocs/src/gen-docs.js139
1 files changed, 63 insertions, 76 deletions
diff --git a/docs/src/gen-docs.js b/docs/src/gen-docs.js
index 8ed0c563..2cbc9267 100755
--- a/docs/src/gen-docs.js
+++ b/docs/src/gen-docs.js
@@ -3,90 +3,77 @@ require.paths.push('lib');
var reader = require('reader.js'),
ngdoc = require('ngdoc.js'),
writer = require('writer.js'),
- callback = require('callback.js'),
SiteMap = require('SiteMap.js').SiteMap,
- appCache = require('appCache.js');
+ appCache = require('appCache.js').appCache,
+ Q = require('qq');
-var docs = [];
-var start;
-var work = callback.chain(function(){
- start = now();
- console.log('Generating Angular Reference Documentation...');
- reader.collect(work.waitMany(function(text, file, line){
- var doc = new ngdoc.Doc(text, file, line);
- docs.push(doc);
- doc.parse();
- }));
+process.on('uncaughtException', function (err) {
+ console.error(err.stack || err);
});
-var writes = callback.chain(function(){
+
+var start = now();
+var docs;
+
+writer.makeDir('build/docs/syntaxhighlighter').then(function() {
+ console.log('Generating Angular Reference Documentation...');
+ return reader.collect();
+}).then(function generateHtmlDocPartials(docs_) {
+ docs = docs_;
ngdoc.merge(docs);
+ var fileFutures = [];
docs.forEach(function(doc){
- writer.output(doc.section + '/' + doc.id + '.html', doc.html(), writes.waitFor());
+ fileFutures.push(writer.output(doc.section + '/' + doc.id + '.html', doc.html()));
});
+
+ writeTheRest(fileFutures);
+
+ return Q.deep(fileFutures);
+}).then(function generateManifestFile() {
+ return appCache('build/docs/').then(function(list) {
+ writer.output('appcache-offline.manifest',list)
+ });
+}).then(function printStats() {
+ console.log('DONE. Generated ' + docs.length + ' pages in ' + (now()-start) + 'ms.' );
+}).end();
+
+
+function writeTheRest(writesFuture) {
var metadata = ngdoc.metadata(docs);
- writer.output('docs-keywords.js', ['NG_PAGES=', JSON.stringify(metadata).replace(/{/g, '\n{'), ';'], writes.waitFor());
- writer.copyDir('img', writes.waitFor());
- writer.copyDir('examples', writes.waitFor());
- writer.copyTpl('index.html', writes.waitFor());
- writer.copyTpl('.htaccess', writes.waitFor());
- writer.copy('docs/src/templates/index.html', 'build/docs/index-jq.html', writes.waitFor(),
- '<-- jquery place holder -->', '<script src=\"jquery.min.js\"><\/script>');
- writer.copyTpl('offline.html', writes.waitFor());
- //writer.output('app-cache.manifest',
- // appCacheTemplate().replace(/%TIMESTAMP%/, (new Date()).toISOString()),
- // 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.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());
- writer.output('app-cache.manifest', appCache('build/docs/'), writes.waitFor());
-});
-writes.onDone(function(){
- console.log('DONE. Generated ' + docs.length + ' pages in ' +
- (now()-start) + 'ms.' );
-});
-work.onDone(writes);
-writer.makeDir('build/docs/syntaxhighlighter', work);
-///////////////////////////////////
-function now(){ return new Date().getTime(); }
+ writesFuture.push(writer.copyDir('img'));
+ writesFuture.push(writer.copyDir('examples'));
+ writesFuture.push(writer.copyTpl('index.html'));
+ writesFuture.push(writer.copy('docs/src/templates/index.html',
+ 'build/docs/index-jq.html',
+ '<!-- jquery place holder -->',
+ '<script src=\"jquery.min.js\"><\/script>'));
+ writesFuture.push(writer.copyTpl('offline.html'));
+ writesFuture.push(writer.copyTpl('docs-scenario.html'));
+ writesFuture.push(writer.copyTpl('jquery.min.js'));
+ writesFuture.push(writer.output('docs-keywords.js',
+ ['NG_PAGES=', JSON.stringify(metadata).replace(/{/g, '\n{'), ';']));
+ writesFuture.push(writer.output('sitemap.xml', new SiteMap(docs).render()));
+ writesFuture.push(writer.output('docs-scenario.js', ngdoc.scenarios(docs)));
+ writesFuture.push(writer.output('robots.txt', 'Sitemap: http://docs.angularjs.org/sitemap.xml\n'));
+ writesFuture.push(writer.output('appcache.manifest',appCache()));
-function appCacheTemplate() {
- return ["CACHE MANIFEST",
- "# %TIMESTAMP%",
- "",
- "# cache all of these",
- "CACHE:",
- "syntaxhighlighter/syntaxhighlighter-combined.js",
- "../angular.min.js",
- "docs-combined.js",
- "docs-keywords.js",
- "docs-combined.css",
- "syntaxhighlighter/syntaxhighlighter-combined.css",
- "",
- "FALLBACK:",
- "/ offline.html",
- "",
- "# allow access to google analytics and twitter when we are online",
- "NETWORK:",
- "*"].join('\n');
+ writesFuture.push(writer.merge(['docs.js',
+ 'doc_widgets.js'],
+ 'docs-combined.js'));
+ writesFuture.push(writer.merge(['docs.css',
+ 'doc_widgets.css'],
+ 'docs-combined.css'));
+ writesFuture.push(writer.merge(['syntaxhighlighter/shCore.js',
+ 'syntaxhighlighter/shBrushJScript.js',
+ 'syntaxhighlighter/shBrushXml.js'],
+ 'syntaxhighlighter/syntaxhighlighter-combined.js'));
+ writesFuture.push(writer.merge(['syntaxhighlighter/shCore.css',
+ 'syntaxhighlighter/shThemeDefault.css'],
+ 'syntaxhighlighter/syntaxhighlighter-combined.css'));
}
+
+
+function now(){ return new Date().getTime(); }
+
+function noop(){};