export function parameterNameAndType(this: ParameterReflection, displaySymbol = true) { const md = []; if (displaySymbol) { md.push('-'); } if (this.flags && !this.flags.isRest) { md.push(this.flags.map(flag => `\`${flag}\` `)); } md.push(`${this.flags.isRest ? '...' : ''} **${this.name}**`); if (this.type) { md.push(`: *${type.call(this.type)}*`); } if (this.defaultValue) { md.push(`= ${this.defaultValue}`); } return md.join(''); }
export function ifHasTypeDeclarations(this: SignatureReflection, truthy: boolean, options: any) { const parameterDeclarations = this.parameters && this.parameters.map(parameter => { const type = parameter.type as ReflectionType; return ( parameter.type && type.declaration && ((type.declaration.children && type.declaration.children.length > 0) || (type.declaration.signatures && type.declaration.signatures.length > 0)) ); }); const hasTypeDeclarations = parameterDeclarations && parameterDeclarations.some(parameterDeclaration => parameterDeclaration); if (hasTypeDeclarations && truthy) { return options.fn(this); } return !hasTypeDeclarations && !truthy ? options.fn(this) : options.inverse(this); }
export default function paramTypeToString(parameter: ParameterReflection) { let typeOut; if (parameter.type instanceof ReflectionType && parameter.type.toString() === 'function') { const declarations = parameter.type.declaration.signatures?.map((sig) => signatureTitle.call(sig, false, true)); typeOut = declarations.join(' | ').replace(/\n/, ''); } else if (parameter.type instanceof UnionType) { typeOut = parameter.type.types .map((currentType) => { if (currentType instanceof ReflectionType) { const declarations = currentType.declaration.signatures?.map((sig) => signatureTitle.call(sig, false, true)); return declarations.join(' | ').replace(/\n/, ''); } return type.call(currentType); }) .join(' | '); } else { typeOut = type.call(parameter.type); } return typeOut; }
export function parameterTable(this: ParameterReflection[], hideUncommented: boolean) { const md = []; const defaultValues = this.map((param) => !!param.defaultValue); const hasDefaultValues = !defaultValues.every((value) => !value); (param) => (param.comment && !!param.comment.text) || (param.comment && !!param.comment.shortText) ); const hasComments = !comments.every((value) => !value); const isOptional = parameter.flags.includes('Optional'); `${parameter.flags.isRest ? '...' : ''}${parameter.name}${isOptional ? '?' : ''}`, typeOut ? typeOut.toString().replace(/\|/g, '|') : '', ]; if (hasDefaultValues) { row.push(parameter.defaultValue ? parameter.defaultValue : '-'); if (parameter.comment && parameter.comment.shortText) { commentsText.push( MarkdownTheme.handlebars.helpers.comment.call(stripLineBreaks.call(parameter.comment.shortText)) ); if (parameter.comment && parameter.comment.text) { commentsText.push(MarkdownTheme.handlebars.helpers.comment.call(stripLineBreaks.call(parameter.comment.text)));