mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Added encoding option.
This commit is contained in:
parent
04bc22c2fa
commit
4820ac398d
2
main.js
2
main.js
@ -60,7 +60,7 @@
|
||||
|
||||
sourceFiles = jsdoc.src.getFilePaths(opts._);
|
||||
|
||||
jsdoc.parser.parseFiles(sourceFiles);
|
||||
jsdoc.parser.parseFiles(sourceFiles, opts.encoding);
|
||||
|
||||
if (opts.validate) {
|
||||
var jsonSchema = require('sitepen/jsonSchema');
|
||||
|
||||
@ -6,31 +6,37 @@
|
||||
|
||||
(function() {
|
||||
var slash = java.lang.System.getProperty('file.separator') || '/',
|
||||
File = Packages.java.io.File,
|
||||
File = java.io.File,
|
||||
defaultEncoding = java.lang.System.getProperty('file.encoding');
|
||||
|
||||
exports.read = function(path, options) {
|
||||
exports.read = function(path, encoding) {
|
||||
var options = options || {},
|
||||
encoding = options.encoding || defaultEncoding;
|
||||
encoding = encoding || defaultEncoding,
|
||||
input;
|
||||
print('encoding is '+encoding);
|
||||
input = new java.util.Scanner(
|
||||
new File(path),
|
||||
encoding
|
||||
).useDelimiter("\\Z");
|
||||
|
||||
return readFile(path, encoding);
|
||||
return String( input.next() );
|
||||
}
|
||||
|
||||
exports.write = function(path, content, options) {
|
||||
exports.write = function(path, content, encoding) {
|
||||
var options = options || {},
|
||||
encoding = options.encoding || defaultEncoding,
|
||||
out;
|
||||
encoding = encoding || defaultEncoding,
|
||||
output;
|
||||
|
||||
out = new Packages.java.io.PrintWriter(
|
||||
new Packages.java.io.OutputStreamWriter(
|
||||
new Packages.java.io.FileOutputStream(path),
|
||||
output = new java.io.PrintWriter(
|
||||
new java.io.OutputStreamWriter(
|
||||
new java.io.FileOutputStream(path),
|
||||
encoding
|
||||
)
|
||||
);
|
||||
|
||||
out.write(content);
|
||||
out.flush();
|
||||
out.close();
|
||||
output.write(content);
|
||||
output.flush();
|
||||
output.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -18,9 +18,10 @@
|
||||
destination: 'jsdoc.xml'
|
||||
};
|
||||
|
||||
argsParser.addOption('t', 'template', true, 'The name of the template to use.');
|
||||
argsParser.addOption('t', 'template', true, 'The name of the template to use. Default: the "default" template');
|
||||
argsParser.addOption('e', 'encoding', true, 'Assume this encoding when reading all source files. Default: your system default encoding');
|
||||
argsParser.addOption('T', 'test', false, 'Run unit tests and quit.');
|
||||
argsParser.addOption('d', 'destination', true, 'The path to output folder.');
|
||||
argsParser.addOption('d', 'destination', true, 'The path to output folder. Default: ./jsdocs');
|
||||
argsParser.addOption('h', 'help', false, 'Print help message and quit.');
|
||||
argsParser.addOption('V', 'validate', false, 'Validate the results produced by parsing the source code.');
|
||||
|
||||
|
||||
@ -125,17 +125,17 @@
|
||||
|
||||
/**
|
||||
*/
|
||||
exports.parseFiles = function(sourceFiles) {
|
||||
exports.parseFiles = function(sourceFiles, encoding) {
|
||||
var ast = getParser(),
|
||||
fs = require('common/fs'),
|
||||
source = '';
|
||||
|
||||
for (i = 0, leni = sourceFiles.length; i < leni; i++) {
|
||||
try {
|
||||
source = fs.read(sourceFiles[i]);
|
||||
source = fs.read(sourceFiles[i], encoding);
|
||||
}
|
||||
catch(e) {
|
||||
print('ERROR: ' + e);
|
||||
print('FILE READ ERROR: ' + e);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user