diff --git a/packages/api-docs-builder/ApiBuilders/HookApiBuilder.ts b/packages/api-docs-builder/ApiBuilders/HookApiBuilder.ts index f02e5e6d9de344..2f48f39bc9d73f 100644 --- a/packages/api-docs-builder/ApiBuilders/HookApiBuilder.ts +++ b/packages/api-docs-builder/ApiBuilders/HookApiBuilder.ts @@ -482,7 +482,7 @@ const extractInfoFromType = async ( * @param filename The filename where its defined (to infer the package) * @returns an array of import command */ -const getHookImports = (name: string, filename: string) => { +const defaultGetHookImports = (name: string, filename: string) => { const githubPath = toGitHubPath(filename); const rootImportPath = githubPath.replace( /\/packages\/mui(?:-(.+?))?\/src\/.*/, @@ -552,6 +552,8 @@ export default async function generateHookApi( if (annotatedDescriptionMatch !== null) { reactApi.description = reactApi.description.slice(0, annotatedDescriptionMatch.index).trim(); } + + const { getHookImports = defaultGetHookImports } = projectSettings; reactApi.filename = filename; reactApi.name = name; reactApi.imports = getHookImports(name, filename); diff --git a/packages/api-docs-builder/ProjectSettings.ts b/packages/api-docs-builder/ProjectSettings.ts index 2ba937f0a4e9b2..3ae895666b561e 100644 --- a/packages/api-docs-builder/ProjectSettings.ts +++ b/packages/api-docs-builder/ProjectSettings.ts @@ -74,9 +74,13 @@ export interface ProjectSettings { */ importTranslationPagesDirectory?: string; /** - * Returns an array of import commands used for the API page header. + * Returns an array of import commands used for the component API page header. */ getComponentImports?: (name: string, filename: string) => string[]; + /** + * Returns an array of import commands used for the hook API page header. + */ + getHookImports?: (name: string, filename: string) => string[]; /** * Settings to configure props definition tests. */