Skip to content

Commit 8229d7e

Browse files
petebacondarwinmhevery
authored andcommitted
chore(gulpfile): duplicate tasks to generate "public" docs
1 parent f503c1e commit 8229d7e

File tree

1 file changed

+46
-35
lines changed

1 file changed

+46
-35
lines changed

gulpfile.js

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -492,17 +492,10 @@ gulp.task('serve/benchmarks_external.dart', pubserve(gulp, gulpPlugins, {
492492
// --------------
493493
// doc generation
494494
var Dgeni = require('dgeni');
495-
gulp.task('docs/dgeni', function() {
496-
try {
497-
var dgeni = new Dgeni([require('./docs/dgeni-package')]);
498-
return dgeni.generate();
499-
} catch(x) {
500-
console.log(x.stack);
501-
throw x;
502-
}
503-
});
504-
505495
var bower = require('bower');
496+
var jasmine = require('gulp-jasmine');
497+
var webserver = require('gulp-webserver');
498+
506499
gulp.task('docs/bower', function() {
507500
var bowerTask = bower.commands.install(undefined, undefined, { cwd: 'docs' });
508501
bowerTask.on('log', function (result) {
@@ -514,36 +507,54 @@ gulp.task('docs/bower', function() {
514507
return bowerTask;
515508
});
516509

517-
gulp.task('docs/assets', ['docs/bower'], function() {
518-
return gulp.src('docs/bower_components/**/*')
519-
.pipe(gulp.dest('dist/docs/lib'));
520-
});
521510

522-
gulp.task('docs/app', function() {
523-
return gulp.src('docs/app/**/*')
524-
.pipe(gulp.dest('dist/docs'));
525-
});
511+
function createDocsTasks(public) {
512+
var dgeniPackage = public ? './docs/public-docs-package' : './docs/dgeni-package';
513+
var distDocsPath = public ? 'dist/public_docs' : 'dist/docs';
514+
var taskPrefix = public ? 'public_docs' : 'docs';
526515

527-
gulp.task('docs', ['docs/assets', 'docs/app', 'docs/dgeni']);
528-
gulp.task('docs/watch', function() {
529-
return gulp.watch('docs/app/**/*', ['docs/app']);
530-
});
516+
gulp.task(taskPrefix + '/dgeni', function() {
517+
try {
518+
var dgeni = new Dgeni([require(dgeniPackage)]);
519+
return dgeni.generate();
520+
} catch(x) {
521+
console.log(x.stack);
522+
throw x;
523+
}
524+
});
531525

532-
var jasmine = require('gulp-jasmine');
533-
gulp.task('docs/test', function () {
534-
return gulp.src('docs/**/*.spec.js')
535-
.pipe(jasmine({
536-
includeStackTrace: true
526+
gulp.task(taskPrefix + '/assets', ['docs/bower'], function() {
527+
return gulp.src('docs/bower_components/**/*')
528+
.pipe(gulp.dest(distDocsPath + '/lib'));
529+
});
530+
531+
gulp.task(taskPrefix + '/app', function() {
532+
return gulp.src('docs/app/**/*')
533+
.pipe(gulp.dest(distDocsPath));
534+
});
535+
536+
gulp.task(taskPrefix, [taskPrefix + '/assets', taskPrefix + '/app', taskPrefix + '/dgeni']);
537+
gulp.task(taskPrefix + '/watch', function() {
538+
return gulp.watch('docs/app/**/*', [taskPrefix + '/app']);
539+
});
540+
541+
gulp.task(taskPrefix + '/test', function () {
542+
return gulp.src('docs/**/*.spec.js')
543+
.pipe(jasmine({
544+
includeStackTrace: true
545+
}));
546+
});
547+
548+
gulp.task(taskPrefix + '/serve', function() {
549+
gulp.src(distDocsPath + '/')
550+
.pipe(webserver({
551+
fallback: 'index.html'
537552
}));
538-
});
553+
});
554+
}
539555

540-
var webserver = require('gulp-webserver');
541-
gulp.task('docs/serve', function() {
542-
gulp.src('dist/docs/')
543-
.pipe(webserver({
544-
fallback: 'index.html'
545-
}));
546-
});
556+
createDocsTasks(true);
557+
createDocsTasks(false);
547558

548559
// ------------------
549560
// karma tests

0 commit comments

Comments
 (0)