mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
update catharsis to fix issues with repeatable types (#502)
This commit is contained in:
parent
68fb9cab6a
commit
30d9692c17
@ -16,7 +16,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "0.1.22",
|
"async": "0.1.22",
|
||||||
"catharsis": "0.6.0",
|
"catharsis": "0.7.0",
|
||||||
"crypto-browserify": "git+https://github.com/dominictarr/crypto-browserify.git#95c5d505",
|
"crypto-browserify": "git+https://github.com/dominictarr/crypto-browserify.git#95c5d505",
|
||||||
"js2xmlparser": "0.1.0",
|
"js2xmlparser": "0.1.0",
|
||||||
"jshint": "0.9.1",
|
"jshint": "0.9.1",
|
||||||
|
|||||||
2
node_modules/catharsis/catharsis.js
generated
vendored
2
node_modules/catharsis/catharsis.js
generated
vendored
@ -56,7 +56,7 @@ function cachedParse(expr, options) {
|
|||||||
var cache = getTypeExpressionCache(options);
|
var cache = getTypeExpressionCache(options);
|
||||||
var parsedType;
|
var parsedType;
|
||||||
|
|
||||||
if (cache && cache[expr]) {
|
if (cache && Object.prototype.hasOwnProperty.call(cache, expr)) {
|
||||||
return cache[expr];
|
return cache[expr];
|
||||||
} else {
|
} else {
|
||||||
parsedType = parse(expr, options);
|
parsedType = parse(expr, options);
|
||||||
|
|||||||
6
node_modules/catharsis/lib/parser.js
generated
vendored
6
node_modules/catharsis/lib/parser.js
generated
vendored
File diff suppressed because one or more lines are too long
57
node_modules/catharsis/lib/stringify.js
generated
vendored
57
node_modules/catharsis/lib/stringify.js
generated
vendored
@ -66,7 +66,6 @@ Stringifier.prototype.nullable = function(nullable) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Stringifier.prototype.optional = function(optional) {
|
Stringifier.prototype.optional = function(optional) {
|
||||||
/*jshint boss: true */ // TODO: remove after JSHint releases the fix for jshint/jshint#878
|
|
||||||
if (optional === true) {
|
if (optional === true) {
|
||||||
return '=';
|
return '=';
|
||||||
} else {
|
} else {
|
||||||
@ -111,43 +110,46 @@ Stringifier.prototype['this'] = function(funcThis) {
|
|||||||
return funcThis ? 'this:' + this.type(funcThis) : '';
|
return funcThis ? 'this:' + this.type(funcThis) : '';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: refactor for clarity
|
||||||
Stringifier.prototype.type = function(type) {
|
Stringifier.prototype.type = function(type) {
|
||||||
|
var result = '';
|
||||||
|
|
||||||
if (!type) {
|
if (!type) {
|
||||||
return '';
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// nullable comes first
|
|
||||||
var result = this.nullable(type.nullable);
|
|
||||||
|
|
||||||
// next portion varies by type
|
|
||||||
switch(type.type) {
|
switch(type.type) {
|
||||||
case Types.AllLiteral:
|
case Types.AllLiteral:
|
||||||
result += this._formatNameAndType(type, '*');
|
result += this._formatRepeatableAndNullable(type, '',
|
||||||
|
this._formatNameAndType(type, '*'));
|
||||||
break;
|
break;
|
||||||
case Types.FunctionType:
|
case Types.FunctionType:
|
||||||
result += this._signature(type);
|
result += this._signature(type);
|
||||||
break;
|
break;
|
||||||
case Types.NullLiteral:
|
case Types.NullLiteral:
|
||||||
result += this._formatNameAndType(type, 'null');
|
result += this._formatRepeatableAndNullable(type, '',
|
||||||
|
this._formatNameAndType(type, 'null'));
|
||||||
break;
|
break;
|
||||||
case Types.RecordType:
|
case Types.RecordType:
|
||||||
result += this._record(type);
|
result += this._formatRepeatableAndNullable(type, '', this._record(type));
|
||||||
break;
|
break;
|
||||||
case Types.TypeApplication:
|
case Types.TypeApplication:
|
||||||
result += this.type(type.expression);
|
result += this._formatRepeatableAndNullable(type, '', this.type(type.expression));
|
||||||
result += this.applications(type.applications);
|
result += this.applications(type.applications);
|
||||||
break;
|
break;
|
||||||
case Types.UndefinedLiteral:
|
case Types.UndefinedLiteral:
|
||||||
result += this._formatNameAndType(type, 'undefined');
|
result += this._formatRepeatableAndNullable(type, '',
|
||||||
|
this._formatNameAndType(type, 'undefined'));
|
||||||
break;
|
break;
|
||||||
case Types.TypeUnion:
|
case Types.TypeUnion:
|
||||||
result += this.elements(type.elements);
|
result += this._formatRepeatableAndNullable(type, '', this.elements(type.elements));
|
||||||
break;
|
break;
|
||||||
case Types.UnknownLiteral:
|
case Types.UnknownLiteral:
|
||||||
result += this._formatNameAndType(type, '?');
|
result += this._formatRepeatableAndNullable(type, '',
|
||||||
|
this._formatNameAndType(type, '?'));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
result += this._formatNameAndType(type);
|
result += this._formatRepeatableAndNullable(type, '', this._formatNameAndType(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally, optionality
|
// finally, optionality
|
||||||
@ -190,14 +192,23 @@ Stringifier.prototype._recordFields = function(fields) {
|
|||||||
|
|
||||||
function combineNameAndType(nameString, typeString) {
|
function combineNameAndType(nameString, typeString) {
|
||||||
var separator = (nameString && typeString) ? ':' : '';
|
var separator = (nameString && typeString) ? ':' : '';
|
||||||
|
|
||||||
return nameString + separator + typeString;
|
return nameString + separator + typeString;
|
||||||
}
|
}
|
||||||
|
|
||||||
Stringifier.prototype._formatRepeatable = function(nameString, typeString) {
|
Stringifier.prototype._formatRepeatableAndNullable = function(type, nameString, typeString) {
|
||||||
var open = this._inFunctionSignatureParams ? '...[' : '...';
|
var open = '';
|
||||||
var close = this._inFunctionSignatureParams ? ']' : '';
|
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) {
|
Stringifier.prototype._formatNameAndType = function(type, literal) {
|
||||||
@ -215,17 +226,14 @@ Stringifier.prototype._formatNameAndType = function(type, literal) {
|
|||||||
nameString = openTag + nameString + '</a>';
|
nameString = openTag + nameString + '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type.repeatable === true) {
|
return combineNameAndType(nameString, typeString);
|
||||||
return this._formatRepeatable(nameString, typeString);
|
|
||||||
} else {
|
|
||||||
return combineNameAndType(nameString, typeString);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Stringifier.prototype._signature = function(type) {
|
Stringifier.prototype._signature = function(type) {
|
||||||
var params = [];
|
var params = [];
|
||||||
var param;
|
var param;
|
||||||
var result;
|
var result;
|
||||||
|
var signatureBase;
|
||||||
|
|
||||||
// these go within the signature's parens, in this order
|
// these go within the signature's parens, in this order
|
||||||
var props = [
|
var props = [
|
||||||
@ -245,7 +253,8 @@ Stringifier.prototype._signature = function(type) {
|
|||||||
}
|
}
|
||||||
this._inFunctionSignatureParams = false;
|
this._inFunctionSignatureParams = false;
|
||||||
|
|
||||||
result = 'function(' + params.join(', ') + ')';
|
signatureBase = 'function(' + params.join(', ') + ')';
|
||||||
|
result = this._formatRepeatableAndNullable(type, '', signatureBase);
|
||||||
result += this.result(type.result);
|
result += this.result(type.result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
18
node_modules/catharsis/package.json
generated
vendored
18
node_modules/catharsis/package.json
generated
vendored
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "jsdoc",
|
"name": "jsdoc",
|
||||||
"version": "3.3.0-dev",
|
"version": "3.3.0-dev",
|
||||||
"revision": "1380989053246",
|
"revision": "1381768141793",
|
||||||
"description": "An API documentation generator for JavaScript.",
|
"description": "An API documentation generator for JavaScript.",
|
||||||
"keywords": [ "documentation", "javascript" ],
|
"keywords": [ "documentation", "javascript" ],
|
||||||
"licenses": [
|
"licenses": [
|
||||||
@ -16,7 +16,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "0.1.22",
|
"async": "0.1.22",
|
||||||
"catharsis": "0.6.0",
|
"catharsis": "0.7.0",
|
||||||
"crypto-browserify": "git+https://github.com/dominictarr/crypto-browserify.git#95c5d505",
|
"crypto-browserify": "git+https://github.com/dominictarr/crypto-browserify.git#95c5d505",
|
||||||
"js2xmlparser": "0.1.0",
|
"js2xmlparser": "0.1.0",
|
||||||
"jshint": "0.9.1",
|
"jshint": "0.9.1",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user