Compare commits

...

6 Commits

Author SHA1 Message Date
Alex Yang 0d54ce5cd5 fix: docs link 2025-04-21 14:54:26 -07:00
Alex Yang 4d7bf0385f fix: docs link 2025-04-21 14:38:57 -07:00
Alex Yang 008e86e403 fix: docs link 2025-04-21 14:32:05 -07:00
Alex Yang f0402e2e9d fix: docs link 2025-04-21 13:14:24 -07:00
Alex Yang f9896a809c chore: bump 2025-04-21 12:56:06 -07:00
Alex Yang 663d8f2272 make docs great again - 2nd time 2025-04-21 12:53:59 -07:00
5 changed files with 33 additions and 29 deletions
+4 -3
View File
@@ -4,10 +4,11 @@
"private": true,
"scripts": {
"postinstall": "fumadocs-mdx",
"prebuild": "pnpm run build:docs",
"build": "next build",
"dev": "next dev --turbo",
"start": "next start",
"postbuild": "tsx scripts/post-build.mts",
"postbuild": "tsx scripts/post-build.mts && tsx scripts/validate-links.mts",
"build:docs": "cross-env NODE_OPTIONS=\"--max-old-space-size=8192\" typedoc && tsx scripts/generate-docs.mts",
"validate-links": "tsx scripts/validate-links.mts"
},
@@ -89,9 +90,9 @@
"remark-stringify": "^11.0.0",
"tailwindcss": "^4.0.9",
"tsx": "^4.19.3",
"typedoc": "0.28.2",
"typedoc": "0.28.3",
"typedoc-plugin-markdown": "^4.6.2",
"typedoc-plugin-merge-modules": "^7.0.0",
"typedoc-plugin-merge-modules": " ^7.0.0",
"typescript": "^5.7.3"
}
}
+12 -9
View File
@@ -13,12 +13,12 @@ const apiRefOut = "./src/content/docs/api";
// clean generated files
rimrafSync(out, {
filter(v) {
return !v.endsWith("index.mdx") && !v.endsWith("meta.json");
return !v.endsWith("index.md") && !v.endsWith("meta.json");
},
});
void typescriptGenerateFiles(generator, {
input: ["./src/content/docs/api/**/*.mdx"],
input: ["./src/content/docs/api/**/*.md"],
output: (file) => path.resolve(path.dirname(file), path.basename(file)),
transformOutput,
});
@@ -27,19 +27,22 @@ function transformOutput(filePath: string, content: string) {
const fileName = path.basename(filePath);
let title = fileName.split(".")[0];
if (title === "index") title = "LlamaIndex API Reference";
return `---\ntitle: ${title}\n---\n\n${transformAbsoluteUrl(content, filePath)}`;
return `---\ntitle: ${title}\n---\n\n${transformAbsoluteUrl(
content.replace(/(?<!\\)\{([^}]+)(?<!\\)}/g, "\\{$1\\}"),
filePath,
)}`;
}
/**
* Transforms the content by converting relative MDX links to absolute docs API links
* Example: [text](../type-aliases/TaskHandler.mdx) -> [text](/docs/api/type-aliases/TaskHandler)
* [text](BaseChatEngine.mdx) -> [text](/docs/api/classes/BaseChatEngine)
* [text](BaseVectorStore.mdx#constructors) -> [text](/docs/api/classes/BaseVectorStore#constructors)
* [text](TaskStep.mdx) -> [text](/docs/api/type-aliases/TaskStep)
* Transforms the content by converting relative MD links to absolute docs API links
* Example: [text](../type-aliases/TaskHandler.md) -> [text](/docs/api/type-aliases/TaskHandler)
* [text](BaseChatEngine.md) -> [text](/docs/api/classes/BaseChatEngine)
* [text](BaseVectorStore.md#constructors) -> [text](/docs/api/classes/BaseVectorStore#constructors)
* [text](TaskStep.md) -> [text](/docs/api/type-aliases/TaskStep)
*/
function transformAbsoluteUrl(content: string, filePath: string) {
const group = path.dirname(filePath).split(path.sep).pop();
return content.replace(/\]\(([^)]+)\.mdx([^)]*)\)/g, (_, slug, anchor) => {
return content.replace(/\]\(([^)]+)\.md([^)]*)\)/g, (_, slug, anchor) => {
const slugParts = slug.split("/");
const fileName = slugParts[slugParts.length - 1];
const fileGroup = slugParts[slugParts.length - 2] ?? group;
+4 -4
View File
@@ -28,14 +28,14 @@ interface RelativeLinkResult {
* Get all valid documentation routes from the content directory
*/
async function getValidRoutes(): Promise<Set<string>> {
const mdxFiles = await glob("**/*.mdx", { cwd: CONTENT_DIR });
const mdxFiles = await glob("**/*.mdx?", { cwd: CONTENT_DIR });
const routes = new Set<string>();
// Add each MDX file as a valid route
for (const file of mdxFiles) {
// Remove .mdx extension and normalize to route format
let route = file.replace(/\.mdx$/, "");
let route = file.replace(/\.mdx?$/, "");
// Handle index files
if (route.endsWith("/index")) {
@@ -131,7 +131,7 @@ function findRelativeLinksInFile(
* Find relative links in all MDX files
*/
async function findRelativeLinks(): Promise<RelativeLinkResult[]> {
const mdxFiles = await glob("**/*.mdx", { cwd: CONTENT_DIR });
const mdxFiles = await glob("**/*.mdx?", { cwd: CONTENT_DIR });
const results: RelativeLinkResult[] = [];
for (const file of mdxFiles) {
@@ -150,7 +150,7 @@ async function findRelativeLinks(): Promise<RelativeLinkResult[]> {
}
async function validateLinks(): Promise<LinkValidationResult[]> {
const mdxFiles = await glob("**/*.mdx", { cwd: CONTENT_DIR });
const mdxFiles = await glob("**/*.mdx?", { cwd: CONTENT_DIR });
const validRoutes = await getValidRoutes();
const results: LinkValidationResult[] = [];
+1 -1
View File
@@ -20,7 +20,7 @@
"categoryOrder": ["Classes", "Enums", "Functions", "Interfaces", "Types"],
"sort": ["source-order"],
"entryFileName": "index.md",
"fileExtension": ".mdx",
"fileExtension": ".md",
"hidePageTitle": true,
"hidePageHeader": true,
"hideGroupHeadings": true,
+12 -12
View File
@@ -298,14 +298,14 @@ importers:
specifier: ^4.19.3
version: 4.19.3
typedoc:
specifier: 0.28.2
version: 0.28.2(typescript@5.7.3)
specifier: 0.28.3
version: 0.28.3(typescript@5.7.3)
typedoc-plugin-markdown:
specifier: ^4.6.2
version: 4.6.2(typedoc@0.28.2(typescript@5.7.3))
version: 4.6.2(typedoc@0.28.3(typescript@5.7.3))
typedoc-plugin-merge-modules:
specifier: ^7.0.0
version: 7.0.0(typedoc@0.28.2(typescript@5.7.3))
specifier: ' ^7.0.0'
version: 7.0.0(typedoc@0.28.3(typescript@5.7.3))
typescript:
specifier: ^5.7.3
version: 5.7.3
@@ -12666,8 +12666,8 @@ packages:
peerDependencies:
typescript: 4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x
typedoc@0.28.2:
resolution: {integrity: sha512-9Giuv+eppFKnJ0oi+vxqLM817b/IrIsEMYgy3jj6zdvppAfDqV3d6DXL2vXUg2TnlL62V48th25Zf/tcQKAJdg==}
typedoc@0.28.3:
resolution: {integrity: sha512-5svOCTfXvVSh6zbZKSQluZhR8yN2tKpTeHZxlmWpE6N5vc3R8k/jhg9nnD6n5tN9/ObuQTojkONrOxFdUFUG9w==}
engines: {node: '>= 18', pnpm: '>= 10'}
hasBin: true
peerDependencies:
@@ -27168,13 +27168,13 @@ snapshots:
optionalDependencies:
rxjs: 7.8.1
typedoc-plugin-markdown@4.6.2(typedoc@0.28.2(typescript@5.7.3)):
typedoc-plugin-markdown@4.6.2(typedoc@0.28.3(typescript@5.7.3)):
dependencies:
typedoc: 0.28.2(typescript@5.7.3)
typedoc: 0.28.3(typescript@5.7.3)
typedoc-plugin-merge-modules@7.0.0(typedoc@0.28.2(typescript@5.7.3)):
typedoc-plugin-merge-modules@7.0.0(typedoc@0.28.3(typescript@5.7.3)):
dependencies:
typedoc: 0.28.2(typescript@5.7.3)
typedoc: 0.28.3(typescript@5.7.3)
typedoc@0.26.11(typescript@5.7.3):
dependencies:
@@ -27185,7 +27185,7 @@ snapshots:
typescript: 5.7.3
yaml: 2.7.1
typedoc@0.28.2(typescript@5.7.3):
typedoc@0.28.3(typescript@5.7.3):
dependencies:
'@gerrit0/mini-shiki': 3.2.3
lunr: 2.3.9