1
1
import { task , src , dest } from 'gulp' ;
2
2
import { Dgeni } from 'dgeni' ;
3
3
import * as path from 'path' ;
4
- import { buildConfig } from 'material2-build-tools' ;
4
+ import { buildConfig , sequenceTask } from 'material2-build-tools' ;
5
5
import { apiDocsPackage } from '../../dgeni/index' ;
6
6
7
7
// There are no type definitions available for these imports.
@@ -73,18 +73,21 @@ const markdownOptions = {
73
73
} ;
74
74
75
75
/** Generate all docs content. */
76
- task ( 'docs' , [
77
- 'markdown-docs' ,
78
- 'markdown-docs-cdk' ,
79
- 'highlight-examples' ,
80
- 'api-docs' ,
81
- 'minified-api-docs' ,
82
- 'build-examples-module' ,
83
- 'stackblitz-example-assets' ,
84
- ] ) ;
76
+ task ( 'docs' , sequenceTask (
77
+ 'clean' ,
78
+ [
79
+ 'markdown-docs-material' ,
80
+ 'markdown-docs-cdk' ,
81
+ 'build-highlighted-examples' ,
82
+ 'build-examples-module' ,
83
+ 'api-docs' ,
84
+ 'copy-stackblitz-examples'
85
+ ] ,
86
+ 'minify-html-files'
87
+ ) ) ;
85
88
86
89
/** Generates html files from the markdown overviews and guides for material. */
87
- task ( 'markdown-docs' , ( ) => {
90
+ task ( 'markdown-docs-material ' , ( ) => {
88
91
// Extend the renderer for custom heading anchor rendering
89
92
markdown . marked . Renderer . prototype . heading = ( text : string , level : number ) : string => {
90
93
if ( level === 3 || level === 4 ) {
@@ -124,7 +127,7 @@ task('markdown-docs-cdk', () => {
124
127
* Creates syntax-highlighted html files from the examples to be used for the source view of
125
128
* live examples on the docs site.
126
129
*/
127
- task ( 'highlight -examples' , ( ) => {
130
+ task ( 'build-highlighted -examples' , ( ) => {
128
131
// rename files to fit format: [filename]-[filetype].html
129
132
const renameFile = ( filePath : any ) => {
130
133
const extension = filePath . extname . slice ( 1 ) ;
@@ -144,15 +147,18 @@ task('api-docs', () => {
144
147
return docs . generate ( ) ;
145
148
} ) ;
146
149
147
- /** Generates minified html api docs. */
148
- task ( 'minified-api-docs' , [ 'api-docs' ] , ( ) => {
149
- return src ( 'dist/docs/api/*.html' )
150
+ /**
151
+ * Minifies all HTML files that have been generated. The HTML files for the
152
+ * highlighted examples can be skipped, because it won't have any effect.
153
+ */
154
+ task ( 'minify-html-files' , [ 'api-docs' ] , ( ) => {
155
+ return src ( 'dist/docs/+(api|markdown)/**/*.html' )
150
156
. pipe ( htmlmin ( htmlMinifierOptions ) )
151
- . pipe ( dest ( 'dist/docs/api/ ' ) ) ;
157
+ . pipe ( dest ( 'dist/docs' ) ) ;
152
158
} ) ;
153
159
154
160
/** Copies example sources to be used as stackblitz assets for the docs site. */
155
- task ( 'stackblitz-example-assets ' , ( ) => {
161
+ task ( 'copy- stackblitz-examples ' , ( ) => {
156
162
src ( path . join ( packagesDir , 'material-examples' , '**/*' ) )
157
163
. pipe ( dest ( path . join ( DIST_DOCS , 'stackblitz' , 'examples' ) ) ) ;
158
164
} ) ;
0 commit comments