import { css } from '@emotion/react'; import { theme, spacing, UndoIcon, iconSize } from '@expo/styleguide'; import ReactMarkdown from 'react-markdown'; import { H2, H3Code, H4, H4Code } from '~/components/plugins/Headings'; import { APIDataType } from '~/components/plugins/api/APIDataType'; import { AccessorDefinitionData, MethodDefinitionData, MethodSignatureData, PropData, TypeSignaturesData, } from '~/components/plugins/api/APIDataTypes'; import { APISectionDeprecationNote } from '~/components/plugins/api/APISectionDeprecationNote'; import { APISectionPlatformTags } from '~/components/plugins/api/APISectionPlatformTags'; import { CommentTextBlock, getMethodName, getTagNamesList, mdComponents, renderParams, resolveTypeName, STYLES_APIBOX, STYLES_APIBOX_NESTED, STYLES_NESTED_SECTION_HEADER, STYLES_NOT_EXPOSED_HEADER, TypeDocKind, } from '~/components/plugins/api/APISectionUtils'; import { LI, UL, CODE } from '~/ui/components/Text'; export type APISectionMethodsProps = { data: (MethodDefinitionData | PropData)[]; apiName?: string; header?: string; exposeInSidebar?: boolean; }; export type RenderMethodOptions = { apiName?: string; header?: string; exposeInSidebar?: boolean; }; export const renderMethod = ( method: MethodDefinitionData | AccessorDefinitionData | PropData, { apiName, exposeInSidebar = true }: RenderMethodOptions = {} ): JSX.Element[] => { const signatures = (method as MethodDefinitionData).signatures || (method as PropData)?.type?.declaration?.signatures || (method as AccessorDefinitionData)?.getSignature || []; const HeaderComponent = exposeInSidebar ? H3Code : H4Code; return signatures.map( ({ name, parameters, comment, type }: MethodSignatureData | TypeSignaturesData) => (
{getMethodName(method as MethodDefinitionData, apiName, name, parameters)}