2010-12-22 23:44:27 +00:00
|
|
|
require.paths.push(__dirname);
|
|
|
|
|
require.paths.push('lib');
|
|
|
|
|
var reader = require('reader.js'),
|
|
|
|
|
ngdoc = require('ngdoc.js'),
|
|
|
|
|
writer = require('writer.js'),
|
2011-06-25 01:09:59 +00:00
|
|
|
SiteMap = require('SiteMap.js').SiteMap,
|
2011-07-10 01:15:40 +00:00
|
|
|
appCache = require('appCache.js').appCache,
|
|
|
|
|
Q = require('qq');
|
2010-12-22 23:44:27 +00:00
|
|
|
|
2011-07-10 01:15:40 +00:00
|
|
|
process.on('uncaughtException', function (err) {
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
writer.makeDir('build/docs/syntaxhighlighter').then(function() {
|
|
|
|
|
console.log('Generating Angular Reference Documentation...');
|
|
|
|
|
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){
|
2011-07-10 01:15:40 +00:00
|
|
|
fileFutures.push(writer.output(doc.section + '/' + doc.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);
|
|
|
|
|
|
2011-07-10 01:15:40 +00:00
|
|
|
writesFuture.push(writer.copyDir('img'));
|
|
|
|
|
writesFuture.push(writer.copyDir('examples'));
|
2011-08-20 15:51:00 +00:00
|
|
|
|
|
|
|
|
var manifest = 'manifest="appcache.manifest"',
|
|
|
|
|
jq = '<script src="jquery.min.js"></script>',
|
|
|
|
|
ngMin = '<script src="../angular.min.js" ng:autobind></script>',
|
2011-09-01 14:16:01 +00:00
|
|
|
ng = '<script src="../angular.js" ng:autobind></script>';
|
2011-08-20 15:51:00 +00:00
|
|
|
|
|
|
|
|
writesFuture.push(writer.copy('docs/src/templates/index.html', 'build/docs/index.html',
|
|
|
|
|
writer.replace, {'doc:manifest': manifest,
|
|
|
|
|
'<!-- angular script place holder -->': ngMin}));
|
|
|
|
|
|
|
|
|
|
writesFuture.push(writer.copy('docs/src/templates/index.html', 'build/docs/index-jq.html',
|
|
|
|
|
writer.replace, {'doc:manifest': manifest,
|
|
|
|
|
'<!-- angular script place holder -->': ngMin,
|
|
|
|
|
'<!-- jquery place holder -->': jq}));
|
|
|
|
|
|
|
|
|
|
writesFuture.push(writer.copy('docs/src/templates/index.html', 'build/docs/index-debug.html',
|
|
|
|
|
writer.replace, {'doc:manifest': '',
|
|
|
|
|
'<!-- angular script place holder -->': ng}));
|
|
|
|
|
|
|
|
|
|
writesFuture.push(writer.copy('docs/src/templates/index.html', 'build/docs/index-jq-debug.html',
|
|
|
|
|
writer.replace, {'doc:manifest': '',
|
|
|
|
|
'<!-- angular script place holder -->': ng,
|
|
|
|
|
'<!-- jquery place holder -->': jq}));
|
|
|
|
|
|
2011-07-10 01:15:40 +00:00
|
|
|
writesFuture.push(writer.copyTpl('offline.html'));
|
|
|
|
|
writesFuture.push(writer.copyTpl('docs-scenario.html'));
|
|
|
|
|
writesFuture.push(writer.copyTpl('jquery.min.js'));
|
2011-06-07 19:53:40 +00:00
|
|
|
|
2011-07-10 01:15:40 +00:00
|
|
|
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()));
|
2011-07-21 02:29:54 +00:00
|
|
|
writesFuture.push(writer.copyTpl('.htaccess'));
|
2011-06-07 19:53:40 +00:00
|
|
|
|
2011-07-10 01:15:40 +00:00
|
|
|
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'));
|
2011-06-07 19:53:40 +00:00
|
|
|
}
|
2011-07-10 01:15:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
function now(){ return new Date().getTime(); }
|
|
|
|
|
|
|
|
|
|
function noop(){};
|