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/componentDocblockHandler.js
import { getDocblock } from '../utils/docblock.js';
import isReactForwardRefCall from '../utils/isReactForwardRefCall.js';
import resolveToValue from '../utils/resolveToValue.js';
function getDocblockFromComponent(path) {
    let description = null;
    if (path.isClassDeclaration() || path.isClassExpression()) {
        const decorators = path.get('decorators');
        // If we have a class declaration or expression, then the comment might be
        // attached to the last decorator instead as trailing comment.
        if (decorators && decorators.length > 0) {
            description = getDocblock(decorators[decorators.length - 1], true);
        }
    }
    if (description == null) {
        // Find parent statement (e.g. var Component = React.createClass(<path>);)
        let searchPath = path;
        while (searchPath && !searchPath.isStatement()) {
            searchPath = searchPath.parentPath;
        }
        if (searchPath) {
            // If the parent is an export statement, we have to traverse one more up
            if (searchPath.parentPath.isExportNamedDeclaration() ||
                searchPath.parentPath.isExportDefaultDeclaration()) {
                searchPath = searchPath.parentPath;
            }
            description = getDocblock(searchPath);
        }
    }
    if (!description) {
        const searchPath = isReactForwardRefCall(path)
            ? path.get('arguments')[0]
            : path;
        const inner = resolveToValue(searchPath);
        if (inner.node !== path.node) {
            return getDocblockFromComponent(inner);
        }
    }
    return description;
}
/**
 * Finds the nearest block comment before the component definition.
 */
const componentDocblockHandler = function (documentation, componentDefinition) {
    documentation.set('description', getDocblockFromComponent(componentDefinition) || '');
};
export default componentDocblockHandler;