Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix: use type cleanup instead of <code> tags for MDX table compatibility

Sushmitha Malleshbe8cdf6592ab
diff --git a/docs/content/reference/sdk-reference/typescript/remote-file.mdx b/docs/content/reference/sdk-reference/typescript/remote-file.mdx
index 11b12acad..7bff04403 100644
--- a/docs/content/reference/sdk-reference/typescript/remote-file.mdx
+++ b/docs/content/reference/sdk-reference/typescript/remote-file.mdx
@@ -47,7 +47,7 @@ async buffer(): Promise<Uint8Array<ArrayBufferLike>>
**Returns**
-<code>Promise&lt;Uint8Array&lt;ArrayBufferLike&gt;&gt;</code> — The file content as a Uint8Array
+`Promise<Uint8Array>` — The file content as a Uint8Array
---
diff --git a/docs/content/reference/sdk-reference/typescript/tool-router-session-files-mount.mdx b/docs/content/reference/sdk-reference/typescript/tool-router-session-files-mount.mdx
index 6906b56ac..f9bad6b19 100644
--- a/docs/content/reference/sdk-reference/typescript/tool-router-session-files-mount.mdx
+++ b/docs/content/reference/sdk-reference/typescript/tool-router-session-files-mount.mdx
@@ -144,7 +144,7 @@ async upload(input: string | File | ArrayBuffer | Uint8Array<ArrayBufferLike>, o
| Name | Type | Description |
|------|------|-------------|
-| `input` | <code>string | File | ArrayBuffer | Uint8Array&lt;ArrayBufferLike&gt;</code> | File path (string), native File, or raw buffer (ArrayBuffer | Uint8Array). |
+| `input` | `string \| File \| ArrayBuffer \| Uint8Array` | File path (string), native File, or raw buffer (ArrayBuffer \| Uint8Array). |
| `options?` | `object` | Optional configuration. When passing a buffer, remotePath is required. |
**Returns**
diff --git a/ts/packages/core/scripts/generate-docs.ts b/ts/packages/core/scripts/generate-docs.ts
index 45c34e9cb..46f50aa97 100644
--- a/ts/packages/core/scripts/generate-docs.ts
+++ b/ts/packages/core/scripts/generate-docs.ts
@@ -454,8 +454,8 @@ function generateMethodMdx(method: MethodDoc): string {
for (const param of sig.parameters) {
const opt = param.required ? '' : '?';
const desc = escapeTextForMdx(param.description || '');
- const typeCell = safeInlineType(simplifyTypeForTable(param.type));
- lines.push(`| \`${param.name}${opt}\` | ${typeCell} | ${desc} |`);
+ const typeCell = escapeTypeForMdx(simplifyTypeForTable(param.type));
+ lines.push(`| \`${param.name}${opt}\` | \`${typeCell}\` | ${desc} |`);
}
} else {
// No descriptions - use simpler table
@@ -463,8 +463,8 @@ function generateMethodMdx(method: MethodDoc): string {
lines.push('|------|------|');
for (const param of sig.parameters) {
const opt = param.required ? '' : '?';
- const typeCell = safeInlineType(simplifyTypeForTable(param.type));
- lines.push(`| \`${param.name}${opt}\` | ${typeCell} |`);
+ const typeCell = escapeTypeForMdx(simplifyTypeForTable(param.type));
+ lines.push(`| \`${param.name}${opt}\` | \`${typeCell}\` |`);
}
}
lines.push('');
@@ -474,8 +474,8 @@ function generateMethodMdx(method: MethodDoc): string {
if (sig.returnType !== 'void') {
lines.push('**Returns**');
lines.push('');
- const returnTypeDisplay = safeInlineType(simplifyTypeForTable(sig.returnType));
- let returnLine = returnTypeDisplay;
+ const returnTypeDisplay = escapeTypeForMdx(simplifyTypeForTable(sig.returnType));
+ let returnLine = `\`${returnTypeDisplay}\``;
if (sig.returnDescription) {
returnLine += ` — ${escapeTextForMdx(sig.returnDescription)}`;
}
@@ -568,16 +568,16 @@ function generateClassMdx(classDoc: ClassDoc): string {
lines.push('| Name | Type | Description |');
lines.push('|------|------|-------------|');
for (const prop of publicProps) {
- const typeCell = safeInlineType(simplifyTypeForTable(prop.type));
+ const typeCell = escapeTypeForMdx(simplifyTypeForTable(prop.type));
const safeDesc = escapeTextForMdx(prop.description || '');
- lines.push(`| \`${prop.name}\` | ${typeCell} | ${safeDesc} |`);
+ lines.push(`| \`${prop.name}\` | \`${typeCell}\` | ${safeDesc} |`);
}
} else {
lines.push('| Name | Type |');
lines.push('|------|------|');
for (const prop of publicProps) {
- const typeCell = safeInlineType(simplifyTypeForTable(prop.type));
- lines.push(`| \`${prop.name}\` | ${typeCell} |`);
+ const typeCell = escapeTypeForMdx(simplifyTypeForTable(prop.type));
+ lines.push(`| \`${prop.name}\` | \`${typeCell}\` |`);
}
}
lines.push('');
@@ -612,25 +612,12 @@ function escapeTextForMdx(str: string): string {
.replace(/>/g, '&gt;');
}
-// Render a type string as an inline code element safe for MDX tables.
-// Uses <code> HTML tag with &lt;/&gt; escaping instead of backticks,
-// because MDX parsers can interpret <TypeName> as JSX even inside
-// backtick code spans within table cells.
-function safeInlineType(type: string): string {
- const escaped = type
- .replace(/&/g, '&amp;')
- .replace(/</g, '&lt;')
- .replace(/>/g, '&gt;')
- .replace(/\{/g, '\\{')
- .replace(/\}/g, '\\}');
- return `<code>${escaped}</code>`;
-}
-
// Clean up internal generic type parameters that don't add value for users
function cleanupGenericTypes(type: string): string {
// Remove generic parameters that are just implementation details
// e.g., "Tools<unknown, unknown, TProvider>" -> "Tools"
// e.g., "Composio<TProvider>" -> "Composio"
+ // e.g., "Uint8Array<ArrayBufferLike>" -> "Uint8Array"
let cleaned = type;
// Remove type parameters that are just unknowns or TProvider
@@ -638,12 +625,22 @@ function cleanupGenericTypes(type: string): string {
cleaned = cleaned.replace(/<TProvider>/g, '');
cleaned = cleaned.replace(/<unknown>/g, '');
+ // Remove TypeScript internal generic parameters (e.g., <ArrayBufferLike>)
+ // that add no value for users and break MDX parsing
+ cleaned = cleaned.replace(/<ArrayBufferLike>/g, '');
+
// Clean up double spaces and trailing commas
cleaned = cleaned.replace(/\s+/g, ' ').trim();
return cleaned;
}
+// Escape type strings for safe use in MDX backtick code spans.
+// Escapes curly braces which MDX interprets as JSX expressions.
+function escapeTypeForMdx(type: string): string {
+ return type.replace(/\{/g, '\\{').replace(/\}/g, '\\}');
+}
+
// Simplify complex types for table display (aggressive)
function simplifyTypeForTable(type: string): string {
// First clean up internal generics