2011-10-17 22:26:10 +00:00
|
|
|
var reader = require('./reader.js'),
|
|
|
|
|
ngdoc = require('./ngdoc.js'),
|
|
|
|
|
writer = require('./writer.js'),
|
|
|
|
|
SiteMap = require('./SiteMap.js').SiteMap,
|
|
|
|
|
appCache = require('./appCache.js').appCache,
|
2011-07-10 01:15:40 +00:00
|
|
|
Q = require('qq');
|
2010-12-22 23:44:27 +00:00
|
|
|
|
2011-10-07 18:27:49 +00:00
|
|
|
process.on('uncaughtException', function(err) {
|
2011-07-10 01:15:40 +00:00
|
|
|
console.error(err.stack || err);
|
2010-12-22 23:44:27 +00:00
|
|
|
});
|
2011-07-10 01:15:40 +00:00
|
|
|
|
|
|
|
|
var start = now();
|
|
|
|
|
var docs;
|
|
|
|
|
|
2012-08-28 19:53:30 +00:00
|
|
|
writer.makeDir('build/docs/', true).then(function() {
|
|
|
|
|
return writer.makeDir('build/docs/partials/');
|
|
|
|
|
}).then(function() {
|
|
|
|
|
console.log('Generating AngularJS Reference Documentation...');
|
2011-07-10 01:15:40 +00:00
|
|
|
return reader.collect();
|
|
|
|
|
}).then(function generateHtmlDocPartials(docs_) {
|
|
|
|
|
docs = docs_;
|
2010-12-22 23:44:27 +00:00
|
|
|
ngdoc.merge(docs);
|
2011-07-10 01:15:40 +00:00
|
|
|
var fileFutures = [];
|
2010-12-22 23:44:27 +00:00
|
|
|
docs.forEach(function(doc){
|
2012-01-16 07:28:10 +00:00
|
|
|
// this hack is here because on OSX angular.module and angular.Module map to the same file.
|
2012-08-20 15:28:04 +00:00
|
|
|
var id = doc.id.replace('angular.Module', 'angular.IModule').
|
|
|
|
|
replace(':', '_'); // rewrite : to _ to be GAE-friendly
|
2012-01-10 21:46:49 +00:00
|
|
|
fileFutures.push(writer.output('partials/' + doc.section + '/' + id + '.html', doc.html()));
|
2010-12-22 23:44:27 +00:00
|
|
|
});
|
2011-07-10 01:15:40 +00:00
|
|
|
|
|
|
|
|
writeTheRest(fileFutures);
|
|
|
|
|
|
|
|
|
|
return Q.deep(fileFutures);
|
|
|
|
|
}).then(function generateManifestFile() {
|
|
|
|
|
return appCache('build/docs/').then(function(list) {
|
2011-09-01 14:16:01 +00:00
|
|
|
writer.output('appcache-offline.manifest', list);
|
2011-07-10 01:15:40 +00:00
|
|
|
});
|
|
|
|
|
}).then(function printStats() {
|
|
|
|
|
console.log('DONE. Generated ' + docs.length + ' pages in ' + (now()-start) + 'ms.' );
|
|
|
|
|
}).end();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function writeTheRest(writesFuture) {
|
2010-12-22 23:44:27 +00:00
|
|
|
var metadata = ngdoc.metadata(docs);
|
|
|
|
|
|
2012-08-28 19:53:30 +00:00
|
|
|
writesFuture.push(writer.symlinkTemplate('css'));
|
|
|
|
|
writesFuture.push(writer.symlinkTemplate('font'));
|
2012-08-29 08:59:54 +00:00
|
|
|
writesFuture.push(writer.symlink('../../docs/img', 'build/docs/img'));
|
2012-08-28 19:53:30 +00:00
|
|
|
writesFuture.push(writer.symlinkTemplate('js'));
|
2011-08-20 15:51:00 +00:00
|
|
|
|
2011-08-30 09:47:24 +00:00
|
|
|
var manifest = 'manifest="/build/docs/appcache.manifest"';
|
2011-08-20 15:51:00 +00:00
|
|
|
|
2012-04-29 05:45:28 +00:00
|
|
|
writesFuture.push(writer.copy('docs/src/templates/index.html', 'index.html',
|
2012-01-17 20:13:29 +00:00
|
|
|
writer.replace, {'doc:manifest': ''})); //manifest //TODO(i): enable
|
2011-08-20 15:51:00 +00:00
|
|
|
|
2012-04-29 05:45:28 +00:00
|
|
|
writesFuture.push(writer.copy('docs/src/templates/index.html', 'index-nocache.html',
|
2011-09-21 00:47:12 +00:00
|
|
|
writer.replace, {'doc:manifest': ''}));
|
|
|
|
|
|
|
|
|
|
|
2012-04-29 05:45:28 +00:00
|
|
|
writesFuture.push(writer.copy('docs/src/templates/index.html', 'index-jq.html',
|
2012-08-25 09:30:55 +00:00
|
|
|
writer.replace, {'doc:manifest': ''}));
|
2011-08-20 15:51:00 +00:00
|
|
|
|
2012-04-29 05:45:28 +00:00
|
|
|
writesFuture.push(writer.copy('docs/src/templates/index.html', 'index-jq-nocache.html',
|
2011-09-21 00:47:12 +00:00
|
|
|
writer.replace, {'doc:manifest': ''}));
|
|
|
|
|
|
|
|
|
|
|
2012-04-29 05:45:28 +00:00
|
|
|
writesFuture.push(writer.copy('docs/src/templates/index.html', 'index-debug.html',
|
2011-08-30 09:47:24 +00:00
|
|
|
writer.replace, {'doc:manifest': ''}));
|
2011-08-20 15:51:00 +00:00
|
|
|
|
2012-04-29 05:45:28 +00:00
|
|
|
writesFuture.push(writer.copy('docs/src/templates/index.html', 'index-jq-debug.html',
|
2011-08-30 09:47:24 +00:00
|
|
|
writer.replace, {'doc:manifest': ''}));
|
2011-08-20 15:51:00 +00:00
|
|
|
|
2012-08-28 19:53:30 +00:00
|
|
|
writesFuture.push(writer.symlinkTemplate('offline.html'));
|
2011-06-07 19:53:40 +00:00
|
|
|
|
2012-08-28 19:53:30 +00:00
|
|
|
writesFuture.push(writer.copyTemplate('docs-scenario.html')); // will be rewritten, don't symlink
|
|
|
|
|
writesFuture.push(writer.output('docs-scenario.js', ngdoc.scenarios(docs)));
|
|
|
|
|
|
|
|
|
|
writesFuture.push(writer.output('docs-keywords.js',
|
2011-07-10 01:15:40 +00:00
|
|
|
['NG_PAGES=', JSON.stringify(metadata).replace(/{/g, '\n{'), ';']));
|
|
|
|
|
writesFuture.push(writer.output('sitemap.xml', new SiteMap(docs).render()));
|
2012-08-28 19:53:30 +00:00
|
|
|
|
2011-07-10 01:15:40 +00:00
|
|
|
writesFuture.push(writer.output('robots.txt', 'Sitemap: http://docs.angularjs.org/sitemap.xml\n'));
|
|
|
|
|
writesFuture.push(writer.output('appcache.manifest',appCache()));
|
2012-08-28 19:53:30 +00:00
|
|
|
writesFuture.push(writer.copyTemplate('.htaccess')); // will be rewritten, don't symlink
|
2011-06-07 19:53:40 +00:00
|
|
|
|
2012-08-28 19:53:30 +00:00
|
|
|
writesFuture.push(writer.symlinkTemplate('app.yaml'));
|
|
|
|
|
writesFuture.push(writer.symlinkTemplate('index.yaml'));
|
|
|
|
|
writesFuture.push(writer.symlinkTemplate('favicon.ico'));
|
|
|
|
|
writesFuture.push(writer.symlinkTemplate('main.py'));
|
2011-06-07 19:53:40 +00:00
|
|
|
}
|
2011-07-10 01:15:40 +00:00
|
|
|
|
|
|
|
|
|
2011-10-07 18:27:49 +00:00
|
|
|
function now() { return new Date().getTime(); }
|
2011-07-10 01:15:40 +00:00
|
|
|
|
2011-10-07 18:27:49 +00:00
|
|
|
function noop() {};
|
2012-08-28 19:53:30 +00:00
|
|
|
|