Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function parseTypeExpression(tagInfo) {
var errorMessage;
var parsedType;
// don't try to parse empty type expressions
if (!tagInfo.typeExpression) {
return tagInfo;
}
try {
parsedType = catharsis.parse(tagInfo.typeExpression, {jsdoc: true});
}
catch (e) {
// always re-throw so the caller has a chance to report which file was bad
throw new Error( util.format('Invalid type expression "%s": %s', tagInfo.typeExpression,
e.message) );
}
tagInfo.type = tagInfo.type.concat( getTypeStrings(parsedType, true) );
tagInfo.parsedType = parsedType;
// Catharsis and JSDoc use the same names for 'optional' and 'nullable'...
['optional', 'nullable'].forEach(function(key) {
if (parsedType[key] !== null && parsedType[key] !== undefined) {
tagInfo[key] = parsedType[key];
}
});
function parseTypeExpression(tagInfo) {
let parsedType;
// don't try to parse empty type expressions
if (!tagInfo.typeExpression) {
return tagInfo;
}
try {
parsedType = catharsis.parse(tagInfo.typeExpression, {jsdoc: true});
}
catch (e) {
// always re-throw so the caller has a chance to report which file was bad
throw new Error(`Invalid type expression "${tagInfo.typeExpression}": ${e.message}`);
}
tagInfo.type = tagInfo.type.concat( getTypeStrings(parsedType, true) );
tagInfo.parsedType = parsedType;
// Catharsis and JSDoc use the same names for 'optional' and 'nullable'...
['optional', 'nullable'].forEach(key => {
if (parsedType[key] !== null && parsedType[key] !== undefined) {
tagInfo[key] = parsedType[key];
}
});
describe('describeType', () => {
const catharsis = require('catharsis');
const parsedType = catharsis.parse('!string');
it('should use "unknown type" if no type is provided', () => {
const description = instance.describeType(undefined);
expect(description).toBeInstanceOf(SafeString);
expect(description.toString()).toBe('unknown');
});
it('should throw if the requested format is not available', () => {
function shouldThrow() {
return instance.describeType(parsedType, 'marshmallow');
}
expect(shouldThrow).toThrow();
});
function parseType(longname) {
var catharsis = require('catharsis');
var err;
try {
return catharsis.parse(longname, {jsdoc: true});
}
catch (e) {
err = new Error('unable to parse ' + longname + ': ' + e.message);
require('jsdoc/util/error').handle(err);
return longname;
}
}
function parseType(longname) {
let err;
try {
return catharsis.parse(longname, {jsdoc: true});
}
catch (e) {
err = new Error(`unable to parse ${longname}: ${e.message}`);
logger.error(err);
return longname;
}
}
function parseType(longname) {
var err;
longname = longname.replace('<', '<');
try {
return catharsis.parse(longname, { jsdoc: true });
} catch (e) {
err = new Error(`unable to parse ${longname}: ${e.message}`);
logger.error(err);
return longname;
}
}
function parseType(longname) {
var catharsis = require('catharsis');
var err;
try {
return catharsis.parse(longname, {jsdoc: true});
}
catch (e) {
err = new Error('unable to parse ' + longname + ': ' + e.message);
require('jsdoc/util/logger').error(err);
return longname;
}
}
function parseType(longname) {
var err;
try {
return catharsis.parse(longname, {jsdoc: true});
}
catch (e) {
err = new Error('unable to parse ' + longname + ': ' + e.message);
require('jsdoc/util/logger').error(err);
return longname;
}
}