1
- import gulp = require( 'gulp' ) ;
1
+ import { task , src , dest } from 'gulp' ;
2
+ import { Dgeni } from 'dgeni' ;
3
+ import * as path from 'path' ;
4
+
5
+ // Node packages that lack of types.
2
6
const markdown = require ( 'gulp-markdown' ) ;
3
7
const transform = require ( 'gulp-transform' ) ;
4
8
const highlight = require ( 'gulp-highlight-files' ) ;
5
9
const rename = require ( 'gulp-rename' ) ;
6
10
const flatten = require ( 'gulp-flatten' ) ;
7
11
const hljs = require ( 'highlight.js' ) ;
8
- import { task } from 'gulp' ;
9
- import * as path from 'path' ;
10
12
11
13
// Our docs contain comments of the form `<!-- example(...) -->` which serve as placeholders where
12
14
// example code should be inserted. We replace these comments with divs that have a
@@ -19,10 +21,10 @@ const EXAMPLE_PATTERN = /<!--\W*example\(([^)]+)\)\W*-->/g;
19
21
// documentation page. Using a RegExp to rewrite links in HTML files to work in the docs.
20
22
const LINK_PATTERN = / ( < a [ ^ > ] * ) h r e f = " ( [ ^ " ] * ) " / g;
21
23
22
- gulp . task ( 'docs' , [ 'markdown-docs' , 'highlight-docs' , 'api-docs' ] )
24
+ task ( 'docs' , [ 'markdown-docs' , 'highlight-docs' , 'api-docs' ] ) ;
23
25
24
- gulp . task ( 'markdown-docs' , ( ) => {
25
- return gulp . src ( [ 'src/lib/**/*.md' , 'guides/*.md' ] )
26
+ task ( 'markdown-docs' , ( ) => {
27
+ return src ( [ 'src/lib/**/*.md' , 'guides/*.md' ] )
26
28
. pipe ( markdown ( {
27
29
// Add syntax highlight using highlight.js
28
30
highlight : ( code : string , language : string ) => {
@@ -36,28 +38,27 @@ gulp.task('markdown-docs', () => {
36
38
}
37
39
} ) )
38
40
. pipe ( transform ( transformMarkdownFiles ) )
39
- . pipe ( gulp . dest ( 'dist/docs/markdown' ) ) ;
41
+ . pipe ( dest ( 'dist/docs/markdown' ) ) ;
40
42
} ) ;
41
43
42
- gulp . task ( 'highlight-docs' , ( ) => {
44
+ task ( 'highlight-docs' , ( ) => {
43
45
// rename files to fit format: [filename]-[filetype].html
44
46
const renameFile = ( path : any ) => {
45
47
const extension = path . extname . slice ( 1 ) ;
46
48
path . basename = `${ path . basename } -${ extension } ` ;
47
49
} ;
48
50
49
- return gulp . src ( 'src/examples/**/*.+(html|css|ts)' )
51
+ return src ( 'src/examples/**/*.+(html|css|ts)' )
50
52
. pipe ( flatten ( ) )
51
53
. pipe ( rename ( renameFile ) )
52
54
. pipe ( highlight ( ) )
53
- . pipe ( gulp . dest ( 'dist/docs/examples' ) ) ;
55
+ . pipe ( dest ( 'dist/docs/examples' ) ) ;
54
56
} ) ;
55
57
56
58
task ( 'api-docs' , ( ) => {
57
- const Dgeni = require ( 'dgeni' ) ;
58
59
const docsPackage = require ( path . resolve ( __dirname , '../../dgeni' ) ) ;
59
- const dgeni = new Dgeni ( [ docsPackage ] ) ;
60
- return dgeni . generate ( ) ;
60
+ const docs = new Dgeni ( [ docsPackage ] ) ;
61
+ return docs . generate ( ) ;
61
62
} ) ;
62
63
63
64
/** Updates the markdown file's content to work inside of the docs app. */
0 commit comments