11import gulp = require( 'gulp' ) ;
22const markdown = require ( 'gulp-markdown' ) ;
33const transform = require ( 'gulp-transform' ) ;
4+ const highlight = require ( 'gulp-highlight-files' ) ;
5+ const rename = require ( 'gulp-rename' ) ;
6+ const flatten = require ( 'gulp-flatten' ) ;
47const hljs = require ( 'highlight.js' ) ;
58import { task } from 'gulp' ;
69import * as path from 'path' ;
@@ -16,7 +19,7 @@ const EXAMPLE_PATTERN = /<!--\W*example\(([^)]+)\)\W*-->/g;
1619// documentation page. Using a RegExp to rewrite links in HTML files to work in the docs.
1720const LINK_PATTERN = / ( < a [ ^ > ] * ) h r e f = " ( [ ^ " ] * ) " / g;
1821
19- gulp . task ( 'docs' , [ 'markdown-docs' , 'api-docs' ] )
22+ gulp . task ( 'docs' , [ 'markdown-docs' , 'highlight-docs' , ' api-docs'] )
2023
2124gulp . task ( 'markdown-docs' , ( ) => {
2225 return gulp . src ( [ 'src/lib/**/*.md' , 'guides/*.md' ] )
@@ -36,6 +39,20 @@ gulp.task('markdown-docs', () => {
3639 . pipe ( gulp . dest ( 'dist/docs/markdown' ) ) ;
3740} ) ;
3841
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+
3956task ( 'api-docs' , ( ) => {
4057 const Dgeni = require ( 'dgeni' ) ;
4158 const docsPackage = require ( path . resolve ( __dirname , '../../dgeni' ) ) ;
0 commit comments