export interface Typed { readonly type ? : string ; readonly items ? : Typed ; readonly $ref : string ; } export function formatType ( p ) { const baseType = p . type || 'object' ; if ( baseType === 'array' ) { return ( p . items ? formatType ( p . items ) : 'object' ) + '[]' ; } return baseType ; } export function formatOne ( name , type , description ) { return `**${ name }** (${ type })\n\n${ description || '' }` ; } export function formatComplex ( name , description , typeDescription , children ) { let ph = '' ; for ( const p of Object . keys ( children ) . sort ( ) ) { ph = ph + `**${ p }** (${ formatType ( children [ p ] ) })\n\n${ children [ p ] . description }\n\n` ; } let typeDescriptionPara = '' ; if ( typeDescription ) { typeDescriptionPara = `\n\n${ typeDescription }` ; } return `${ name }: ${ description || '' }${ typeDescriptionPara }\n\n${ ph }` ; }