1
1
import gulp = require( 'gulp' ) ;
2
2
const markdown = require ( 'gulp-markdown' ) ;
3
3
const transform = require ( 'gulp-transform' ) ;
4
+ const highlight = require ( 'gulp-highlight-files' ) ;
5
+ const rename = require ( 'gulp-rename' ) ;
6
+ const flatten = require ( 'gulp-flatten' ) ;
4
7
const hljs = require ( 'highlight.js' ) ;
5
8
import { task } from 'gulp' ;
6
9
import * as path from 'path' ;
@@ -16,7 +19,7 @@ const EXAMPLE_PATTERN = /<!--\W*example\(([^)]+)\)\W*-->/g;
16
19
// documentation page. Using a RegExp to rewrite links in HTML files to work in the docs.
17
20
const LINK_PATTERN = / ( < a [ ^ > ] * ) h r e f = " ( [ ^ " ] * ) " / g;
18
21
19
- gulp . task ( 'docs' , [ 'markdown-docs' , 'api-docs' ] )
22
+ gulp . task ( 'docs' , [ 'markdown-docs' , 'highlight-docs' , ' api-docs'] )
20
23
21
24
gulp . task ( 'markdown-docs' , ( ) => {
22
25
return gulp . src ( [ 'src/lib/**/*.md' , 'guides/*.md' ] )
@@ -36,6 +39,20 @@ gulp.task('markdown-docs', () => {
36
39
. pipe ( gulp . dest ( 'dist/docs/markdown' ) ) ;
37
40
} ) ;
38
41
42
+ gulp . task ( 'highlight-docs' , ( ) => {
43
+ // rename files to fit format: [filename]-[filetype].html
44
+ const renameFile = ( path : any ) => {
45
+ const extension = path . extname . slice ( 1 ) ;
46
+ path . basename = `${ path . basename } -${ extension } ` ;
47
+ } ;
48
+
49
+ return gulp . src ( 'src/examples/**/*.+(html|css|ts)' )
50
+ . pipe ( flatten ( ) )
51
+ . pipe ( rename ( renameFile ) )
52
+ . pipe ( highlight ( ) )
53
+ . pipe ( gulp . dest ( 'dist/docs/examples' ) ) ;
54
+ } ) ;
55
+
39
56
task ( 'api-docs' , ( ) => {
40
57
const Dgeni = require ( 'dgeni' ) ;
41
58
const docsPackage = require ( path . resolve ( __dirname , '../../dgeni' ) ) ;
0 commit comments