mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Merge pull request #141 from hegemonic/strict-fix
--strict option doesn't work correctly
This commit is contained in:
commit
110644f3e2
@ -12,8 +12,7 @@ var common = {
|
||||
var argParser = new common.args.ArgParser(),
|
||||
ourOptions,
|
||||
defaults = {
|
||||
destination: './out/',
|
||||
strict: true
|
||||
destination: './out/'
|
||||
};
|
||||
|
||||
argParser.addOption('t', 'template', true, 'The name of the template to use. Default: the "default" template');
|
||||
@ -23,7 +22,7 @@ argParser.addOption('T', 'test', false, 'Run all tests and quit.');
|
||||
argParser.addOption('d', 'destination', true, 'The path to the output folder. Use "console" to dump data to the console. Default: console');
|
||||
argParser.addOption('p', 'private', false, 'Display symbols marked with the @private tag. Default: false.');
|
||||
argParser.addOption('r', 'recurse', false, 'Recurse into subdirectories when scanning for source code files.');
|
||||
argParser.addOption('s', 'strict', false, 'Exit immediately if a doclet is incomplete or contains errors. Default: true');
|
||||
argParser.addOption('l', 'lenient', false, 'Continue to generate output if a doclet is incomplete or contains errors. Default: false.');
|
||||
argParser.addOption('h', 'help', false, 'Print this message and quit.');
|
||||
argParser.addOption('X', 'explain', false, 'Dump all found doclet internals to console and quit.');
|
||||
argParser.addOption('q', 'query', true, 'Provide a querystring to define custom variable names/values to add to the options hash.');
|
||||
|
||||
@ -86,15 +86,15 @@ exports.Tag = function(tagTitle, tagBody, meta) {
|
||||
}
|
||||
}
|
||||
|
||||
// validate the tag. for strict validation, throw an exception; otherwise, log a warning.
|
||||
// validate the tag. in lenient mode, log a warning; otherwise, throw an exception.
|
||||
try {
|
||||
jsdoc.tag.validator.validate(this, meta);
|
||||
}
|
||||
catch (e) {
|
||||
if (env.opts.strict) {
|
||||
throw e;
|
||||
} else {
|
||||
if (env.opts.lenient) {
|
||||
console.log(e);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,31 +8,29 @@ describe("jsdoc/tag", function() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
it("has strict validation enabled by default", function() {
|
||||
it("is strict, not lenient, by default", function() {
|
||||
expect(badTag).toThrow();
|
||||
});
|
||||
|
||||
it("throws an exception for bad tags if strict validation is enabled", function() {
|
||||
var strict = !!env.opts.strict;
|
||||
|
||||
env.opts.strict = true;
|
||||
it("throws an exception for bad tags if the lenient option is not enabled", function() {
|
||||
var lenient = !!env.opts.lenient;
|
||||
|
||||
env.opts.lenient = false;
|
||||
expect(badTag).toThrow();
|
||||
|
||||
env.opts.strict = strict;
|
||||
env.opts.lenient = lenient;
|
||||
});
|
||||
|
||||
it("doesn't throw an exception for bad tags if strict validation is disabled", function() {
|
||||
it("doesn't throw an exception for bad tags if the lenient option is enabled", function() {
|
||||
/*jshint evil: true */
|
||||
var strict = !!env.opts.strict,
|
||||
log = new Function(console.log);
|
||||
|
||||
var lenient = !!env.opts.lenient,
|
||||
log = eval(console.log);
|
||||
console.log = function() {};
|
||||
env.opts.strict = false;
|
||||
|
||||
env.opts.lenient = true;
|
||||
expect(badTag).not.toThrow();
|
||||
|
||||
env.opts.strict = strict;
|
||||
env.opts.lenient = lenient;
|
||||
console.log = log;
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user