Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ content/docs/

The navigation validation tests run with `pnpm test`. They verify tool roots, declared pages, and document frontmatter.

Use [native Fumadocs code tabs](https://www.fumadocs.dev/docs/next/markdown#tab-groups) for interchangeable examples. Give consecutive fences a `tab="..."` label and set `tab-group="package-manager"` on the first fence of each npm/pnpm/Yarn installation group so the selected manager is shared and remembered. Keep sequential commands, inputs and outputs in separate blocks.

## Interactive Throughline examples

Selected Throughline guides render the published `@0xbuff/[email protected]` React player. The overview leads with a multi-system checkout recovery trace; introductory pages retain smaller teaching examples. Sources are kept in `src/lib/throughline-demos.ts`; MDX pages use `<ThroughlineDemo id="..." />`. The component is registered in `src/components/mdx.tsx`. Its compiler, player and namespaced CSS load in a separate module only when a demo is rendered. All other 0xBUFF tool documentation remains independent of Throughline.
Expand Down
6 changes: 3 additions & 3 deletions content/docs/assay/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ This guide takes you from installation to a working text comparison.

Assay requires Node.js 24 or later and ECMAScript modules (ESM). TypeScript declarations are included.

```sh
```sh tab="npm" tab-group="package-manager"
npm install @0xbuff/assay
```

```sh
```sh tab="pnpm"
pnpm add @0xbuff/assay
```

```sh
```sh tab="yarn"
yarn add @0xbuff/assay
```

Expand Down
12 changes: 10 additions & 2 deletions content/docs/assay/observations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,17 @@ The review observation must bind to the bundle's artifact digest and match the p
}
```

For model attribution, use:
Choose the reviewer field for the source of the feedback:

```ts
```ts tab="Human"
reviewer: {
kind: "human",
reviewerId: "reviewer-1",
reviewerVersion: "v1",
}
```

```ts tab="Model"
reviewer: {
kind: "model",
providerId: "provider",
Expand Down
20 changes: 18 additions & 2 deletions content/docs/throughline/compatibility.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,32 @@ These guides describe **`@0xbuff/[email protected]`**, published November 8, 202

## Installation and requirements

~~~sh
~~~sh tab="npm" tab-group="package-manager"
npm install @0xbuff/[email protected]
~~~

~~~sh tab="pnpm"
pnpm add @0xbuff/[email protected]
~~~

~~~sh tab="yarn"
yarn add @0xbuff/[email protected]
~~~

For the optional React player:

~~~sh
~~~sh tab="npm" tab-group="package-manager"
npm install react@^19 react-dom@^19
~~~

~~~sh tab="pnpm"
pnpm add react@^19 react-dom@^19
~~~

~~~sh tab="yarn"
yarn add react@^19 react-dom@^19
~~~

| Requirement | v0.0.2 support |
| --- | --- |
| Node.js | **24 or newer** for Node-hosted tooling |
Expand Down
20 changes: 18 additions & 2 deletions content/docs/throughline/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@ Use an ESM project and **Node.js 24 or newer** for Node-based execution. React i

## 1. Install Throughline

~~~sh
~~~sh tab="npm" tab-group="package-manager"
npm install @0xbuff/[email protected]
~~~

~~~sh tab="pnpm"
pnpm add @0xbuff/[email protected]
~~~

~~~sh tab="yarn"
yarn add @0xbuff/[email protected]
~~~

Keep this exact version and commit your package lockfile so the examples match the installed API.

## 2. Compile a trace
Expand Down Expand Up @@ -70,10 +78,18 @@ The code above and this player describe the same sequence of states. Use **Next*

Install React 19 and React DOM 19 if your project does not already include them:

~~~sh
~~~sh tab="npm" tab-group="package-manager"
npm install react@^19 react-dom@^19
~~~

~~~sh tab="pnpm"
pnpm add react@^19 react-dom@^19
~~~

~~~sh tab="yarn"
yarn add react@^19 react-dom@^19
~~~

Import the player and its CSS. In an application, import the stylesheet once in your root entry.

~~~tsx
Expand Down
10 changes: 9 additions & 1 deletion content/docs/throughline/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,18 @@ This checkout scenario follows a lost provider reply, an unknown payment outcome

Install the package:

~~~sh
~~~sh tab="npm" tab-group="package-manager"
npm install @0xbuff/[email protected]
~~~

~~~sh tab="pnpm"
pnpm add @0xbuff/[email protected]
~~~

~~~sh tab="yarn"
yarn add @0xbuff/[email protected]
~~~

Compile a trace:

~~~ts
Expand Down
10 changes: 9 additions & 1 deletion content/docs/throughline/markdown-mdx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,18 @@ export function remarkValidateThroughline() {

Install the remark visitor and types if needed:

~~~sh
~~~sh tab="npm" tab-group="package-manager"
npm install -D unist-util-visit @types/mdast
~~~

~~~sh tab="pnpm"
pnpm add -D unist-util-visit @types/mdast
~~~

~~~sh tab="yarn"
yarn add -D unist-util-visit @types/mdast
~~~

Then register the validator in your existing Fumadocs MDX options; **preserve the other plugins**:

~~~ts
Expand Down
10 changes: 9 additions & 1 deletion content/docs/throughline/react-player.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@ description: Render compiled traces with controls, captions, keyboard navigation

## Install and render

~~~sh
~~~sh tab="npm" tab-group="package-manager"
npm install @0xbuff/[email protected] react@^19 react-dom@^19
~~~

~~~sh tab="pnpm"
pnpm add @0xbuff/[email protected] react@^19 react-dom@^19
~~~

~~~sh tab="yarn"
yarn add @0xbuff/[email protected] react@^19 react-dom@^19
~~~

~~~tsx
import { compile } from "@0xbuff/throughline";
import { ThroughlinePlayer } from "@0xbuff/throughline/react";
Expand Down
8 changes: 7 additions & 1 deletion content/docs/throughline/styling.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ Load it once, usually in your application entry or root stylesheet. The compiler

## Set the theme

~~~tsx
~~~tsx tab="System"
<ThroughlinePlayer trace={trace} theme="auto" />
~~~

~~~tsx tab="Light"
<ThroughlinePlayer trace={trace} theme="light" />
~~~

~~~tsx tab="Dark"
<ThroughlinePlayer trace={trace} theme="dark" />
~~~

Expand Down
70 changes: 70 additions & 0 deletions scripts/code-tabs.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import assert from "node:assert/strict";
import { readFile, readdir } from "node:fs/promises";
import { join } from "node:path";
import test from "node:test";

const root = "content/docs";
const expected = new Map([
["assay/getting-started.mdx", ["@0xbuff/assay"]],
["throughline/getting-started.mdx", ["@0xbuff/[email protected]", "react@^19 react-dom@^19"]],
["throughline/index.mdx", ["@0xbuff/[email protected]"]],
["throughline/compatibility.mdx", ["@0xbuff/[email protected]", "react@^19 react-dom@^19"]],
["throughline/react-player.mdx", ["@0xbuff/[email protected] react@^19 react-dom@^19"]],
["throughline/markdown-mdx.mdx", ["-D unist-util-visit @types/mdast"]],
]);

function fences(source) {
return [...source.matchAll(/^(\x60{3}|~{3})([^\n]*)\n([\s\S]*?)^\1[ \t]*$/gm)]
.map((match) => ({ meta: match[2], body: match[3].trim(), start: match.index, end: match.index + match[0].length }));
}

test("package installation alternatives are adjacent native code tabs", async () => {
const seen = new Set();
for (const product of await readdir(root, { withFileTypes: true })) {
if (!product.isDirectory()) continue;
for (const file of await readdir(join(root, product.name))) {
if (!file.endsWith(".mdx")) continue;
const name = product.name + "/" + file;
const source = await readFile(join(root, name), "utf8");
const blocks = fences(source);
const found = [];
for (let i = 0; i < blocks.length; i++) {
const first = blocks[i];
const match = first.body.match(/^npm install (.+)$/);
if (!/^sh(?:\s|$)/.test(first.meta) || !match) {
if (/^sh(?:\s|$)/.test(first.meta)) assert.doesNotMatch(first.body, /^(?:pnpm add|yarn add) /, name + ": orphan package tab");
continue;
}
const args = match[1];
const pnpm = blocks[i + 1];
const yarn = blocks[i + 2];
assert.equal(first.meta, 'sh tab="npm" tab-group="package-manager"', name);
assert.equal(pnpm?.meta, 'sh tab="pnpm"', name);
assert.equal(yarn?.meta, 'sh tab="yarn"', name);
assert.equal(pnpm.body, "pnpm add " + args, name);
assert.equal(yarn.body, "yarn add " + args, name);
assert.match(source.slice(first.end, pnpm.start), /^\s*$/, name);
assert.match(source.slice(pnpm.end, yarn.start), /^\s*$/, name);
found.push(args);
i += 2;
}
assert.deepEqual(found, expected.get(name) ?? [], name);
if (found.length) seen.add(name);
}
}
assert.deepEqual([...seen].sort(), [...expected.keys()].sort());
});

test("reviewer and player theme alternatives are native tab groups", async () => {
for (const [path, labels] of [
["assay/observations.mdx", ["Human", "Model"]],
["throughline/styling.mdx", ["System", "Light", "Dark"]],
]) {
const source = await readFile(join(root, path), "utf8");
const blocks = fences(source).filter((block) => /\btab="/.test(block.meta));
assert.deepEqual(blocks.map((block) => block.meta.match(/\btab="([^"]+)"/)?.[1]), labels);
for (let i = 1; i < blocks.length; i++) {
assert.match(source.slice(blocks[i - 1].end, blocks[i].start), /^\s*$/, path);
}
}
});
Loading