Fix API generator

This commit is contained in:
Vanilagy
2025-09-04 09:38:56 +02:00
parent f8d236888a
commit 03a9073c40
+23 -3
View File
@@ -785,10 +785,22 @@ const generateDocs = (entryFiles: string[], apiConfigFile: string) => {
const constructorBlocks: string[] = [];
const allReferencedTypes: string[] = [];
// First, process constructor parameters with visibility modifiers as properties from any constructor
// that has them (typically the implementation or the main signature)
let processedProperties = false;
constructorOverloads.forEach((ctor) => {
// Skip the implementation (the one with a body) unless it's the only constructor
if (ctor.body && constructorOverloads.length > 1) {
// Process constructor parameters with visibility modifiers as properties (only from implementation)
// Process constructor parameters with visibility modifiers as properties (only once)
if (!processedProperties) {
const hasVisibilityParams = ctor.parameters.some(param =>
param.modifiers?.some(mod =>
mod.kind === ts.SyntaxKind.PublicKeyword
|| mod.kind === ts.SyntaxKind.PrivateKeyword
|| mod.kind === ts.SyntaxKind.ProtectedKeyword
|| mod.kind === ts.SyntaxKind.ReadonlyKeyword,
),
);
if (hasVisibilityParams) {
ctor.parameters.forEach((param) => {
// Check if parameter has visibility modifier (public, private, protected, readonly)
const hasVisibilityModifier = param.modifiers?.some(mod =>
@@ -826,6 +838,14 @@ const generateDocs = (entryFiles: string[], apiConfigFile: string) => {
const propertyContent = `### \`${paramName}\`\n\n\`\`\`ts\n${propertyDef}\n\`\`\`${desc ? `\n\n${desc}` : ''}${referencesText}`;
properties.push(propertyContent);
});
processedProperties = true;
}
}
});
constructorOverloads.forEach((ctor) => {
// Skip the implementation (the one with a body) unless it's the only constructor
if (ctor.body && constructorOverloads.length > 1) {
return;
}