update catharsis to fix issues with repeatable types (#502)

This commit is contained in:
Jeff Williams 2013-10-14 09:32:20 -07:00
parent 68fb9cab6a
commit 30d9692c17
6 changed files with 52 additions and 37 deletions

View File

@ -16,7 +16,7 @@
},
"dependencies": {
"async": "0.1.22",
"catharsis": "0.6.0",
"catharsis": "0.7.0",
"crypto-browserify": "git+https://github.com/dominictarr/crypto-browserify.git#95c5d505",
"js2xmlparser": "0.1.0",
"jshint": "0.9.1",

View File

@ -56,7 +56,7 @@ function cachedParse(expr, options) {
var cache = getTypeExpressionCache(options);
var parsedType;
if (cache && cache[expr]) {
if (cache && Object.prototype.hasOwnProperty.call(cache, expr)) {
return cache[expr];
} else {
parsedType = parse(expr, options);

File diff suppressed because one or more lines are too long

View File

@ -66,7 +66,6 @@ Stringifier.prototype.nullable = function(nullable) {
};
Stringifier.prototype.optional = function(optional) {
/*jshint boss: true */ // TODO: remove after JSHint releases the fix for jshint/jshint#878
if (optional === true) {
return '=';
} else {
@ -111,43 +110,46 @@ Stringifier.prototype['this'] = function(funcThis) {
return funcThis ? 'this:' + this.type(funcThis) : '';
};
// TODO: refactor for clarity
Stringifier.prototype.type = function(type) {
var result = '';
if (!type) {
return '';
return result;
}
// nullable comes first
var result = this.nullable(type.nullable);
// next portion varies by type
switch(type.type) {
case Types.AllLiteral:
result += this._formatNameAndType(type, '*');
result += this._formatRepeatableAndNullable(type, '',
this._formatNameAndType(type, '*'));
break;
case Types.FunctionType:
result += this._signature(type);
break;
case Types.NullLiteral:
result += this._formatNameAndType(type, 'null');
result += this._formatRepeatableAndNullable(type, '',
this._formatNameAndType(type, 'null'));
break;
case Types.RecordType:
result += this._record(type);
result += this._formatRepeatableAndNullable(type, '', this._record(type));
break;
case Types.TypeApplication:
result += this.type(type.expression);
result += this._formatRepeatableAndNullable(type, '', this.type(type.expression));
result += this.applications(type.applications);
break;
case Types.UndefinedLiteral:
result += this._formatNameAndType(type, 'undefined');
result += this._formatRepeatableAndNullable(type, '',
this._formatNameAndType(type, 'undefined'));
break;
case Types.TypeUnion:
result += this.elements(type.elements);
result += this._formatRepeatableAndNullable(type, '', this.elements(type.elements));
break;
case Types.UnknownLiteral:
result += this._formatNameAndType(type, '?');
result += this._formatRepeatableAndNullable(type, '',
this._formatNameAndType(type, '?'));
break;
default:
result += this._formatNameAndType(type);
result += this._formatRepeatableAndNullable(type, '', this._formatNameAndType(type));
}
// finally, optionality
@ -190,14 +192,23 @@ Stringifier.prototype._recordFields = function(fields) {
function combineNameAndType(nameString, typeString) {
var separator = (nameString && typeString) ? ':' : '';
return nameString + separator + typeString;
}
Stringifier.prototype._formatRepeatable = function(nameString, typeString) {
var open = this._inFunctionSignatureParams ? '...[' : '...';
var close = this._inFunctionSignatureParams ? ']' : '';
Stringifier.prototype._formatRepeatableAndNullable = function(type, nameString, typeString) {
var open = '';
var close = '';
var combined;
return open + combineNameAndType(nameString, typeString) + close;
if (type.repeatable) {
open = this._inFunctionSignatureParams ? '...[' : '...';
close = this._inFunctionSignatureParams ? ']' : '';
}
combined = this.nullable(type.nullable) + combineNameAndType(nameString, typeString);
return open + combined + close;
};
Stringifier.prototype._formatNameAndType = function(type, literal) {
@ -215,17 +226,14 @@ Stringifier.prototype._formatNameAndType = function(type, literal) {
nameString = openTag + nameString + '</a>';
}
if (type.repeatable === true) {
return this._formatRepeatable(nameString, typeString);
} else {
return combineNameAndType(nameString, typeString);
}
return combineNameAndType(nameString, typeString);
};
Stringifier.prototype._signature = function(type) {
var params = [];
var param;
var result;
var signatureBase;
// these go within the signature's parens, in this order
var props = [
@ -245,7 +253,8 @@ Stringifier.prototype._signature = function(type) {
}
this._inFunctionSignatureParams = false;
result = 'function(' + params.join(', ') + ')';
signatureBase = 'function(' + params.join(', ') + ')';
result = this._formatRepeatableAndNullable(type, '', signatureBase);
result += this.result(type.result);
return result;

18
node_modules/catharsis/package.json generated vendored

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{
"name": "jsdoc",
"version": "3.3.0-dev",
"revision": "1380989053246",
"revision": "1381768141793",
"description": "An API documentation generator for JavaScript.",
"keywords": [ "documentation", "javascript" ],
"licenses": [
@ -16,7 +16,7 @@
},
"dependencies": {
"async": "0.1.22",
"catharsis": "0.6.0",
"catharsis": "0.7.0",
"crypto-browserify": "git+https://github.com/dominictarr/crypto-browserify.git#95c5d505",
"js2xmlparser": "0.1.0",
"jshint": "0.9.1",