mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 02:43:48 +02:00
Fix API generator
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user