@@ -3,90 +3,77 @@ require.paths.push('lib');
33var reader = require ( 'reader.js' ) ,
44 ngdoc = require ( 'ngdoc.js' ) ,
55 writer = require ( 'writer.js' ) ,
6- callback = require ( 'callback.js' ) ,
76 SiteMap = require ( 'SiteMap.js' ) . SiteMap ,
8- appCache = require ( 'appCache.js' ) ;
7+ appCache = require ( 'appCache.js' ) . appCache ,
8+ Q = require ( 'qq' ) ;
99
10- var docs = [ ] ;
11- var start ;
12- var work = callback . chain ( function ( ) {
13- start = now ( ) ;
14- console . log ( 'Generating Angular Reference Documentation...' ) ;
15- reader . collect ( work . waitMany ( function ( text , file , line ) {
16- var doc = new ngdoc . Doc ( text , file , line ) ;
17- docs . push ( doc ) ;
18- doc . parse ( ) ;
19- } ) ) ;
10+ process . on ( 'uncaughtException' , function ( err ) {
11+ console . error ( err . stack || err ) ;
2012} ) ;
21- var writes = callback . chain ( function ( ) {
13+
14+ var start = now ( ) ;
15+ var docs ;
16+
17+ writer . makeDir ( 'build/docs/syntaxhighlighter' ) . then ( function ( ) {
18+ console . log ( 'Generating Angular Reference Documentation...' ) ;
19+ return reader . collect ( ) ;
20+ } ) . then ( function generateHtmlDocPartials ( docs_ ) {
21+ docs = docs_ ;
2222 ngdoc . merge ( docs ) ;
23+ var fileFutures = [ ] ;
2324 docs . forEach ( function ( doc ) {
24- writer . output ( doc . section + '/' + doc . id + '.html' , doc . html ( ) , writes . waitFor ( ) ) ;
25+ fileFutures . push ( writer . output ( doc . section + '/' + doc . id + '.html' , doc . html ( ) ) ) ;
2526 } ) ;
27+
28+ writeTheRest ( fileFutures ) ;
29+
30+ return Q . deep ( fileFutures ) ;
31+ } ) . then ( function generateManifestFile ( ) {
32+ return appCache ( 'build/docs/' ) . then ( function ( list ) {
33+ writer . output ( 'appcache-offline.manifest' , list )
34+ } ) ;
35+ } ) . then ( function printStats ( ) {
36+ console . log ( 'DONE. Generated ' + docs . length + ' pages in ' + ( now ( ) - start ) + 'ms.' ) ;
37+ } ) . end ( ) ;
38+
39+
40+ function writeTheRest ( writesFuture ) {
2641 var metadata = ngdoc . metadata ( docs ) ;
27- writer . output ( 'docs-keywords.js' , [ 'NG_PAGES=' , JSON . stringify ( metadata ) . replace ( / { / g, '\n{' ) , ';' ] , writes . waitFor ( ) ) ;
28- writer . copyDir ( 'img' , writes . waitFor ( ) ) ;
29- writer . copyDir ( 'examples' , writes . waitFor ( ) ) ;
30- writer . copyTpl ( 'index.html' , writes . waitFor ( ) ) ;
31- writer . copyTpl ( '.htaccess' , writes . waitFor ( ) ) ;
32- writer . copy ( 'docs/src/templates/index.html' , 'build/docs/index-jq.html' , writes . waitFor ( ) ,
33- '<-- jquery place holder -->' , '<script src=\"jquery.min.js\"><\/script>' ) ;
34- writer . copyTpl ( 'offline.html' , writes . waitFor ( ) ) ;
35- //writer.output('app-cache.manifest',
36- // appCacheTemplate().replace(/%TIMESTAMP%/, (new Date()).toISOString()),
37- // writes.waitFor());
38- writer . merge ( [ 'docs.js' ,
39- 'doc_widgets.js' ] ,
40- 'docs-combined.js' ,
41- writes . waitFor ( ) ) ;
42- writer . merge ( [ 'docs.css' ,
43- 'doc_widgets.css' ] ,
44- 'docs-combined.css' ,
45- writes . waitFor ( ) ) ;
46- writer . copyTpl ( 'docs-scenario.html' , writes . waitFor ( ) ) ;
47- writer . output ( 'docs-scenario.js' , ngdoc . scenarios ( docs ) , writes . waitFor ( ) ) ;
48- writer . output ( 'sitemap.xml' , new SiteMap ( docs ) . render ( ) , writes . waitFor ( ) ) ;
49- writer . output ( 'robots.txt' , 'Sitemap: http://docs.angularjs.org/sitemap.xml\n' , writes . waitFor ( ) ) ;
50- writer . merge ( [ 'syntaxhighlighter/shCore.js' ,
51- 'syntaxhighlighter/shBrushJScript.js' ,
52- 'syntaxhighlighter/shBrushXml.js' ] ,
53- 'syntaxhighlighter/syntaxhighlighter-combined.js' ,
54- writes . waitFor ( ) ) ;
55- writer . merge ( [ 'syntaxhighlighter/shCore.css' ,
56- 'syntaxhighlighter/shThemeDefault.css' ] ,
57- 'syntaxhighlighter/syntaxhighlighter-combined.css' ,
58- writes . waitFor ( ) ) ;
59- writer . copyTpl ( 'jquery.min.js' , writes . waitFor ( ) ) ;
60- writer . output ( 'app-cache.manifest' , appCache ( 'build/docs/' ) , writes . waitFor ( ) ) ;
61- } ) ;
62- writes . onDone ( function ( ) {
63- console . log ( 'DONE. Generated ' + docs . length + ' pages in ' +
64- ( now ( ) - start ) + 'ms.' ) ;
65- } ) ;
66- work . onDone ( writes ) ;
67- writer . makeDir ( 'build/docs/syntaxhighlighter' , work ) ;
6842
69- ///////////////////////////////////
70- function now ( ) { return new Date ( ) . getTime ( ) ; }
43+ writesFuture . push ( writer . copyDir ( 'img' ) ) ;
44+ writesFuture . push ( writer . copyDir ( 'examples' ) ) ;
45+ writesFuture . push ( writer . copyTpl ( 'index.html' ) ) ;
46+ writesFuture . push ( writer . copy ( 'docs/src/templates/index.html' ,
47+ 'build/docs/index-jq.html' ,
48+ '<!-- jquery place holder -->' ,
49+ '<script src=\"jquery.min.js\"><\/script>' ) ) ;
50+ writesFuture . push ( writer . copyTpl ( 'offline.html' ) ) ;
51+ writesFuture . push ( writer . copyTpl ( 'docs-scenario.html' ) ) ;
52+ writesFuture . push ( writer . copyTpl ( 'jquery.min.js' ) ) ;
7153
54+ writesFuture . push ( writer . output ( 'docs-keywords.js' ,
55+ [ 'NG_PAGES=' , JSON . stringify ( metadata ) . replace ( / { / g, '\n{' ) , ';' ] ) ) ;
56+ writesFuture . push ( writer . output ( 'sitemap.xml' , new SiteMap ( docs ) . render ( ) ) ) ;
57+ writesFuture . push ( writer . output ( 'docs-scenario.js' , ngdoc . scenarios ( docs ) ) ) ;
58+ writesFuture . push ( writer . output ( 'robots.txt' , 'Sitemap: http://docs.angularjs.org/sitemap.xml\n' ) ) ;
59+ writesFuture . push ( writer . output ( 'appcache.manifest' , appCache ( ) ) ) ;
7260
73- function appCacheTemplate ( ) {
74- return [ "CACHE MANIFEST" ,
75- "# %TIMESTAMP%" ,
76- "" ,
77- "# cache all of these" ,
78- "CACHE:" ,
79- "syntaxhighlighter/syntaxhighlighter-combined.js" ,
80- "../angular.min.js" ,
81- "docs-combined.js" ,
82- "docs-keywords.js" ,
83- "docs-combined.css" ,
84- "syntaxhighlighter/syntaxhighlighter-combined.css" ,
85- "" ,
86- "FALLBACK:" ,
87- "/ offline.html" ,
88- "" ,
89- "# allow access to google analytics and twitter when we are online" ,
90- "NETWORK:" ,
91- "*" ] . join ( '\n' ) ;
61+ writesFuture . push ( writer . merge ( [ 'docs.js' ,
62+ 'doc_widgets.js' ] ,
63+ 'docs-combined.js' ) ) ;
64+ writesFuture . push ( writer . merge ( [ 'docs.css' ,
65+ 'doc_widgets.css' ] ,
66+ 'docs-combined.css' ) ) ;
67+ writesFuture . push ( writer . merge ( [ 'syntaxhighlighter/shCore.js' ,
68+ 'syntaxhighlighter/shBrushJScript.js' ,
69+ 'syntaxhighlighter/shBrushXml.js' ] ,
70+ 'syntaxhighlighter/syntaxhighlighter-combined.js' ) ) ;
71+ writesFuture . push ( writer . merge ( [ 'syntaxhighlighter/shCore.css' ,
72+ 'syntaxhighlighter/shThemeDefault.css' ] ,
73+ 'syntaxhighlighter/syntaxhighlighter-combined.css' ) ) ;
9274}
75+
76+
77+ function now ( ) { return new Date ( ) . getTime ( ) ; }
78+
79+ function noop ( ) { } ;
0 commit comments