Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion tools/gulp/tasks/docs.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import {task, src, dest} from 'gulp';
import {Dgeni} from 'dgeni';
import * as path from 'path';
import {HTML_MINIFIER_OPTIONS} from '../constants';

// Node packages that lack of types.
const markdown = require('gulp-markdown');
const transform = require('gulp-transform');
const highlight = require('gulp-highlight-files');
const rename = require('gulp-rename');
const flatten = require('gulp-flatten');
const htmlmin = require('gulp-htmlmin');
const hljs = require('highlight.js');

// Our docs contain comments of the form `<!-- example(...) -->` which serve as placeholders where
Expand All @@ -21,7 +23,7 @@ const EXAMPLE_PATTERN = /<!--\W*example\(([^)]+)\)\W*-->/g;
// documentation page. Using a RegExp to rewrite links in HTML files to work in the docs.
const LINK_PATTERN = /(<a[^>]*) href="([^"]*)"/g;

task('docs', ['markdown-docs', 'highlight-docs', 'api-docs']);
task('docs', ['markdown-docs', 'highlight-docs', 'api-docs', 'minify-html-docs']);

task('markdown-docs', () => {
return src(['src/lib/**/*.md', 'guides/*.md'])
Expand Down Expand Up @@ -61,6 +63,12 @@ task('api-docs', () => {
return docs.generate();
});

task('minify-html-docs', ['api-docs'], () => {
return src('dist/docs/api/*.html')
.pipe(htmlmin(HTML_MINIFIER_OPTIONS))
.pipe(dest('dist/docs/api/'));
});

/** Updates the markdown file's content to work inside of the docs app. */
function transformMarkdownFiles(buffer: Buffer, file: any): string {
let content = buffer.toString('utf-8');
Expand Down