-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
15 changed files
with
888 additions
and
384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* @import "tailwindcss"; */ | ||
@import "tailwindcss"; | ||
|
||
/* @theme { | ||
--color-primaryColor: rgb(99, 102, 241); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { generateDocs } from "./metaphase_aot"; | ||
|
||
// Only run if this file is being executed directly | ||
if (import.meta.main) { | ||
await generateDocs({ | ||
crateDataPath: | ||
"../../../bazel-bin/nativelink-config/docs_json.rustdoc/nativelink_config.json", | ||
outputPath: "../content/docs/reference/nativelink-config.mdx", | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { type ConvertFile, convertMarkdownToMdx } from "./md-to-mdx"; | ||
|
||
const rootDir = "../"; | ||
const docsDir = "src/content/docs"; | ||
const assetsDir = "@assets"; | ||
|
||
const filesToConvert: ConvertFile[] = [ | ||
{ | ||
input: `${rootDir}/local-remote-execution/README.md`, | ||
output: `${docsDir}/explanations/lre.mdx`, | ||
docs: { | ||
title: "Local Remote Execution", | ||
description: "Local Remote Execution architecture", | ||
}, | ||
}, | ||
{ | ||
input: `${rootDir}/CONTRIBUTING.md`, | ||
output: `${docsDir}/contribute/guidelines.mdx`, | ||
|
||
docs: { | ||
title: "NativeLink contribution guidelines", | ||
description: "Contribution Guidelines", | ||
}, | ||
}, | ||
{ | ||
input: "README.md", | ||
output: `${docsDir}/contribute/docs.mdx`, | ||
docs: { | ||
title: "The NativeLink documentation", | ||
description: "Working on documentation", | ||
}, | ||
}, | ||
{ | ||
input: `${rootDir}/nativelink-config/README.md`, | ||
output: `${docsDir}/config/configuration-intro.mdx`, | ||
docs: { | ||
title: "NativeLink configuration guide", | ||
description: "NativeLink configuration guide", | ||
}, | ||
}, | ||
{ | ||
input: `${rootDir}/deployment-examples/chromium/README.md`, | ||
output: `${docsDir}/deployment-examples/chromium.mdx`, | ||
docs: { | ||
title: "NativeLink deployment example for Chromium", | ||
description: "NativeLink deployment example for Chromium", | ||
}, | ||
}, | ||
{ | ||
input: `${rootDir}/deployment-examples/kubernetes/README.md`, | ||
output: `${docsDir}/deployment-examples/kubernetes.mdx`, | ||
docs: { | ||
title: "Local Remote Execution architecture", | ||
description: "Local Remote Execution architecture", | ||
}, | ||
}, | ||
{ | ||
input: `${rootDir}/CHANGELOG.md`, | ||
output: `${docsDir}/reference/changelog.mdx`, | ||
docs: { | ||
title: "Changelog", | ||
description: "NativeLink's Changelog", | ||
pagefind: false, // Set pagefind to false for changelog | ||
}, | ||
}, | ||
{ | ||
input: `${rootDir}/README.md`, | ||
output: `${docsDir}/introduction/setup.mdx`, | ||
docs: { | ||
title: "Introduction", | ||
description: "Get started with NativeLink", | ||
pagefind: true, | ||
assets: [`${assetsDir}/logo-dark.svg`, `${assetsDir}/logo-light.svg`], | ||
}, | ||
}, | ||
]; | ||
|
||
filesToConvert.map((file) => { | ||
convertMarkdownToMdx(file); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import type { Literal, Node, Parent, Root, RootContent } from "mdast"; | ||
|
||
// Define a type for nodes that contain a `value` property | ||
interface HtmlNode extends Literal { | ||
type: "html"; | ||
value: string; | ||
} | ||
|
||
// This function logs all nodes of a given type in the AST. | ||
export function logSpecificNodes(tree: Root, nodeType: string): void { | ||
tree.children.forEach((node, _index) => { | ||
if (node.type === nodeType) { | ||
console.info(node); | ||
} | ||
}); | ||
} | ||
|
||
// This function searches for HTML nodes with a specific ID and logs them. | ||
export function findNodesById(tree: RootContent[], targetId: string): void { | ||
const idRegex = new RegExp(`id=["']${targetId}["']`, "i"); | ||
// console.log(tree.children[1]); | ||
tree.forEach((node, _index) => { | ||
if (node.type === "html" && idRegex.test((node as HtmlNode).value)) { | ||
console.info(node); | ||
} | ||
}); | ||
} | ||
|
||
// Exporting the AST to a file | ||
// This function writes the entire AST or a portion of it to a file for easier inspection. | ||
export function exportAstToFile(tree: Root, filename: string): void { | ||
Bun.write(filename, JSON.stringify(tree, null, 2)); | ||
} | ||
|
||
// Recursively logging the AST up to a certain depth | ||
// This function logs the AST up to a specified depth, which is useful for large structures. | ||
export function logAstAtDepth( | ||
node: Node, | ||
depth: number, | ||
maxDepth: number, | ||
): void { | ||
if (depth > maxDepth) { | ||
return; | ||
} | ||
|
||
if ("children" in node && Array.isArray((node as Parent).children)) { | ||
for (const child of (node as Parent).children) { | ||
logAstAtDepth(child, depth + 1, maxDepth); | ||
console.info(node); | ||
} | ||
} | ||
} | ||
|
||
// Example usage (uncomment the relevant lines to use): | ||
|
||
// logSpecificNodes(tree, "paragraph"); | ||
// findNodesById(tree, "description"); | ||
// exportAstToFile(tree, 'ast-output.json'); | ||
// logAstAtDepth(tree, 0, 2); |
Oops, something went wrong.