forked from TraceMachina/nativelink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reimplement documentation infrastructure
Probably most modern Documentation stack in existence.
- Loading branch information
1 parent
c85b6df
commit f90d793
Showing
34 changed files
with
13,373 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# build output | ||
dist/ | ||
# generated types | ||
.astro/ | ||
|
||
# dependencies | ||
node_modules/ | ||
|
||
# logs | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
|
||
|
||
# environment variables | ||
.env | ||
.env.production | ||
|
||
# macOS-specific files | ||
.DS_Store | ||
|
||
# Generated by wrangler during local development. | ||
.wrangler | ||
|
||
# Generated during the build and only intended to debug bundle size. | ||
stats.html | ||
|
||
# Generated files | ||
src/content/docs/guides/contributing.mdx | ||
src/content/docs/guides/lre.mdx | ||
src/content/docs/reference/changelog.mdx | ||
src/content/docs/reference/nativelink-config.mdx | ||
src/content/docs/tutorials/setup.mdx | ||
src/content/docs/guides/chromium.mdx | ||
src/content/docs/guides/configuration.mdx | ||
src/content/docs/guides/kubernetes.mdx | ||
src/content/docs/guides/setup.md |
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 @@ | ||
v22.3.0 |
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,60 @@ | ||
# The NativeLink documentation | ||
|
||
This is the NativeLink documentation hosted at <https://docs.nativelink.com>. | ||
|
||
## 📚 Stack | ||
|
||
The NativeLink documentation uses a custom, highly efficient, high performance | ||
stack. Getting a bunch of bleeding-edge tools to work well together can be | ||
challenging. Feel free to copy-paste it into your own projects. | ||
|
||
- [Diátaxis](https://diataxis.fr/) as overarching documentation philosophy. | ||
- [Pnpm](https://github.com/pnpm/pnpm) as production bundler. | ||
- [Bun](https://github.com/oven-sh/bun) as build-time TypeScript interpreter. | ||
- [Biome](https://biomejs.dev/) as linting toolchain. | ||
- [Astro](https://astro.build/) as meta-framework. | ||
- [Starlight](https://starlight.astro.build/de/) as documentation framework. | ||
- [Qwik](https://qwik.dev/) as SSR component framework. | ||
- [TailwindCSS 4.0-alpha](https://tailwindcss.com/blog/tailwindcss-v4-alpha) for | ||
component styling which makes use of [LightningCSS](https://lightningcss.dev/) | ||
for faster CSS processing. | ||
- [Cloudflare Pages/Workers](https://pages.cloudflare.com/) for deployments. | ||
|
||
## 🚀 Common workflows | ||
|
||
See `package.json` for build scripts. | ||
|
||
This project requires `pnpm`. The nix flake ships a compatible version. | ||
|
||
```bash | ||
# Install dependencies with pnpm. Don't install with bun. | ||
pnpm install | ||
|
||
# Run a development server. Doesn't rebuild the autogenerated parts of the docs. | ||
pnpm dev | ||
|
||
# Run formatter and linter checks. | ||
pnpm check | ||
|
||
# Apply formatter and linter fixes. | ||
pnpm fix | ||
|
||
# Test cloudflare deployments locally. Useful when debugging SSR. Rebuilds the | ||
# autogenerated parts of the docs. | ||
pnpm preview | ||
``` | ||
|
||
When deploying to Cloudflare, make sure to set the `PNPM_VERSION` to `8.15.5` to | ||
stay in sync with the flake. Also, use `pnpm exec playwright install && pnpm | ||
build` on the Cloudflare worker. This sets up headless Chromium which is used to | ||
generate mermaid diagrams during the build. You don't need to set playwright up | ||
locally as it's already configured in the flake. | ||
|
||
## 🐛 Known issues | ||
|
||
- `"@builder.io/qwik": "=1.5.6"` because `1.5.7` is bugged. | ||
- We use Bun as internal TypeScript processor, but can't use it as bundler yet. | ||
- HTML comments aren't correctly removed from Markdown documents. | ||
- The changelog needs to be excluded from `pagefind`. | ||
- `"@playform/compress": "=0.0.12"` because `0.0.13` doesn't properly compress | ||
CSS. |
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,238 @@ | ||
// import cloudflare from "@astrojs/cloudflare"; | ||
import partytown from "@astrojs/partytown"; | ||
import sitemap from "@astrojs/sitemap"; | ||
import starlight from "@astrojs/starlight"; | ||
import { rehypeMermaid } from "@beoe/rehype-mermaid"; // "rehype-mermaid"; | ||
import rehypeAutolinkHeadings from "rehype-autolink-headings"; | ||
import { rehypeHeadingIds } from "@astrojs/markdown-remark"; | ||
import starlightUtils from "@lorenzo_lewis/starlight-utils"; | ||
import { default as playformCompress } from "@playform/compress"; | ||
import qwikdev from "@qwikdev/astro"; | ||
import tailwindcss from "@tailwindcss/vite"; | ||
import { defineConfig } from "astro/config"; | ||
import { visualizer } from "rollup-plugin-visualizer"; | ||
import { visit } from "unist-util-visit"; | ||
|
||
function rehypeLazyLoadMermaid() { | ||
return (tree) => { | ||
visit(tree, 'element', (node) => { | ||
if (node.tagName === 'img') { | ||
node.properties.loading = 'lazy'; | ||
} | ||
}); | ||
}; | ||
} | ||
|
||
// https://astro.build/config | ||
// biome-ignore lint/style/noDefaultExport: Astro expects a default export. | ||
export default defineConfig({ | ||
// TODO(aaronmondal): Regularly test whether this still works. We currently | ||
// use a static build due to excessive SSR bundle size | ||
// caused by shiki. Migrate to full SSR once that's fixed. | ||
// output: "server", | ||
// adapter: cloudflare({ | ||
// imageService: "passthrough", | ||
// routes: { | ||
// extend: { | ||
// exclude: [{ pattern: "/build/*" }, { pattern: "/pagefind/*" }], | ||
// }, | ||
// }, | ||
// }), | ||
markdown: { | ||
rehypePlugins: [ | ||
rehypeHeadingIds, | ||
[ rehypeAutolinkHeadings, { behavior: "wrap" } ], | ||
[ | ||
rehypeMermaid, | ||
// TODO(aaronmondal): The "@beoe/cache" package doesn't build on | ||
// Cloudflare. Reimplement our own. | ||
{ class: "not-content", strategy: "img-class-dark-mode" }, | ||
], | ||
rehypeLazyLoadMermaid, | ||
], | ||
}, | ||
vite: { | ||
plugins: [visualizer()], | ||
css: { | ||
transformer: "lightningcss", | ||
plugins: [tailwindcss()], | ||
}, | ||
}, | ||
site: "https://nextgen-docs.nativelink.pages.dev", | ||
integrations: [ | ||
partytown(), | ||
qwikdev(), | ||
sitemap(), | ||
starlight({ | ||
components: { | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
PageFrame: "./src/components/PageFrame.astro", | ||
}, | ||
logo: { | ||
light: "/src/assets/logo-light.svg", | ||
dark: "/src/assets/logo-dark.svg", | ||
replacesTitle: true, | ||
}, | ||
title: "NativeLink Docs", | ||
social: { | ||
github: "https://github.com/TraceMachina/nativelink", | ||
slack: | ||
"https://nativelink.slack.com/join/shared_invite/zt-281qk1ho0-krT7HfTUIYfQMdwflRuq7A", | ||
}, | ||
customCss: ["./src/assets/landing.css", "./src/assets/custom.css"], | ||
plugins: [ | ||
starlightUtils({ | ||
navLinks: { | ||
leading: { useSidebarLabelled: "leadingNavLinks" }, | ||
}, | ||
}), | ||
], | ||
sidebar: [ | ||
{ | ||
label: "leadingNavLinks", | ||
items: [ | ||
{ label: "Docs", link: "/tutorials/setup/" }, | ||
{ label: "NativeCloud", link: "https://app.nativelink.com/" }, | ||
], | ||
}, | ||
// The documentation structure follows the Diátaxis framework. | ||
// See https://diataxis.fr/ for details. | ||
{ | ||
// Corresponds to https://diataxis.fr/tutorials/. Learning-oriented | ||
// content without elaborate explanations. Tutorials should have a | ||
// clear goal and a straightforward "follow-these-commands" structure. | ||
label: "Tutorials", | ||
items: [ | ||
{ | ||
label: "Setup", | ||
link: "/tutorials/setup", | ||
}, | ||
], | ||
}, | ||
{ | ||
// Corresponds to https://diataxis.fr/how-to-guides/. Guides don't | ||
// need to be "complete". They should provide practical guidance for | ||
// real-world use-cases. | ||
label: "Guides", | ||
items: [ | ||
{ | ||
label: "Configuration examples", | ||
link: "/guides/configuration", | ||
}, | ||
{ | ||
label: "Local Remote Execution", | ||
link: "/guides/lre/", | ||
}, | ||
{ | ||
label: "Chromium example", | ||
link: "/guides/chromium", | ||
}, | ||
{ | ||
label: "Kubernetes example", | ||
link: "/guides/kubernetes", | ||
}, | ||
{ | ||
label: "Contributing", | ||
link: "/guides/contributing", | ||
}, | ||
|
||
], | ||
}, | ||
{ | ||
// Corresponds to https://diataxis.fr/explanation/. Information on | ||
// internal functionality and design concepts. Explanations should | ||
// explain design decisions, constraints, etc. | ||
label: "Understanding NativeLink", | ||
items: [ | ||
{ | ||
label: "History", | ||
link: "/explanations/history/", | ||
}, | ||
], | ||
}, | ||
{ | ||
// Corresponds to https://diataxis.fr/reference/. Technical | ||
// descriptions with the intent to be used as consulting material. | ||
// Mostly autogenerated to stay in sync with the codebase. | ||
label: "Reference", | ||
autogenerate: { | ||
directory: "reference", | ||
}, | ||
}, | ||
], | ||
}), | ||
// Note: Compression should be the last integration. | ||
playformCompress({ | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
CSS: { | ||
lightningcss: { minify: true }, | ||
csso: null, | ||
}, | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
HTML: { | ||
"html-minifier-terser": { | ||
removeComments: false, // Preserve comments to maintain Qwik's hooks | ||
collapseWhitespace: false, | ||
removeAttributeQuotes: false, | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
minifyJS: true, | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
minifyCSS: true, | ||
}, | ||
}, | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
Image: true, | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
JavaScript: { | ||
terser: { | ||
// Qwik doesn't work with the default settings. Attempt to get as much | ||
// compression going as possible without breaking anything. | ||
compress: { | ||
booleans: true, | ||
conditionals: true, | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
dead_code: true, | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
drop_console: false, | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
drop_debugger: true, | ||
evaluate: true, | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
hoist_funs: true, | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
hoist_vars: true, | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
if_return: true, | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
join_vars: true, | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
keep_fargs: true, // Necessary for function arguments | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
keep_fnames: true, // Keep function names for debugging | ||
loops: true, | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
negate_iife: true, | ||
properties: true, | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
reduce_funcs: true, | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
reduce_vars: true, | ||
sequences: true, | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
side_effects: true, | ||
typeofs: false, // Keep typeof | ||
unused: true, | ||
warnings: true, | ||
}, | ||
mangle: { | ||
// Preserve function names for debugging | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
keep_fnames: true, | ||
}, | ||
}, | ||
}, | ||
// biome-ignore lint/style/useNamingConvention: Can't change this. | ||
SVG: true, | ||
}), | ||
], | ||
}); |
Oops, something went wrong.