Skip to content

Commit c04eba7

Browse files
committed
[code-infra] Allow customizing hooks imports in API docs generator
1 parent 300a60e commit c04eba7

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/api-docs-builder/ApiBuilders/HookApiBuilder.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ const extractInfoFromType = async (
482482
* @param filename The filename where its defined (to infer the package)
483483
* @returns an array of import command
484484
*/
485-
const getHookImports = (name: string, filename: string) => {
485+
const defaultGetHookImports = (name: string, filename: string) => {
486486
const githubPath = toGitHubPath(filename);
487487
const rootImportPath = githubPath.replace(
488488
/\/packages\/mui(?:-(.+?))?\/src\/.*/,
@@ -552,6 +552,8 @@ export default async function generateHookApi(
552552
if (annotatedDescriptionMatch !== null) {
553553
reactApi.description = reactApi.description.slice(0, annotatedDescriptionMatch.index).trim();
554554
}
555+
556+
const { getHookImports = defaultGetHookImports } = projectSettings;
555557
reactApi.filename = filename;
556558
reactApi.name = name;
557559
reactApi.imports = getHookImports(name, filename);

packages/api-docs-builder/ProjectSettings.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,13 @@ export interface ProjectSettings {
7474
*/
7575
importTranslationPagesDirectory?: string;
7676
/**
77-
* Returns an array of import commands used for the API page header.
77+
* Returns an array of import commands used for the component API page header.
7878
*/
7979
getComponentImports?: (name: string, filename: string) => string[];
80+
/**
81+
* Returns an array of import commands used for the hook API page header.
82+
*/
83+
getHookImports?: (name: string, filename: string) => string[];
8084
/**
8185
* Settings to configure props definition tests.
8286
*/

0 commit comments

Comments
 (0)