UNPKG

@sanity/tsdoc

Version:

Generate API reference docs from TypeScript projects and store in a Sanity-friendly JSON format. Render a static frontend, or as React components.

51 lines (45 loc) 1.18 kB
import {defineField, defineType} from 'sanity' import {APIPropertySignaturePreview} from '../components/APIPropertySignaturePreview' export const apiPropertySignatureType = defineType({ type: 'object', name: 'api.propertySignature', title: 'Property signature', components: { preview: APIPropertySignaturePreview, }, fields: [ defineField({ type: 'string', name: 'name', title: 'Name', }), defineField({ type: 'api.releaseTag', name: 'releaseTag', title: 'Release tag', }), defineField({ type: 'boolean', name: 'isOptional', title: 'Is optional', options: {layout: 'checkbox'}, }), defineField({ type: 'api.tokens', name: 'type', title: 'Type', }), defineField({ type: 'tsdoc.docComment', name: 'comment', title: 'Comment', }), ], preview: { select: {name: 'name', isOptional: 'isOptional', type: 'type'}, // prepare: ({isOptional, name, type}: any) => ({ // title: `${name}${isOptional ? '?' : ''}: ${type?.map((t) => t.text).join('')})}`, // subtitle: 'Property signature', // }), }, })