diff --git a/docs/scripts/buildApi.ts b/docs/scripts/buildApi.ts
index 223a644258f7b9..340c966e43dac9 100644
--- a/docs/scripts/buildApi.ts
+++ b/docs/scripts/buildApi.ts
@@ -23,6 +23,11 @@ import muiDefaultPropsHandler from 'docs/src/modules/utils/defaultPropsHandler';
import muiFindAnnotatedComponentsResolver from 'docs/src/modules/utils/findAnnotatedComponentsResolver';
import { LANGUAGES, LANGUAGES_IN_PROGRESS } from 'docs/src/modules/constants';
import parseTest from 'docs/src/modules/utils/parseTest';
+import generatePropTypeDescription, {
+ escapeCell,
+ isElementTypeAcceptingRefProp,
+ isElementAcceptingRefProp,
+} from 'docs/src/modules/utils/generatePropTypeDescription';
import { findPages, findPagesMarkdown, findComponents } from 'docs/src/modules/utils/find';
import {
getHeaders,
@@ -109,100 +114,6 @@ function getChained(type: PropTypeDescriptor): false | PropDescriptor {
return false;
}
-function escapeCell(value: string): string {
- // As the pipe is use for the table structure
- return value.replace(/ {
- const subType = type.value[subValue];
- return `${subValue}${subType.required ? '' : '?'}: ${generatePropTypeDescription(
- subType,
- )}`;
- })
- .join(', ')} }`;
-
- case 'union':
- return (
- type.value
- .map((type2) => {
- return generatePropTypeDescription(type2);
- })
- // Display one value per line as it's better for visibility.
- .join('
| ')
- );
- case 'enum':
- return (
- type.value
- .map((type2) => {
- return escapeCell(type2.value);
- })
- // Display one value per line as it's better for visibility.
- .join('
| ')
- );
-
- case 'arrayOf': {
- return `Array<${generatePropTypeDescription(type.value)}>`;
- }
-
- case 'instanceOf': {
- if (type.value.startsWith('typeof')) {
- return /typeof (.*) ===/.exec(type.value)![1];
- }
- return type.value;
- }
-
- default:
- return type.name;
- }
-}
-
/**
* Returns `null` if the prop should be ignored.
* Throws if it is invalid.
diff --git a/docs/src/modules/utils/generatePropTypeDescription.ts b/docs/src/modules/utils/generatePropTypeDescription.ts
index 28297de96f5588..2a60c985ab927c 100644
--- a/docs/src/modules/utils/generatePropTypeDescription.ts
+++ b/docs/src/modules/utils/generatePropTypeDescription.ts
@@ -47,12 +47,12 @@ function getChained(type: PropTypeDescriptor) {
return false;
}
-function escapeCell(value: string): string {
+export function escapeCell(value: string): string {
// As the pipe is use for the table structure
return value.replace(/