Minify sphinx docs too

This commit is contained in:
Ivan Blinkov 2017-05-30 16:47:46 +03:00 committed by alexey-milovidov
parent 51b8b19cc2
commit 09f4d26816
2 changed files with 33 additions and 25 deletions

1
.gitignore vendored
View File

@ -223,3 +223,4 @@ config-preprocessed.xml
# Gulp dependencies used to minify website
node_modules
public
website/docs

View File

@ -11,17 +11,32 @@ var connect = require('gulp-connect');
var run = require('gulp-run');
var outputDir = 'public';
var docsDir = '../docs/build/docs';
var docsDir = '../doc/reference';
var paths = {
htmls: ['*.html', '!reference_ru.html', '!reference_en.html'],
htmls: [
'**/*.html',
'!reference_ru.html',
'!reference_en.html',
'!node_modules/**/*.html',
'!public/**/*.html'],
reference: ['reference_ru.html', 'reference_en.html'],
docs: [docsDir + '/**'],
scripts: ['*.js', '!gulpfile.js'],
styles: ['*.css'],
images: ['*.png', '*.ico'],
docs: ['../doc/reference/build/docs/**/*'],
scripts: [
'**/*.js',
'!gulpfile.js',
'!node_modules/**/*.js',
'!public/**/*.js'],
styles: [
'**/*.css',
'!node_modules/**/*.css',
'!public/**/*.css'],
images: [
'**/*.{jpg,jpeg,png,svg,ico}',
'!node_modules/**/*.{jpg,jpeg,png,svg,ico}',
'!public/**/*.{jpg,jpeg,png,svg,ico}'],
robotstxt: ['robots.txt'],
presentations: ['../doc/presentations/**']
presentations: ['../doc/presentations/**/*']
};
gulp.task('clean', function () {
@ -32,62 +47,54 @@ gulp.task('reference', [], function () {
return gulp.src(paths.reference)
.pipe(minifyInline())
.pipe(gulp.dest(outputDir))
.pipe(connect.reload())
});
gulp.task('docs', [], function () {
run('cd ' + docsDir + '; make', {});
run('cd ' + docsDir + '; make');
return gulp.src(paths.docs)
.pipe(gulp.dest(outputDir + '/docs'))
.pipe(connect.reload())
.pipe(gulp.dest(outputDir + '/../docs'))
});
gulp.task('presentations', [], function () {
return gulp.src(paths.presentations)
.pipe(gulp.dest(outputDir + '/presentations'))
.pipe(connect.reload())
});
gulp.task('robotstxt', [], function () {
return gulp.src(paths.robotstxt)
.pipe(gulp.dest(outputDir))
.pipe(connect.reload())
});
gulp.task('htmls', ['reference', 'docs', 'robotstxt', 'presentations'], function () {
gulp.task('htmls', ['docs'], function () {
return gulp.src(paths.htmls)
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(minifyInline())
.pipe(gulp.dest(outputDir))
.pipe(connect.reload())
});
gulp.task('scripts', [], function () {
gulp.task('scripts', ['docs'], function () {
return gulp.src(paths.scripts)
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest(outputDir))
.pipe(connect.reload())
});
gulp.task('styles', [], function () {
gulp.task('styles', ['docs'], function () {
return gulp.src(paths.styles)
.pipe(cleanCss())
.pipe(cleanCss({inline: ['none']}))
.pipe(gulp.dest(outputDir))
.pipe(connect.reload())
});
gulp.task('images', [], function () {
gulp.task('images', ['docs'], function () {
return gulp.src(paths.images)
.pipe(imagemin({optimizationLevel: 9}))
.pipe(gulp.dest(outputDir))
.pipe(connect.reload())
});
gulp.task('watch', function () {
gulp.watch(paths.htmls, ['htmls']);
gulp.watch(docsDir, ['docs']);
gulp.watch(paths.docs, ['docs']);
gulp.watch(paths.reference, ['reference']);
gulp.watch(paths.scripts, ['scripts']);
gulp.watch(paths.images, ['images']);
@ -102,6 +109,6 @@ gulp.task('connect', function() {
})
});
gulp.task('build', ['htmls', 'scripts', 'styles', 'images']);
gulp.task('build', ['htmls', 'robotstxt', 'reference', 'presentations', 'scripts', 'styles', 'images']);
gulp.task('default', ['build', 'watch', 'connect']);
gulp.task('default', ['build', 'connect']);