Skip to content

Commit

Permalink
Update docs generation
Browse files Browse the repository at this point in the history
Also add a polished README.md
  • Loading branch information
SchahinRohani committed Sep 3, 2024
1 parent e6a428e commit 0710d73
Show file tree
Hide file tree
Showing 15 changed files with 888 additions and 384 deletions.
43 changes: 28 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
#
<p align="center">
<div id="logo" align="center">
<a href="https://www.nativelink.com">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/tracemachina/nativelink/main/docs/src/assets/logo-dark.svg"/>
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/tracemachina/nativelink/main/docs/src/assets/logo-light.svg"/>
<img alt="NativeLink" src="https://raw.githubusercontent.com/tracemachina/nativelink/main/docs/src/assets/logo-light.svg"/>
<source media="(prefers-color-scheme: dark)" srcset="docs/src/assets/logo-dark.svg" />
<source media="(prefers-color-scheme: light)" srcset="docs/src/assets/logo-light.svg" />
<img alt="NativeLink" src="docs/src/assets/logo-light.svg" width="376" height="100" />
</picture>
</a>
</p>

[![Homepage](https://img.shields.io/badge/Homepage-8A2BE2)](https://nativelink.com)
[![GitHub stars](https://img.shields.io/github/stars/tracemachina/nativelink?style=social)](https://github.com/TraceMachina/nativelink)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/TraceMachina/nativelink/badge)](https://securityscorecards.dev/viewer/?uri=github.com/TraceMachina/nativelink)
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8050/badge)](https://www.bestpractices.dev/projects/8050)
[![Slack](https://img.shields.io/badge/slack--channel-blue?logo=slack)](https://nativelink.slack.com/join/shared_invite/zt-281qk1ho0-krT7HfTUIYfQMdwflRuq7A#/shared-invite/email)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
<br />
</div>

<div id="description" align="center">
enter the shipstorm
</div>

<br />


<div id="badges" align="center">

[![Homepage](https://img.shields.io/badge/Homepage-8A2BE2)](https://nativelink.com)
[![GitHub stars](https://img.shields.io/github/stars/tracemachina/nativelink?style=social)](https://github.com/TraceMachina/nativelink)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/TraceMachina/nativelink/badge)](https://securityscorecards.dev/viewer/?uri=github.com/TraceMachina/nativelink)
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8050/badge)](https://www.bestpractices.dev/projects/8050)
[![Slack](https://img.shields.io/badge/slack--channel-blue?logo=slack)](https://nativelink.slack.com/join/shared_invite/zt-281qk1ho0-krT7HfTUIYfQMdwflRuq7A#/shared-invite/email)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
</div>

## What's NativeLink?

NativeLink is an efficient, high-performance build cache and remote execution system that accelerates software compilation and testing while reducing infrastructure costs. It optimizes build processes for projects of all sizes by intelligently caching build artifacts and distributing tasks across multiple machines.

NativeLink is trusted in production environments to reduce costs and developer iteration times--handling over **one billion requests** per month for its customers, including large corporations such as **Samsung**.

<a href="https://www.youtube.com/watch?v=WLpqFuyLMUQ">
<img src="https://trace-github-resources.s3.us-east-2.amazonaws.com/harper-90-thumbnail.webp" alt="NativeLink Explained in 90 seconds" loading="lazy" width="480" height="360" />
</a>
<p align="center">
<a href="https://www.youtube.com/watch?v=WLpqFuyLMUQ">
<img src="https://trace-github-resources.s3.us-east-2.amazonaws.com/harper-90-thumbnail.webp" alt="NativeLink Explained in 90 seconds" loading="lazy" width="480" />
</a>
</p>

## 🔑 Key Features

Expand Down
7 changes: 5 additions & 2 deletions docs/biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
"rules": {
"all": true,
"style": {
"useNamingConvention": "off",
"noDefaultExport": "off"
"useBlockStatements": "error",
"useShorthandArrayType": "error",
"noShoutyConstants": "warn",
"noDefaultExport": "off",
"useNamingConvention": "off"
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"astro": "astro",
"biome": "biome",
"docs": "bun run docs.build && bun run docs.generate",
"docs.build": "cd .. && unset TMPDIR TMP; bazelisk build nativelink-config:docs_json && cd docs && bun run src/utils/metaphase_aot.ts",
"docs.generate": "bun run src/utils/md_to_mdx_aot.ts",
"docs.build": "cd .. && unset TMPDIR TMP; bazelisk build nativelink-config:docs_json && cd docs && bun run src/utils/docs.build.ts",
"docs.generate": "bun run src/utils/docs.generate.ts",
"build": "bun fix && astro build",
"check": "biome ci . && astro check",
"dev": "astro dev",
Expand Down
49 changes: 49 additions & 0 deletions docs/src/styles/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,52 @@ html[data-theme="dark"] .beoe-light {
html {
scroll-behavior: smooth;
}

.buttons {
display: flex;
justify-content: center;
gap: 10px;
margin-top: 20px;
}

.buttons button {
background-color: #4A90E2; /* A nice blue color */
color: white;
font-size: 18px;
font-weight: bold;
border: none;
border-radius: 50%;
width: 50px;
height: 50px;
cursor: pointer;
transition: transform 0.2s ease, background-color 0.2s ease;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
display: flex;
justify-content: center;
align-items: center;
}

.buttons button:hover {
background-color: #357ABD; /* Darker blue on hover */
transform: scale(1.1);
}

.buttons button:active {
background-color: #2C6BA1; /* Even darker blue on active */
transform: scale(1.05);
}

.buttons button:focus {
outline: none;
box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.5);
}

.buttons button:disabled {
background-color: #B0BEC5; /* Grey color for disabled state */
cursor: not-allowed;
transform: none;
}

.buttons button:disabled:hover {
transform: none;
}
2 changes: 1 addition & 1 deletion docs/src/styles/tailwind.css
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);
Expand Down
10 changes: 10 additions & 0 deletions docs/src/utils/docs.build.ts
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",
});
}
80 changes: 80 additions & 0 deletions docs/src/utils/docs.generate.ts
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);
});
59 changes: 59 additions & 0 deletions docs/src/utils/md-to-mdx/ast/debug.ts
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);
Loading

0 comments on commit 0710d73

Please sign in to comment.