Skip to content

Commit dda6e92

Browse files
ericallamTrigger.dev RepoOps
authored andcommitted
feat(docs): dashboard figures
Mono-RevId: 6d9b335237ff9fbf9e4ebc2090947b09d76481c8
1 parent d3c7adb commit dda6e92

88 files changed

Lines changed: 15663 additions & 203 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.claude/rules/docs-writing.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ paths:
77

88
- MDX rendered by the docs site in `apps/docs`; `docs/AGENTS.md` has the full guide, including what each CI check failure means. Frontmatter: `title`, `description`, `sidebarTitle` (optional).
99
- After creating a new page, add it to `docs.json` navigation under the correct group.
10-
- Components: `<Note>`, `<Warning>`, `<Info>`, `<Tip>`, `<CodeGroup>`, `<Expandable>`, `<Steps>`/`<Step>` (Mintlify's names and props).
10+
- Components: `<Note>`, `<Warning>`, `<Info>`, `<Tip>`, `<CodeGroup>`, `<Expandable>`, `<Steps>`/`<Step>` (Mintlify's names and props). Pictures of the dashboard are `<DashboardFigure>`, not screenshots (`.claude/skills/docs-dashboard-figures/SKILL.md`).
1111
- Moving or deleting a page: add a `redirects` entry in `docs.json`.
1212
- Check with `pnpm --filter docs-site check --links` (fast), or build and run `check` for everything CI runs.
1313
- Code examples should be complete and runnable where possible.

‎.claude/skills/docs-dashboard-figures/SKILL.md‎

Lines changed: 259 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
// Turns a region of the running dashboard into static JSX for a docs figure.
2+
//
3+
// Load it into the dashboard tab (Chrome DevTools MCP `evaluate_script`, format "script",
4+
// sourcePath = this file), then call it:
5+
//
6+
// () => window.__figureCapture("<css selector>") // JSX string
7+
// () => window.__figureCapture(el, { icons: "name" }) // svgs as <Icon name="..." /> placeholders
8+
//
9+
// What it does, so the output is safe inside docs prose:
10+
// - keeps every class verbatim, except interaction-only ones (hover:, focus, active:,
11+
// transitions, cursors): a figure is a still frame.
12+
// - turns semantic and interactive tags into div/span (a, button, h1-h6, p, ul, li, label,
13+
// table parts as display:table divs, input/textarea as a box with the value or placeholder).
14+
// - drops attributes except class, and style values that size or colour the element.
15+
// - inlines svgs as JSX (camelCased attributes).
16+
// The output is a starting point: replace the dashboard's data with the docs' example data,
17+
// cut what the figure doesn't need, and put data-mark on the elements the text points at.
18+
(() => {
19+
const DROP_CLASS =
20+
/(^|:)(hover|focus|focus-visible|focus-within|active|group-hover|group-focus|peer-hover|peer-focus|disabled|group-disabled)(\/[\w-]+)?:|^(transition|duration-|ease-|delay-|cursor-|select-none|outline-hidden|focus-custom|touch-none|pointer-events-|will-change|animate-)/;
21+
const INLINE = new Set([
22+
"a",
23+
"span",
24+
"label",
25+
"code",
26+
"strong",
27+
"em",
28+
"b",
29+
"i",
30+
"small",
31+
"kbd",
32+
"abbr",
33+
]);
34+
const TABLE = {
35+
table: "table",
36+
thead: "table-header-group",
37+
tbody: "table-row-group",
38+
tfoot: "table-footer-group",
39+
tr: "table-row",
40+
th: "table-cell",
41+
td: "table-cell",
42+
colgroup: null,
43+
col: null,
44+
};
45+
const SKIP = new Set(["script", "style", "template", "noscript", "colgroup", "col"]);
46+
const KEEP_STYLE =
47+
/^(width|height|min-width|max-width|min-height|grid-template-columns|background-color|color|border-color|font-size)$/;
48+
49+
const camel = (s) => s.replace(/[-:]([a-z])/g, (_, c) => c.toUpperCase());
50+
const esc = (s) => s.replace(/[{}<>]/g, (c) => `{"${c}"}`);
51+
52+
const classes = (el, extra) => {
53+
const list = (el.getAttribute("class") || "")
54+
.split(/\s+/)
55+
.filter((c) => c && !DROP_CLASS.test(c));
56+
if (extra) list.unshift(extra);
57+
return list.length ? ` className="${list.join(" ")}"` : "";
58+
};
59+
60+
const style = (el) => {
61+
const s = el.getAttribute("style");
62+
if (!s) return "";
63+
const kept = s
64+
.split(";")
65+
.map((d) => d.split(":").map((x) => x.trim()))
66+
.filter(([k, v]) => k && v && KEEP_STYLE.test(k) && !v.includes("var(--sm-"));
67+
if (!kept.length) return "";
68+
return ` style={{ ${kept.map(([k, v]) => `${camel(k)}: ${JSON.stringify(v)}`).join(", ")} }}`;
69+
};
70+
71+
const svg = (el, opts, pad) => {
72+
if (opts.icons === "name") return `${pad}<Icon name="TODO"${classes(el)} />`;
73+
const clone = el.cloneNode(true);
74+
clone.querySelectorAll("title").forEach((t) => t.remove());
75+
let html = clone.outerHTML
76+
.replace(/\s(class)="([^"]*)"/g, (_, __, v) => {
77+
const kept = v.split(/\s+/).filter((c) => c && !DROP_CLASS.test(c));
78+
return kept.length ? ` className="${kept.join(" ")}"` : "";
79+
})
80+
.replace(/\s(aria-hidden|data-[\w-]+|focusable)="[^"]*"/g, "")
81+
.replace(/\sstyle="[^"]*"/g, "")
82+
.replace(/\s([a-z]+[-:][a-z-:]+)=/g, (_, a) => ` ${camel(a)}=`)
83+
.replace(/<(\w+)([^>]*)><\/\1>/g, "<$1$2 />");
84+
return pad + html;
85+
};
86+
87+
const walk = (node, opts, depth) => {
88+
const pad = " ".repeat(depth);
89+
if (node.nodeType === 3) {
90+
const t = node.textContent.replace(/\s+/g, " ").trim();
91+
return t ? pad + esc(t) : "";
92+
}
93+
if (node.nodeType !== 1) return "";
94+
const el = node;
95+
const tag = el.tagName.toLowerCase();
96+
if (SKIP.has(tag)) return "";
97+
if (el.getAttribute("aria-hidden") === "true" && tag !== "svg" && !el.textContent.trim())
98+
return "";
99+
const cs = getComputedStyle(el);
100+
if (cs.display === "none" || (cs.visibility === "hidden" && tag !== "svg")) return "";
101+
if (tag === "svg") return svg(el, opts, pad);
102+
if (tag === "img")
103+
return `${pad}<div${classes(el)}${style(el)} /> {/* img: ${el.getAttribute("alt") || el.getAttribute("src")} */}`;
104+
if (tag === "input" || tag === "textarea" || tag === "select") {
105+
const type = el.getAttribute("type");
106+
if (type === "checkbox" || type === "radio") {
107+
return `${pad}<div${classes(el)} /> {/* ${type}${el.checked ? " checked" : ""} */}`;
108+
}
109+
const value = el.value || "";
110+
const shown = value || el.getAttribute("placeholder") || "";
111+
const tone = value ? "" : "text-text-dimmed";
112+
return `${pad}<div${classes(el, tone)}${style(el)}>${esc(shown)}</div>`;
113+
}
114+
let out = INLINE.has(tag) ? "span" : "div";
115+
let extra = "";
116+
if (tag in TABLE) {
117+
out = "div";
118+
extra = TABLE[tag];
119+
}
120+
const kids = [...el.childNodes].map((c) => walk(c, opts, depth + 1)).filter(Boolean);
121+
const open = `${pad}<${out}${classes(el, extra)}${style(el)}`;
122+
if (!kids.length) return `${open} />`;
123+
return `${open}>\n${kids.join("\n")}\n${pad}</${out}>`;
124+
};
125+
126+
window.__figureCapture = (root, opts = {}) => {
127+
const el = typeof root === "string" ? document.querySelector(root) : root;
128+
if (!el) return `/* nothing matches ${root} */`;
129+
const r = el.getBoundingClientRect();
130+
return (
131+
`{/* captured ${location.pathname} ${Math.round(r.width)}x${Math.round(r.height)} */}\n` +
132+
walk(el, opts, 0)
133+
);
134+
};
135+
})();

‎.github/workflows/docs-figures.yml‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: 📚 Docs figures
2+
3+
# The docs draw some dashboard screens in code (apps/docs/lib/dashboard-figures.ts). A webapp change
4+
# can make one stale, so this runs on webapp changes too and lists the figures to review as warnings.
5+
# It fails only on a <DashboardFigure> tag that names a missing figure or mark.
6+
on:
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
paths:
10+
- ".github/workflows/docs-figures.yml"
11+
- "apps/webapp/app/**"
12+
- "apps/docs/lib/dashboard-figures*"
13+
- "apps/docs/scripts/check-figures.mjs"
14+
- "docs/**"
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
18+
cancel-in-progress: true
19+
20+
permissions:
21+
contents: read
22+
23+
jobs:
24+
figures:
25+
name: figures
26+
runs-on: ubuntu-latest
27+
timeout-minutes: 5
28+
steps:
29+
- name: 📥 Checkout repository
30+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
31+
with:
32+
persist-credentials: false
33+
34+
- name: ⎔ Setup node
35+
uses: WarpBuilds/setup-node@2867cf8f859d73439e1ad18b542617e5a29f0f10 # v7.0.0
36+
with:
37+
node-version: 24.22.1
38+
39+
- name: 🖼️ Check dashboard figures
40+
run: node apps/docs/scripts/check-figures.mjs

‎.github/workflows/publish-docs.yml‎

Lines changed: 6 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ name: 📚 Publish docs
22

33
# Docs-only commits on main publish on merge. Anything else waits for a
44
# docs-release-* tag. See .github/scripts/publish-docs.sh.
5-
#
6-
# Every new docs-live commit is also deployed as the docs site's (apps/docs) production
7-
# deployment, checked before it takes the production domain. That job skips with a notice
8-
# until its secrets exist: VERCEL_TOKEN, VERCEL_ORG_ID, VERCEL_DOCS_PROJECT_ID and
9-
# VERCEL_AUTOMATION_BYPASS_SECRET.
5+
# docs-live feeds the Mintlify docs until the new docs site replaces them. The docs site is
6+
# published and deployed elsewhere; nothing here deploys it.
107
on:
118
push:
129
branches:
@@ -17,9 +14,7 @@ on:
1714
- "docs-release-*"
1815
workflow_dispatch:
1916

20-
# Writes docs-live (Mintlify's GitHub app deploys from it) and comments on waiting commits.
21-
permissions:
22-
contents: write
17+
permissions: {}
2318

2419
concurrency:
2520
group: publish-docs
@@ -28,9 +23,8 @@ concurrency:
2823
jobs:
2924
publish:
3025
runs-on: warp-ubuntu-latest-x64-2x
31-
outputs:
32-
publish_sha: ${{ steps.build.outputs.publish_sha }}
33-
deploy_sha: ${{ steps.target.outputs.deploy_sha }}
26+
permissions:
27+
contents: write # pushes docs-live (Mintlify's GitHub app deploys from it) and comments on waiting commits
3428
env:
3529
GIT_AUTHOR_NAME: github-actions[bot]
3630
GIT_AUTHOR_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
@@ -87,20 +81,7 @@ jobs:
8781
git -c "http.https://github.com/.extraheader=AUTHORIZATION: basic $auth" \
8882
push origin "$PUBLISH_SHA:refs/heads/docs-live"
8983
90-
# A manual run with nothing new to publish redeploys docs-live as it is: the way to recover
91-
# a production deploy that a failed or skipped run left behind.
92-
- name: 🎯 Pick the tree to deploy
93-
id: target
94-
env:
95-
PUBLISH_SHA: ${{ steps.build.outputs.publish_sha }}
96-
run: |
97-
sha="$PUBLISH_SHA"
98-
if [ -z "$sha" ] && [ "$GITHUB_EVENT_NAME" = workflow_dispatch ]; then
99-
sha=$(git ls-remote "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" refs/heads/docs-live | cut -f1)
100-
fi
101-
echo "deploy_sha=$sha" >> "$GITHUB_OUTPUT"
102-
103-
# Comments are a courtesy: a failed one must not stop the deploy of what was just pushed.
84+
# Comments are a courtesy: a failed one must not fail the run after docs-live moved.
10485
- name: 💬 Comment on docs-only commits that are waiting
10586
if: steps.build.outputs.publish_sha != ''
10687
continue-on-error: true
@@ -119,126 +100,3 @@ jobs:
119100
-f body="This docs-only change is waiting for the next docs release: $why. It will go live with the next \`docs-release-*\` tag that includes it." \
120101
>/dev/null
121102
done <"$RUNNER_TEMP/new-waiting"
122-
123-
# Builds the tree just pushed to docs-live, deploys it without the production domain, checks
124-
# the deployment, then promotes it. A failed step leaves the previous deployment serving.
125-
deploy-site:
126-
name: deploy-site
127-
needs: publish
128-
# Pushes, tags and manual runs only: never on a pull request, which can't reach these secrets anyway.
129-
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && needs.publish.outputs.deploy_sha != ''
130-
runs-on: warp-ubuntu-latest-x64-4x
131-
timeout-minutes: 20
132-
permissions:
133-
contents: read
134-
# One production deploy at a time, in order, so an older tree never promotes last.
135-
concurrency:
136-
group: docs-production
137-
cancel-in-progress: false
138-
env:
139-
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
140-
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
141-
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_DOCS_PROJECT_ID }}
142-
VERCEL_CLI: vercel@65.14.0
143-
NEXT_TELEMETRY_DISABLED: "1"
144-
steps:
145-
- name: 🔑 Check deploy settings
146-
id: config
147-
run: |
148-
if [ -z "$VERCEL_TOKEN" ] || [ -z "$VERCEL_ORG_ID" ] || [ -z "$VERCEL_PROJECT_ID" ]; then
149-
echo "::notice title=Docs site deploy skipped::VERCEL_TOKEN, VERCEL_ORG_ID or VERCEL_DOCS_PROJECT_ID is not set."
150-
echo "enabled=false" >> "$GITHUB_OUTPUT"
151-
else
152-
echo "enabled=true" >> "$GITHUB_OUTPUT"
153-
fi
154-
155-
- name: 📥 Checkout docs-live
156-
if: steps.config.outputs.enabled == 'true'
157-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
158-
with:
159-
ref: ${{ needs.publish.outputs.deploy_sha }}
160-
# History (without old file contents) gives each page its last-modified date in the
161-
# sitemap, JSON-LD and .md; a shallow clone builds without them.
162-
fetch-depth: 0
163-
filter: blob:none
164-
persist-credentials: false
165-
166-
- name: ⎔ Setup pnpm
167-
if: steps.config.outputs.enabled == 'true'
168-
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
169-
with:
170-
version: 10.33.2
171-
172-
- name: ⎔ Setup node
173-
if: steps.config.outputs.enabled == 'true'
174-
uses: WarpBuilds/setup-node@2867cf8f859d73439e1ad18b542617e5a29f0f10 # v7.0.0
175-
with:
176-
node-version: 24.22.1
177-
cache: "pnpm"
178-
179-
- name: 💾 Restore the docs build cache
180-
if: steps.config.outputs.enabled == 'true'
181-
uses: WarpBuilds/cache@dad44e2487e9dc889ad6e6bd198e77bb2d828eee # v2.0.0
182-
with:
183-
path: apps/docs/.next/cache
184-
key: docs-next-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('apps/docs/**', 'docs/**') }}
185-
restore-keys: |
186-
docs-next-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-
187-
188-
# The project's root directory is apps/docs; its vercel.json installs only the docs site.
189-
- name: ⚙️ Pull project settings
190-
if: steps.config.outputs.enabled == 'true'
191-
run: pnpm dlx "$VERCEL_CLI" pull --yes --environment=production --token="$VERCEL_TOKEN"
192-
193-
# The build stops if a production setting (Ask AI, its limits, analytics) is missing.
194-
- name: 🏗️ Build
195-
if: steps.config.outputs.enabled == 'true'
196-
env:
197-
VERCEL_ENV: production
198-
run: pnpm dlx "$VERCEL_CLI" build --prod --token="$VERCEL_TOKEN"
199-
200-
- name: 🚀 Deploy without the production domain
201-
id: deploy
202-
if: steps.config.outputs.enabled == 'true'
203-
run: |
204-
url=$(pnpm dlx "$VERCEL_CLI" deploy --prebuilt --prod --skip-domain --token="$VERCEL_TOKEN")
205-
echo "url=$url" >> "$GITHUB_OUTPUT"
206-
207-
- name: 🔗 Check URLs, MCP and headers on the deployment
208-
if: steps.config.outputs.enabled == 'true'
209-
working-directory: apps/docs
210-
env:
211-
URL: ${{ steps.deploy.outputs.url }}
212-
# Deployment URLs sit behind the project's Vercel Authentication until promoted.
213-
VERCEL_AUTOMATION_BYPASS_SECRET: ${{ secrets.VERCEL_AUTOMATION_BYPASS_SECRET }}
214-
run: |
215-
node scripts/check-urls.mjs "$URL/docs" --live
216-
node scripts/check-mcp.mjs "$URL/docs"
217-
node scripts/check-headers.mjs "$URL/docs"
218-
219-
- name: ✅ Promote to production
220-
if: steps.config.outputs.enabled == 'true'
221-
env:
222-
URL: ${{ steps.deploy.outputs.url }}
223-
PUBLISH_SHA: ${{ needs.publish.outputs.deploy_sha }}
224-
run: |
225-
# A rerun of an older run must not put an older tree back over a newer one.
226-
head=$(git ls-remote "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" refs/heads/docs-live | cut -f1)
227-
if [ "$head" != "$PUBLISH_SHA" ]; then
228-
msg="docs-live is at $head now, not $PUBLISH_SHA. Re-run the workflow run for $head instead."
229-
echo "::notice title=Docs site not promoted::$msg"
230-
echo "### Docs site not promoted: $msg" >> "$GITHUB_STEP_SUMMARY"
231-
exit 0
232-
fi
233-
pnpm dlx "$VERCEL_CLI" promote "$URL" --yes --token="$VERCEL_TOKEN"
234-
echo "### Docs site live: $PUBLISH_SHA ($URL)" >> "$GITHUB_STEP_SUMMARY"
235-
236-
- name: 📣 Report a failed deploy
237-
if: failure()
238-
env:
239-
PUBLISH_SHA: ${{ needs.publish.outputs.deploy_sha }}
240-
run: |
241-
msg="The docs site production deploy of $PUBLISH_SHA failed. The previous deployment is still serving; Mintlify publishing from docs-live is unaffected."
242-
echo "::error title=Docs site deploy failed::$msg"
243-
echo "### Docs site deploy failed" >> "$GITHUB_STEP_SUMMARY"
244-
echo "$msg Re-run this job once the cause is fixed." >> "$GITHUB_STEP_SUMMARY"

‎apps/docs/.env.example‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44

55
# Ask AI. Unset: no Ask AI button and /api/ask answers 404.
66
# ANTHROPIC_API_KEY=
7+
# Or Amazon Bedrock. Default: anthropic
8+
# DOCS_ASK_MODEL_PROVIDER=bedrock
9+
# Production: a role assumed with Vercel OIDC. The role trusts only production deployments,
10+
# so local dev uses the IAM key pair below.
11+
# DOCS_ASK_AWS_ROLE_ARN=
12+
# Or an IAM key pair
13+
# DOCS_ASK_AWS_ACCESS_KEY_ID=
14+
# DOCS_ASK_AWS_SECRET_ACCESS_KEY=
15+
# Default: AWS_REGION
16+
# DOCS_ASK_AWS_REGION=us-east-1
717
# Default: claude-sonnet-5-5
818
# ASK_AI_MODEL=
919
# Default: 25000000 (output tokens count 5 times)

0 commit comments

Comments
 (0)