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-01-24 21:33:47 +00:00
|
|
|
callback = require('callback.js'),
|
|
|
|
|
SiteMap = require('SiteMap.js').SiteMap;
|
2010-12-22 23:44:27 +00:00
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
var writes = callback.chain(function(){
|
|
|
|
|
ngdoc.merge(docs);
|
|
|
|
|
docs.forEach(function(doc){
|
2011-04-29 22:18:27 +00:00
|
|
|
writer.output(doc.section + '/' + doc.id + '.html', doc.html(), writes.waitFor());
|
2010-12-22 23:44:27 +00:00
|
|
|
});
|
|
|
|
|
var metadata = ngdoc.metadata(docs);
|
2011-01-26 05:55:11 +00:00
|
|
|
writer.output('docs-keywords.js', ['NG_PAGES=', JSON.stringify(metadata).replace(/{/g, '\n{'), ';'], writes.waitFor());
|
2011-02-03 23:21:34 +00:00
|
|
|
writer.copyDir('img', writes.waitFor());
|
2011-05-19 15:33:25 +00:00
|
|
|
writer.copyDir('examples', writes.waitFor());
|
|
|
|
|
writer.copyTpl('index.html', writes.waitFor());
|
2011-07-19 23:58:40 +00:00
|
|
|
writer.copyTpl('.htaccess', writes.waitFor());
|
2011-07-15 01:28:15 +00:00
|
|
|
writer.copy('docs/src/templates/index.html', 'build/docs/index-jq.html', writes.waitFor(),
|
|
|
|
|
'<-- jquery place holder -->', '<script src=\"jquery.min.js\"><\/script>');
|
2011-06-07 19:53:40 +00:00
|
|
|
writer.copyTpl('offline.html', writes.waitFor());
|
|
|
|
|
writer.output('app-cache.manifest',
|
|
|
|
|
appCacheTemplate().replace(/%TIMESTAMP%/, (new Date()).toISOString()),
|
|
|
|
|
writes.waitFor());
|
2011-05-10 18:16:00 +00:00
|
|
|
writer.merge(['docs.js',
|
|
|
|
|
'doc_widgets.js'],
|
|
|
|
|
'docs-combined.js',
|
|
|
|
|
writes.waitFor());
|
|
|
|
|
writer.merge(['docs.css',
|
|
|
|
|
'doc_widgets.css'],
|
|
|
|
|
'docs-combined.css',
|
|
|
|
|
writes.waitFor());
|
2011-05-19 15:33:25 +00:00
|
|
|
writer.copyTpl('docs-scenario.html', writes.waitFor());
|
2010-12-22 23:44:27 +00:00
|
|
|
writer.output('docs-scenario.js', ngdoc.scenarios(docs), writes.waitFor());
|
2011-01-24 21:33:47 +00:00
|
|
|
writer.output('sitemap.xml', new SiteMap(docs).render(), writes.waitFor());
|
|
|
|
|
writer.output('robots.txt', 'Sitemap: http://docs.angularjs.org/sitemap.xml\n', writes.waitFor());
|
2011-05-10 18:16:00 +00:00
|
|
|
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());
|
2011-05-19 15:33:25 +00:00
|
|
|
writer.copyTpl('jquery.min.js', writes.waitFor());
|
2010-12-22 23:44:27 +00:00
|
|
|
});
|
|
|
|
|
writes.onDone(function(){
|
2011-01-19 23:42:11 +00:00
|
|
|
console.log('DONE. Generated ' + docs.length + ' pages in ' +
|
2010-12-22 23:44:27 +00:00
|
|
|
(now()-start) + 'ms.' );
|
|
|
|
|
});
|
|
|
|
|
work.onDone(writes);
|
2011-01-11 05:03:50 +00:00
|
|
|
writer.makeDir('build/docs/syntaxhighlighter', work);
|
2010-12-22 23:44:27 +00:00
|
|
|
|
|
|
|
|
///////////////////////////////////
|
|
|
|
|
function now(){ return new Date().getTime(); }
|
2011-06-07 19:53:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
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",
|
|
|
|
|
"img/texture_1.png",
|
|
|
|
|
"img/yellow_bkgnd.jpg",
|
|
|
|
|
"",
|
|
|
|
|
"FALLBACK:",
|
|
|
|
|
"/ offline.html",
|
|
|
|
|
"",
|
|
|
|
|
"# allow access to google analytics and twitter when we are online",
|
|
|
|
|
"NETWORK:",
|
|
|
|
|
"*"].join('\n');
|
|
|
|
|
}
|