Skip to content

Commit 1270823

Browse files
author
Ilya Radchenko
committed
Fix default theme resolve
1 parent fb9fcfb commit 1270823

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/output/html.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
var File = require('vinyl'),
44
vfs = require('vinyl-fs'),
5+
extend = require('extend'),
56
concat = require('concat-stream'),
67
Handlebars = require('handlebars'),
7-
extend = require('extend'),
88
walk = require('../walk'),
99
getTemplate = require('../get_template'),
1010
resolveTheme = require('../resolve_theme'),
@@ -47,16 +47,12 @@ function highlight(comment) {
4747
* @name html
4848
*/
4949
module.exports = function makeHTML(comments, opts, callback) {
50-
5150
comments = walk(comments, highlight);
5251

53-
var options = extend({}, {
54-
theme: 'documentation-theme-default'
55-
}, opts);
56-
52+
var options = extend({}, opts);
5753
var themeModule = resolveTheme(options.theme);
58-
5954
var pageTemplate = getTemplate(Handlebars, themeModule, 'index.hbs');
55+
6056
Handlebars.registerPartial('section',
6157
getTemplate(Handlebars, themeModule, 'section.hbs'));
6258

@@ -75,7 +71,7 @@ module.exports = function makeHTML(comments, opts, callback) {
7571
path: 'index.html',
7672
contents: new Buffer(pageTemplate({
7773
docs: comments,
78-
options: opts
74+
options: options
7975
}), 'utf8')
8076
})));
8177
}));

lib/resolve_theme.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ var path = require('path'),
66
/**
77
* Given the name of a theme as a module, return the directory it
88
* resides in, or throw an error if it is not found
9-
* @param {string} theme the module name
9+
* @param {string} [theme='documentation-theme-default'] the module name
1010
* @throws {Error} if theme is not found
1111
* @returns {string} directory
1212
*/
1313
function resolveTheme(theme) {
14+
var basedir = theme ? process.cwd() : __dirname;
15+
16+
theme = theme || 'documentation-theme-default';
17+
1418
try {
15-
return path.dirname(resolve.sync(theme, { basedir: process.cwd() }));
19+
return path.dirname(resolve.sync(theme, { basedir: basedir }));
1620
} catch (e) {
1721
throw new Error('Theme ' + theme + ' not found');
1822
}

0 commit comments

Comments
 (0)