Basic
This describes the return value of react-docgen either from the parse() method
or from the CLI output.
For the current TypeScript types you can look at github
Documentation
interface Documentation {
childContext?: Record<string, PropDescriptor>;
composes?: string[];
context?: Record<string, PropDescriptor>;
description?: string;
displayName?: string;
methods?: MethodDescriptor[];
props?: Record<string, PropDescriptor>;
}childContext
Type: Record<string, PropDescriptor> | undefined
If the childContextTypeHandler is
active this property will contain legacy React child context descriptors.
composes
Type: string[] | undefined
If the props of the React component are composed of props which react-docgen was unable to resolve, the name of types will be listed here.
{
"composes": ["./sharedProps"]
}context
Type: Record<string, PropDescriptor> | undefined
If the contextTypeHandler is active this
property will contain legacy React context descriptors.
description
Type: string | undefined
If the componentDocblockHandler is
active this property will be set to the description of the React component.
displayName
Type: string | undefined
If the displayNameHandler is active this
property will be set to the name of the React component.
methods
Type: MethodDescriptor[] | undefined
If the componentMethodsHandler or
componentMethodsJsDocHandler is active this property will contain documented
component methods.
props
Type: Record<string, PropDescriptor> | undefined
Contains prop descriptors collected by handlers such as
propTypeHandler,
codeTypeHandler,
propDocblockHandler, and
defaultPropsHandler.
PropDescriptor
interface PropDescriptor {
type?: PropTypeDescriptor;
flowType?: TypeDescriptor<FunctionSignatureType>;
tsType?: TypeDescriptor<TSFunctionSignatureType>;
required?: boolean;
defaultValue?: DefaultValueDescriptor;
description?: string;
}type
Type: PropTypeDescriptor | undefined
Set by PropTypes-based handlers. See the PropTypes documentation for details.
flowType
Type: TypeDescriptor<FunctionSignatureType> | undefined
Set by codeTypeHandler when Flow props are
found.
tsType
Type: TypeDescriptor<TSFunctionSignatureType> | undefined
Set by codeTypeHandler when TypeScript props
are found.
required
Type: boolean | undefined
Indicates whether the prop is required according to the handler that found it.
defaultValue
Type: DefaultValueDescriptor | undefined
Set by defaultPropsHandler when a default
value is found.
description
Type: string | undefined
Set by docblock handlers or by comments in Flow and TypeScript prop definitions.