HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/design.system/node_modules/react-docgen/dist/utils/parseJsDoc.js
import doctrine from 'doctrine';
function getType(tagType) {
    if (!tagType) {
        return null;
    }
    switch (tagType.type) {
        case 'NameExpression':
            // {a}
            return { name: tagType.name };
        case 'UnionType':
            // {a|b}
            return {
                name: 'union',
                elements: tagType.elements
                    .map((element) => getType(element))
                    .filter(Boolean),
            };
        case 'AllLiteral':
            // {*}
            return { name: 'mixed' };
        case 'TypeApplication':
            // {Array<string>} or {string[]}
            return {
                name: 'name' in tagType.expression ? tagType.expression.name : '',
                elements: tagType.applications
                    .map((element) => getType(element))
                    .filter(Boolean),
            };
        case 'ArrayType':
            // {[number, string]}
            return {
                name: 'tuple',
                elements: tagType.elements
                    .map((element) => getType(element))
                    .filter(Boolean),
            };
        default: {
            const typeName = 'name' in tagType && tagType.name
                ? tagType.name
                : 'expression' in tagType &&
                    tagType.expression &&
                    'name' in tagType.expression
                    ? tagType.expression.name
                    : null;
            if (typeName) {
                return { name: typeName };
            }
            else {
                return null;
            }
        }
    }
}
function getOptional(tag) {
    return !!(tag.type && tag.type.type && tag.type.type === 'OptionalType');
}
// Add jsdoc @return description.
function getReturnsJsDoc(jsDoc) {
    const returnTag = jsDoc.tags.find((tag) => tag.title === 'return' || tag.title === 'returns');
    if (returnTag) {
        return {
            description: returnTag.description,
            type: getType(returnTag.type),
        };
    }
    return null;
}
// Add jsdoc @param descriptions.
function getParamsJsDoc(jsDoc) {
    if (!jsDoc.tags) {
        return [];
    }
    return jsDoc.tags
        .filter((tag) => tag.title === 'param')
        .map((tag) => {
        return {
            name: tag.name || '',
            description: tag.description,
            type: getType(tag.type),
            optional: getOptional(tag),
        };
    });
}
export default function parseJsDoc(docblock) {
    const jsDoc = doctrine.parse(docblock);
    return {
        description: jsDoc.description || null,
        params: getParamsJsDoc(jsDoc),
        returns: getReturnsJsDoc(jsDoc),
    };
}