docs: expand input and output object types in API signatures
This commit is contained in:
@@ -255,14 +255,35 @@ function renderSection(moduleName, entries) {
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
function formatParamType(param, allParams) {
|
||||
const cleanName = param.name.replace(/^\[|\]$/g, '').split('=')[0].trim();
|
||||
const prefix = cleanName + '.';
|
||||
const childParams = allParams.filter((p) => {
|
||||
const pClean = p.name.replace(/^\[|\]$/g, '').split('=')[0].trim();
|
||||
return pClean.startsWith(prefix) && !pClean.slice(prefix.length).includes('.');
|
||||
});
|
||||
|
||||
if (childParams.length > 0) {
|
||||
const props = childParams.map((cp) => {
|
||||
const isOpt = cp.name.startsWith('[');
|
||||
const propName = cp.name.replace(/^\[|\]$/g, '').split('=')[0].trim().slice(prefix.length);
|
||||
const propType = formatParamType(cp, allParams);
|
||||
return `${propName}${isOpt ? '?' : ''}: ${propType}`;
|
||||
});
|
||||
return `{${props.join(', ')}}`;
|
||||
}
|
||||
|
||||
return param.type || 'any';
|
||||
}
|
||||
|
||||
function formatMethodSignature(entry) {
|
||||
const topLevelParams = (entry.params || []).filter((p) => !p.name.includes('.'));
|
||||
const paramsStr = topLevelParams
|
||||
.map((p) => {
|
||||
const isOptional = p.name.startsWith('[');
|
||||
const cleanName = p.name.replace(/^\[|\]$/g, '').split('=')[0].trim();
|
||||
const typeStr = p.type ? `: ${p.type}` : '';
|
||||
return `${cleanName}${isOptional ? '?' : ''}${typeStr}`;
|
||||
const typeStr = formatParamType(p, entry.params || []);
|
||||
return `${cleanName}${isOptional ? '?' : ''}: ${typeStr}`;
|
||||
})
|
||||
.join(', ');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user