File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
var walk = require ( '../walk' ) ,
4
+ path = require ( 'path' ) ,
4
5
hljs = require ( 'highlight.js' ) ;
5
6
6
7
/**
@@ -50,5 +51,9 @@ function highlight(comment, options) {
50
51
module . exports = function makeHTML ( comments , options , callback ) {
51
52
options = options || { } ;
52
53
comments = walk ( comments , highlight , options ) ;
53
- require ( options . theme || 'documentation-theme-default' ) ( comments , options , callback ) ;
54
+ var theme = require ( 'documentation-theme-default' ) ;
55
+ if ( options . theme ) {
56
+ theme = require ( path . resolve ( process . cwd ( ) , options . theme ) ) ;
57
+ }
58
+ theme ( comments , options , callback ) ;
54
59
} ;
Original file line number Diff line number Diff line change @@ -207,6 +207,20 @@ test('write to html', function (t) {
207
207
} , false ) ;
208
208
} , options ) ;
209
209
210
+ test ( 'write to html with custom theme' , function ( t ) {
211
+
212
+ var dstDir = path . join ( os . tmpdir ( ) , ( Date . now ( ) + Math . random ( ) ) . toString ( ) ) ;
213
+ fs . mkdirSync ( dstDir ) ;
214
+
215
+ documentation ( [ 'build -t fixture/custom_theme --shallow fixture/internal.input.js -f html -o ' + dstDir ] , { } ,
216
+ function ( err , data ) {
217
+ t . error ( err ) ;
218
+ t . equal ( data , '' ) ;
219
+ t . ok ( fs . readFileSync ( path . join ( dstDir , 'index.html' ) , 'utf8' ) , 'Hello world' ) ;
220
+ t . end ( ) ;
221
+ } , false ) ;
222
+ } , options ) ;
223
+
210
224
test ( 'write to html, highlightAuto' , function ( t ) {
211
225
212
226
var fixture = 'fixture/auto_lang_hljs/multilanguage.input.js' ,
Original file line number Diff line number Diff line change
1
+ var File = require ( 'vinyl' ) ;
2
+
3
+ /**
4
+ * This is a theme only used by documentation to test custom theme
5
+ * support.
6
+ */
7
+ module . exports = function ( comments , options , callback ) {
8
+ return callback ( null , [ new File ( {
9
+ base : '/' ,
10
+ path : '/index.html' ,
11
+ contents : new Buffer ( 'Hello world' )
12
+ } ) ] ) ;
13
+ } ;
You can’t perform that action at this time.
0 commit comments