diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/apidoc/signature.ts | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/scripts/apidoc/signature.ts b/scripts/apidoc/signature.ts index 22eed268..f2a4bd85 100644 --- a/scripts/apidoc/signature.ts +++ b/scripts/apidoc/signature.ts @@ -233,27 +233,37 @@ function analyzeParameterOptions( return []; } - if (parameterType.type === 'union') { - return parameterType.types.flatMap((type) => - analyzeParameterOptions(name, type) - ); - } else if (parameterType.type === 'reflection') { - const properties = parameterType.declaration.children ?? []; - return properties.map((property) => ({ - name: `${name}.${property.name}${isOptional(property) ? '?' : ''}`, - type: declarationTypeToText(property), - default: extractDefaultFromComment(property.comment), - description: mdToHtml( - toBlock( - property.comment ?? - (property.type as ReflectionType)?.declaration?.signatures?.[0] - .comment - ) - ), - })); - } + switch (parameterType.type) { + case 'array': + return analyzeParameterOptions(`${name}[]`, parameterType.elementType); + + case 'union': + return parameterType.types.flatMap((type) => + analyzeParameterOptions(name, type) + ); + + case 'reflection': { + const properties = parameterType.declaration.children ?? []; + return properties.map((property) => ({ + name: `${name}.${property.name}${isOptional(property) ? '?' : ''}`, + type: declarationTypeToText(property), + default: extractDefaultFromComment(property.comment), + description: mdToHtml( + toBlock( + property.comment ?? + (property.type as ReflectionType)?.declaration?.signatures?.[0] + .comment + ) + ), + })); + } + + case 'typeOperator': + return analyzeParameterOptions(name, parameterType.target); - return []; + default: + return []; + } } function isOptional(parameter: Reflection): boolean { |
