This commit is contained in:
Jeff Williams 2013-09-30 22:25:06 -07:00
commit 1a8fac17f0

View File

@ -132,7 +132,8 @@ function generate(title, docs, filename, resolveLinks) {
fs.writeFileSync(outpath, html, 'utf8'); fs.writeFileSync(outpath, html, 'utf8');
} }
function generateSourceFiles(sourceFiles) { function generateSourceFiles(sourceFiles, encoding) {
encoding = encoding || 'utf8';
Object.keys(sourceFiles).forEach(function(file) { Object.keys(sourceFiles).forEach(function(file) {
var source; var source;
// links are keyed to the shortened path in each doclet's `meta.filename` property // links are keyed to the shortened path in each doclet's `meta.filename` property
@ -142,7 +143,7 @@ function generateSourceFiles(sourceFiles) {
try { try {
source = { source = {
kind: 'source', kind: 'source',
code: helper.htmlsafe( fs.readFileSync(sourceFiles[file].resolved, 'utf8') ) code: helper.htmlsafe( fs.readFileSync(sourceFiles[file].resolved, encoding) )
}; };
} }
catch(e) { catch(e) {
@ -486,7 +487,7 @@ exports.publish = function(taffyData, opts, tutorials) {
// output pretty-printed source files by default; do this before generating any other pages, so // output pretty-printed source files by default; do this before generating any other pages, so
// that the other pages can link to the source files // that the other pages can link to the source files
if (!conf['default'] || conf['default'].outputSourceFiles !== false) { if (!conf['default'] || conf['default'].outputSourceFiles !== false) {
generateSourceFiles(sourceFiles); generateSourceFiles(sourceFiles, opts.encoding);
} }
if (members.globals.length) { generate('Global', [{kind: 'globalobj'}], globalUrl); } if (members.globals.length) { generate('Global', [{kind: 'globalobj'}], globalUrl); }