Skip to content

fix: prevent object properties from showing as separate parameters (#810) #818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 2.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions src/scripts/builders/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,42 @@ const convertToMDX = async (

const getMethodFrontmatter = (doc: ReferenceClassItemMethod) => {
const { params, return: returns, example, overloads, itemtype } = doc;

// Process params to handle nested object properties
const processedParams = params?.map(param => {
// If this is a nested property (contains a dot), skip it
if (param.name.includes('.')) {
return null;
}

// If this is an object parameter, collect its nested properties
if (param.type === 'Object' && params) {
const nestedProps = params
.filter(p => p.name.startsWith(`${param.name}.`))
.map(p => {
const propName = p.name.split('.')[1];
return `• ${propName}: ${p.description}`;
});

if (nestedProps.length > 0) {
param.description = `${param.description || ''}\n\nProperties:\n${nestedProps.join('\n')}`;
}
}

return param;
}).filter(Boolean);

return {
params,
params: processedParams,
return: returns,
example,
overloads,
overloads: overloads?.map(overload => ({
...overload,
params: overload.params?.map(param => {
if (param.name.includes('.')) return null;
return param;
}).filter(Boolean)
})),
itemtype,
chainable: doc.chainable === 1,
beta: doc.beta ? !!doc.beta : undefined,
Expand Down