How to use the catharsis.describe function in catharsis

To help you get started, we’ve selected a few catharsis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hegemonic / jsdoc-baseline / lib / helpers / expression / index.js View on Github external
let description;

            if (typeof format !== 'string') {
                format = 'simple';
            } else if (!['extended', 'simple'].includes(format)) {
                throw new Exception('The {{describeType}} helper accepts the options "simple" ' +
                    'and "extended".');
            } else if (format === 'extended' && typeof property !== 'string') {
                property = 'description';
            }

            if (typeof parsedType === 'object') {
                description = catharsis.describe(parsedType, catharsisOptions);
            } else {
                // We don't know the type
                description = catharsis.describe(catharsis.parse('?'), catharsisOptions);
            }

            if (format === 'extended') {
                return new SafeString(_.get(description.extended, property));
            } else {
                return new SafeString(description.simple);
            }
        },
github hegemonic / jsdoc-baseline / lib / helpers.js View on Github external
Helpers.prototype.describeType = function describeType(parsedType, options) {
    var catharsisOptions = {
        // TODO: add codeTag and/or codeClass based on config
        // TODO: use the correct locale
        links: templateHelper.longnameToUrl
    };
    var description;

    options = _.defaults(options || {}, {
        format: 'simple'
    });

    description = catharsis.describe(parsedType, catharsisOptions);

    switch(options.format) {
        case 'extended':
            return description.extended;
        default: {
            return description.simple;
        }
    }
};
github hegemonic / jsdoc-baseline / lib / helpers / expression / index.js View on Github external
describeType(parsedType, format, property) {
            const catharsisOptions = getCatharsisOptions(template);
            let description;

            if (typeof format !== 'string') {
                format = 'simple';
            } else if (!['extended', 'simple'].includes(format)) {
                throw new Exception('The {{describeType}} helper accepts the options "simple" ' +
                    'and "extended".');
            } else if (format === 'extended' && typeof property !== 'string') {
                property = 'description';
            }

            if (typeof parsedType === 'object') {
                description = catharsis.describe(parsedType, catharsisOptions);
            } else {
                // We don't know the type
                description = catharsis.describe(catharsis.parse('?'), catharsisOptions);
            }

            if (format === 'extended') {
                return new SafeString(_.get(description.extended, property));
            } else {
                return new SafeString(description.simple);
            }
        },

catharsis

A JavaScript parser for Google Closure Compiler and JSDoc type expressions.

MIT
Latest version published 4 years ago

Package Health Score

70 / 100
Full package analysis

Similar packages