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/handlers/displayNameHandler.js
import getMemberValuePath from '../utils/getMemberValuePath.js';
import getNameOrValue from '../utils/getNameOrValue.js';
import isReactForwardRefCall from '../utils/isReactForwardRefCall.js';
import resolveToValue from '../utils/resolveToValue.js';
import resolveFunctionDefinitionToReturnValue from '../utils/resolveFunctionDefinitionToReturnValue.js';
const displayNameHandler = function (documentation, componentDefinition) {
    let displayNamePath = getMemberValuePath(componentDefinition, 'displayName');
    if (!displayNamePath) {
        // Function and class declarations need special treatment. The name of the
        // function / class is the displayName
        if ((componentDefinition.isClassDeclaration() ||
            componentDefinition.isFunctionDeclaration()) &&
            componentDefinition.has('id')) {
            documentation.set('displayName', getNameOrValue(componentDefinition.get('id')));
        }
        else if (componentDefinition.isArrowFunctionExpression() ||
            componentDefinition.isFunctionExpression() ||
            isReactForwardRefCall(componentDefinition)) {
            let currentPath = componentDefinition;
            while (currentPath.parentPath) {
                if (currentPath.parentPath.isVariableDeclarator()) {
                    documentation.set('displayName', getNameOrValue(currentPath.parentPath.get('id')));
                    return;
                }
                else if (currentPath.parentPath.isAssignmentExpression()) {
                    const leftPath = currentPath.parentPath.get('left');
                    if (leftPath.isIdentifier() || leftPath.isLiteral()) {
                        documentation.set('displayName', getNameOrValue(leftPath));
                        return;
                    }
                }
                currentPath = currentPath.parentPath;
            }
        }
        return;
    }
    displayNamePath = resolveToValue(displayNamePath);
    // If display name is defined as function somehow (getter, property with function)
    // we resolve the return value of the function
    if (displayNamePath.isFunction()) {
        displayNamePath = resolveFunctionDefinitionToReturnValue(displayNamePath);
    }
    if (!displayNamePath ||
        (!displayNamePath.isStringLiteral() && !displayNamePath.isNumericLiteral())) {
        return;
    }
    documentation.set('displayName', displayNamePath.node.value);
};
export default displayNameHandler;