@@ -30,6 +30,7 @@ var tslint = require('gulp-tslint');
30
30
// 2. Think about using spawn instead of exec in case of long error messages.
31
31
32
32
var TOOLS_PATH = './tools' ;
33
+ var ANGULAR_IO_PROJECT_PATH = path . resolve ( '.' ) ;
33
34
var ANGULAR_PROJECT_PATH = '../angular' ;
34
35
var PUBLIC_PATH = './public' ;
35
36
var TEMP_PATH = './_temp' ;
@@ -63,12 +64,21 @@ var _devguideShredJadeOptions = {
63
64
} ;
64
65
65
66
var _apiShredOptions = {
67
+ lang : 'ts' ,
66
68
examplesDir : path . join ( ANGULAR_PROJECT_PATH , 'modules/@angular/examples' ) ,
67
69
fragmentsDir : path . join ( DOCS_PATH , '_fragments/_api' ) ,
68
70
zipDir : path . join ( RESOURCES_PATH , 'zips/api' ) ,
69
71
logLevel : _dgeniLogLevel
70
72
} ;
71
73
74
+ var _apiShredOptionsForDart = {
75
+ lang : 'dart' ,
76
+ examplesDir : path . resolve ( ngPathFor ( 'dart' ) , 'examples' ) ,
77
+ fragmentsDir : path . join ( DOCS_PATH , '_fragments/_api' ) ,
78
+ zipDir : path . join ( RESOURCES_PATH , 'zips/api' ) ,
79
+ logLevel : _dgeniLogLevel
80
+ } ;
81
+
72
82
var _excludePatterns = [ '**/node_modules/**' , '**/typings/**' , '**/packages/**' ] ;
73
83
74
84
var _excludeMatchers = _excludePatterns . map ( function ( excludePattern ) {
@@ -96,6 +106,14 @@ var _exampleProtractorBoilerplateFiles = [
96
106
97
107
var _exampleConfigFilename = 'example-config.json' ;
98
108
109
+ var lang , langs ;
110
+ function configLangs ( langOption ) {
111
+ lang = ( langOption || 'all' ) . toLowerCase ( ) ;
112
+ if ( lang === 'all' ) { lang = '(ts|js|dart)' ; }
113
+ langs = lang . match ( / \w + / g) ; // the languages in `lang` as an array
114
+ }
115
+ configLangs ( argv . lang ) ;
116
+
99
117
function isDartPath ( path ) {
100
118
// Testing via indexOf() for now. If we need to match only paths with folders
101
119
// named 'dart' vs 'dart*' then try: path.match('/dart(/|$)') != null;
@@ -131,6 +149,7 @@ gulp.task('run-e2e-tests', runE2e);
131
149
* all means (ts|js|dart)
132
150
*/
133
151
function runE2e ( ) {
152
+ if ( ! argv . lang ) configLangs ( 'ts|js' ) ; // Exclude dart by default
134
153
var promise ;
135
154
if ( argv . fast ) {
136
155
// fast; skip all setup
@@ -183,8 +202,6 @@ function runE2e() {
183
202
// each app/spec collection sequentially.
184
203
function findAndRunE2eTests ( filter , outputFile ) {
185
204
// create an output file with header.
186
- var lang = ( argv . lang || '(ts|js)' ) . toLowerCase ( ) ;
187
- if ( lang === 'all' ) { lang = '(ts|js|dart)' ; }
188
205
var startTime = new Date ( ) . getTime ( ) ;
189
206
var header = `Doc Sample Protractor Results for ${ lang } on ${ new Date ( ) . toLocaleString ( ) } \n` ;
190
207
header += argv . fast ?
@@ -528,7 +545,9 @@ gulp.task('build-docs', ['build-devguide-docs', 'build-api-docs', 'build-plunker
528
545
// Stop zipping examples Feb 28, 2016
529
546
//gulp.task('build-docs', ['build-devguide-docs', 'build-api-docs', 'build-plunkers', '_zip-examples']);
530
547
531
- gulp . task ( 'build-api-docs' , [ 'build-js-api-docs' , 'build-ts-api-docs' , 'build-dart-cheatsheet' ] ) ;
548
+ gulp . task ( 'build-api-docs' , [ 'build-js-api-docs' , 'build-ts-api-docs' ,
549
+ // On TRAVIS? Skip building the Dart API docs for now.
550
+ ...( process . env . TRAVIS ? [ ] : [ 'build-dart-api-docs' ] ) ] ) ;
532
551
533
552
gulp . task ( 'build-devguide-docs' , [ '_shred-devguide-examples' , '_shred-devguide-shared-jade' ] , function ( ) {
534
553
return buildShredMaps ( true ) ;
@@ -542,12 +561,40 @@ gulp.task('build-js-api-docs', ['_shred-api-examples'], function() {
542
561
return buildApiDocs ( 'js' ) ;
543
562
} ) ;
544
563
564
+ gulp . task ( 'build-dart-api-docs' , [ '_shred-api-examples' , 'dartdoc' ] , function ( ) {
565
+ // TODO(chalin): also build build-dart-cheatsheet
566
+ return buildApiDocsForDart ( ) ;
567
+ } ) ;
568
+
545
569
gulp . task ( 'build-plunkers' , [ '_copy-example-boilerplate' ] , function ( ) {
546
570
return plunkerBuilder . buildPlunkers ( EXAMPLES_PATH , LIVE_EXAMPLES_PATH , { errFn : gutil . log } ) ;
547
571
} ) ;
548
572
549
573
gulp . task ( 'build-dart-cheatsheet' , [ ] , function ( ) {
550
- return buildApiDocs ( 'dart' ) ;
574
+ gutil . log ( 'build-dart-cheatsheet - NOT IMPLEMENTED YET' ) ;
575
+ // return buildApiDocsForDart();
576
+ } ) ;
577
+
578
+ gulp . task ( 'dartdoc' , [ 'pub upgrade' ] , function ( ) {
579
+ const ngRepoPath = ngPathFor ( 'dart' ) ;
580
+ if ( argv . fast && fs . existsSync ( path . resolve ( ngRepoPath , 'doc' ) ) ) {
581
+ gutil . log ( 'Skipping dartdoc: --fast flag enabled and "doc" dir exists' ) ;
582
+ return true ;
583
+ }
584
+ checkAngularProjectPath ( ngRepoPath ) ;
585
+ const dartdoc = spawnExt ( 'dartdoc' , [ '--output' , 'doc/api' , '--add-crossdart' ] , { cwd : ngRepoPath } ) ;
586
+ return dartdoc . promise ;
587
+ } ) ;
588
+
589
+ gulp . task ( 'pub upgrade' , [ ] , function ( ) {
590
+ const ngRepoPath = ngPathFor ( 'dart' ) ;
591
+ if ( argv . fast && fs . existsSync ( path . resolve ( ngRepoPath , 'packages' ) ) ) {
592
+ gutil . log ( 'Skipping pub upgrade: --fast flag enabled and "packages" dir exists' ) ;
593
+ return true ;
594
+ }
595
+ checkAngularProjectPath ( ngRepoPath ) ;
596
+ const pubUpgrade = spawnExt ( 'pub' , [ 'upgrade' ] , { cwd : ngRepoPath } ) ;
597
+ return pubUpgrade . promise ;
551
598
} ) ;
552
599
553
600
gulp . task ( 'git-changed-examples' , [ '_shred-devguide-examples' ] , function ( ) {
@@ -596,10 +643,35 @@ gulp.task('git-changed-examples', ['_shred-devguide-examples'], function(){
596
643
} ) ;
597
644
} ) ;
598
645
599
- gulp . task ( 'harp-compile' , [ 'build-docs' ] , function ( ) {
646
+ gulp . task ( 'harp-compile' , [ ] , function ( ) {
647
+ return harpCompile ( )
648
+ } ) ;
649
+
650
+ gulp . task ( 'serve' , [ ] , function ( ) {
651
+ // Harp will serve files from workspace.
652
+ const cmd = 'npm run harp -- server .' ;
653
+ gutil . log ( 'Launching harp server (over project files)' ) ;
654
+ gutil . log ( ` > ${ cmd } ` ) ;
655
+ gutil . log ( 'Note: issuing this command directly from the command line will show harp comiple warnings.' ) ;
656
+ return execPromise ( cmd ) ;
657
+ } ) ;
658
+
659
+ gulp . task ( 'serve-www' , [ ] , function ( ) {
660
+ // Serve generated site.
661
+ return execPromise ( 'npm run live-server ./www' ) ;
662
+ } ) ;
663
+
664
+ gulp . task ( 'build-compile' , [ 'build-docs' ] , function ( ) {
600
665
return harpCompile ( ) ;
601
666
} ) ;
602
667
668
+ gulp . task ( 'check-serve' , [ 'build-docs' ] , function ( ) {
669
+ return harpCompile ( ) . then ( function ( ) {
670
+ gutil . log ( 'Launching live-server over ./www' ) ;
671
+ return execPromise ( 'npm run live-server ./www' ) ;
672
+ } ) ;
673
+ } ) ;
674
+
603
675
gulp . task ( 'check-deploy' , [ 'build-docs' ] , function ( ) {
604
676
return harpCompile ( ) . then ( function ( ) {
605
677
gutil . log ( 'compile ok' ) ;
@@ -693,8 +765,15 @@ gulp.task('_shred-clean-devguide', function(cb) {
693
765
} ) ;
694
766
695
767
gulp . task ( '_shred-api-examples' , [ '_shred-clean-api' ] , function ( ) {
696
- checkAngularProjectPath ( ) ;
697
- return docShredder . shred ( _apiShredOptions ) ;
768
+ const promises = [ ] ;
769
+ gutil . log ( 'Shredding API examples for languages: ' + langs . join ( ', ' ) ) ;
770
+ langs . forEach ( ( lang ) => {
771
+ if ( lang === 'js' ) return ; // JS is handled via TS.
772
+ checkAngularProjectPath ( ngPathFor ( lang ) ) ;
773
+ const options = lang == 'dart' ? _apiShredOptionsForDart : _apiShredOptions ;
774
+ promises . push ( docShredder . shred ( options ) ) ;
775
+ } ) ;
776
+ return Q . all ( promises ) ;
698
777
} ) ;
699
778
700
779
gulp . task ( '_shred-clean-api' , function ( cb ) {
@@ -1087,8 +1166,8 @@ function buildApiDocs(targetLanguage) {
1087
1166
var dgeni = new Dgeni ( [ package ] ) ;
1088
1167
return dgeni . generate ( ) ;
1089
1168
} catch ( err ) {
1090
- gutil . log ( err ) ;
1091
- gutil . log ( err . stack ) ;
1169
+ console . error ( err ) ;
1170
+ console . error ( err . stack ) ;
1092
1171
throw err ;
1093
1172
}
1094
1173
@@ -1099,6 +1178,48 @@ function buildApiDocs(targetLanguage) {
1099
1178
}
1100
1179
}
1101
1180
1181
+
1182
+ function buildApiDocsForDart ( ) {
1183
+ const apiDir = 'api' ;
1184
+ const vers = 'latest' ;
1185
+ const dab = require ( './tools/dart-api-builder/dab' ) ( ANGULAR_IO_PROJECT_PATH ) ;
1186
+ const log = dab . log ;
1187
+
1188
+ log . level = _dgeniLogLevel ;
1189
+ const dabInfo = dab . dartPkgConfigInfo ;
1190
+ dabInfo . ngIoDartApiDocPath = path . join ( DOCS_PATH , 'dart' , vers , apiDir ) ;
1191
+ dabInfo . ngDartDocPath = path . join ( ngPathFor ( 'dart' ) , 'doc' , apiDir ) ;
1192
+ // Exclude API entries for developer/internal libraries. Also exclude entries for
1193
+ // the top-level catch all "angular2" library (otherwise every entry appears twice).
1194
+ dabInfo . excludeLibRegExp = new RegExp ( / ^ (? ! a n g u l a r 2 ) | \. t e s t i n g | _ | c o d e g e n | ^ a n g u l a r 2 $ / ) ;
1195
+
1196
+ try {
1197
+ checkAngularProjectPath ( 'dart' ) ;
1198
+ var destPath = dabInfo . ngIoDartApiDocPath ;
1199
+ var sourceDirs = fs . readdirSync ( dabInfo . ngDartDocPath )
1200
+ . filter ( ( name ) => ! name . match ( / ^ i n d e x / ) )
1201
+ . map ( ( name ) => path . join ( dabInfo . ngDartDocPath , name ) ) ;
1202
+ log . info ( `Building Dart API pages for ${ sourceDirs . length } libraries` ) ;
1203
+
1204
+ return copyFiles ( sourceDirs , [ destPath ] ) . then ( ( ) => {
1205
+ log . debug ( 'Finished copying' , sourceDirs . length , 'directories from' , dabInfo . ngDartDocPath , 'to' , destPath ) ;
1206
+
1207
+ const apiEntries = dab . loadApiDataAndSaveToApiListFile ( ) ;
1208
+ const tmpDocsPath = path . resolve ( path . join ( process . env . HOME , 'tmp/docs.json' ) ) ;
1209
+ if ( argv . dumpDocsJson ) fs . writeFileSync ( tmpDocsPath , JSON . stringify ( apiEntries , null , 2 ) ) ;
1210
+ dab . createApiDataAndJadeFiles ( apiEntries ) ;
1211
+
1212
+ } ) . catch ( ( err ) => {
1213
+ console . log ( err ) ;
1214
+ } ) ;
1215
+
1216
+ } catch ( err ) {
1217
+ console . error ( err ) ;
1218
+ console . error ( err . stack ) ;
1219
+ throw err ;
1220
+ }
1221
+ }
1222
+
1102
1223
function buildShredMaps ( shouldWrite ) {
1103
1224
var options = {
1104
1225
devguideExamplesDir : _devguideShredOptions . examplesDir ,
@@ -1270,8 +1391,13 @@ function execCommands(cmds, options, cb) {
1270
1391
} ) ;
1271
1392
}
1272
1393
1273
- function checkAngularProjectPath ( ) {
1274
- if ( ! fs . existsSync ( ANGULAR_PROJECT_PATH ) ) {
1275
- throw new Error ( 'API related tasks require the angular2 repo to be at ' + path . resolve ( ANGULAR_PROJECT_PATH ) ) ;
1394
+ function ngPathFor ( lang ) {
1395
+ return ANGULAR_PROJECT_PATH + ( lang === 'dart' ? '-dart' : '' ) ;
1396
+ }
1397
+
1398
+ function checkAngularProjectPath ( lang ) {
1399
+ var ngPath = path . resolve ( ngPathFor ( lang || 'ts' ) ) ;
1400
+ if ( ! fs . existsSync ( ngPath ) ) {
1401
+ throw new Error ( 'API related tasks require the angular2 repo to be at ' + ngPath ) ;
1276
1402
}
1277
1403
}
0 commit comments