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' ) ;
8+ const exec = require ( 'child_process' ) . exec ;
59import { task } from 'gulp' ;
610import * as path from 'path' ;
711
@@ -16,7 +20,7 @@ const EXAMPLE_PATTERN = /<!--\W*example\(([^)]+)\)\W*-->/g;
1620// documentation page. Using a RegExp to rewrite links in HTML files to work in the docs.
1721const LINK_PATTERN = / ( < a [ ^ > ] * ) h r e f = " ( [ ^ " ] * ) " / g;
1822
19- gulp . task ( 'docs' , [ 'markdown-docs' , 'api-docs' ] )
23+ gulp . task ( 'docs' , [ 'markdown-docs' , 'highlight-docs' , ' api-docs'] )
2024
2125gulp . task ( 'markdown-docs' , ( ) => {
2226 return gulp . src ( [ 'src/lib/**/*.md' , 'guides/*.md' ] )
@@ -36,6 +40,20 @@ gulp.task('markdown-docs', () => {
3640 . pipe ( gulp . dest ( 'dist/docs/markdown' ) ) ;
3741} ) ;
3842
43+ gulp . task ( 'highlight-docs' , ( ) => {
44+ // rename files to fit format: [filename]-[filetype].html
45+ const renameFile = ( path : any ) => {
46+ const extension = path . extname . slice ( 1 ) ;
47+ path . basename = `${ path . basename } -${ extension } ` ;
48+ } ;
49+
50+ return gulp . src ( 'src/examples/**/*.+(html|css|ts)' )
51+ . pipe ( flatten ( ) )
52+ . pipe ( rename ( renameFile ) )
53+ . pipe ( highlight ( ) )
54+ . pipe ( gulp . dest ( 'dist/docs/examples' ) ) ;
55+ } ) ;
56+
3957task ( 'api-docs' , ( ) => {
4058 const Dgeni = require ( 'dgeni' ) ;
4159 const docsPackage = require ( path . resolve ( __dirname , '../../dgeni' ) ) ;
0 commit comments