Skip to content

Commit ca27b20

Browse files
authored
fix(versioning): cleanup versioning abilities. (#18)
1 parent 4144f53 commit ca27b20

6 files changed

Lines changed: 167 additions & 15 deletions

File tree

‎AGENTS.md‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
55
## What this repo is
66

7-
A Bun-workspaces monorepo containing the Abstract Data Starlight documentation theme, a local playground that consumes it, and (eventually) a GitHub template repo for client project scaffolding.
7+
A Bun-workspaces monorepo containing the Abstract Data Starlight documentation theme, the CLI scaffolder, and the template client projects are scaffolded from.
88

9-
- `packages/starlight-theme/` — the `@abstractdata/starlight-theme` npm package. **This is the deliverable.**
9+
- `packages/starlight-theme/` — the `@abstractdata/starlight-theme` npm package. **This is the primary deliverable.**
10+
- `packages/create-docs/` — the `@abstractdata/create-docs` CLI scaffolder (`bun create @abstractdata/docs`).
11+
- `packages/template/` — the template `create-docs` bundles and scaffolds from.
1012
- `apps/playground/` — private dev site, never published. Consumes the theme via `workspace:*`.
11-
- `mockup.html` — round-two static HTML mockup. Source of truth for visual decisions until Round 3 lands. Don't delete.
13+
- `docs/round-2-mockup.html` — archived static HTML mockup. Visual reference — don't delete.
1214

1315
## Package manager
1416

@@ -49,7 +51,7 @@ Lockfile is `bun.lock` (text-based). Commit it.
4951
- ✅ **Round 3c:** branded Shiki/expressive-code themes (cyan/gold/burgundy), custom `<Hero>` component using Astro's `<Image>`, gold ghost button polish, light-mode hex visibility bumped, branded TOC right sidebar, `packages/template/` template package with GitHub Pages workflow.
5052
- ✅ **Round 3.5 (QA):** branded `404.astro` with Glitch headline, search modal styling (`site-search dialog` + `::backdrop`), expanded `prefers-reduced-motion` block, mobile/light/calm walkthrough confirmed.
5153
- ✅ **Round 4:** self-hosted variable fonts via `@fontsource-variable/*` (no Google Fonts CDN), Vercel + Cloudflare Pages workflow variants in template, kitchen-sink showcase page, migration guide for existing Starlight users, `mockup.html` archived to `docs/`.
52-
- ⏳ **Future:** `bun create @abstractdata/docs` CLI scaffolder (separate `create-abstractdata-docs` package).
54+
- ✅ **Round 5:** `bun create @abstractdata/docs` CLI scaffolder (`packages/create-docs/`), Python + TypeScript autodoc pipelines (`scripts/build-python-docs.mjs` / `build-ts-docs.mjs`), `<VersionPicker>` component for versioned API reference, `abstract-data-setup` skill with full Python + TS detection and config-write workflow, multi-tool skill compilation (Cursor MDC + Copilot), release-please automation.
5355

5456
## Non-obvious gotchas — read before adding features
5557

@@ -78,13 +80,15 @@ Releases are automated via [release-please](https://github.com/googleapis/releas
7880

7981
This repo ships a Claude Code skill at `.claude/skills/abstract-data-setup/SKILL.md` — when invoked inside a project that depends on `@abstractdata/starlight-theme`, it walks the user through:
8082

81-
1. **Detection** — Python signals via `pyproject.toml`, source tree shape, package + submodule discovery.
82-
2. **Docstring coverage audit** — runs `interrogate` (or AST walk fallback) on candidate modules, classifies as green/yellow/red, surfaces gaps before they become empty API pages.
83-
3. **Docstring style detection** — Google / NumPy / Sphinx sniffer; warns on mixed style.
84-
4. **Interactive questions** — modules to document, motion / credit / version.
85-
5. **Config writes** — `scripts/python-autodoc.json`, `astro.config.mjs` sidebar + plugin call, `package.json` `docs:python` script.
86-
6. **Optional generation** — runs `bun run docs:python` on consent.
87-
7. **Optional pre-commit hook** — if any module is below 80% coverage, offers to install an `interrogate` hook in the *source* project's `.pre-commit-config.yaml` plus dev deps. Edits the source repo, not the docs repo.
83+
1. **Stack detection** — Python (`pyproject.toml`, source tree), TypeScript (entry points, `package.json` exports), Next.js, TanStack Router, OpenAPI, Prisma, Drizzle, and logo assets.
84+
2. **Python docstring audit** — runs `interrogate` (or AST walk fallback), classifies green/yellow/red per module.
85+
3. **Python style detection** — Google / NumPy / Sphinx sniffer; warns on mixed style.
86+
4. **TypeScript TSDoc audit** — runs TypeDoc in validation-only mode to count undocumented exports, same traffic-light thresholds as Python.
87+
5. **Interactive questions** — modules/entry points to document, motion / credit / version, logo, last-updated timestamps, Edit-on-GitHub link.
88+
6. **Config writes** — `scripts/python-autodoc.json`, `scripts/ts-autodoc.json`, `astro.config.mjs` sidebar + plugin call, `package.json` `docs:python` / `docs:ts` scripts.
89+
7. **Optional generation** — runs `bun run docs:python` / `bun run docs:ts` on consent.
90+
8. **Thin-page dispatch** — detects sparse auto-generated pages and offers to hand off to the `abstract-data-docs-author` companion skill.
91+
9. **Optional pre-commit hook** — per-stack: `interrogate` for Python, TypeDoc validation for TypeScript. Edits the *source* repo, not the docs repo.
8892

8993
**Source of truth:** `.claude/skills/abstract-data-setup/SKILL.md` at the monorepo root. Everything else is generated from it.
9094

@@ -122,7 +126,7 @@ node scripts/compile-skill.mjs
122126

123127
### Future skills
124128

125-
TypeScript autodoc, OpenAPI, Next.js detection, etc. should follow the same pattern: hand-author a `SKILL.md`, let the compiler emit Cursor and Copilot variants. Add new entries to the `TARGETS` array in `scripts/compile-skill.mjs`.
129+
OpenAPI, Next.js route-map, Prisma schema-doc, Drizzle schema-doc, and `abstract-data-docs-author` (prose enrichment) should follow the same pattern when implemented: hand-author a `SKILL.md`, let the compiler emit Cursor and Copilot variants. Add new entries to the `TARGETS` array in `scripts/compile-skill.mjs`.
126130

127131
## Loop closure
128132

‎apps/playground/src/content/docs/kitchen-sink.mdx‎

Lines changed: 115 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Kitchen Sink
33
description: Every component, callout, code language, and styling primitive the theme ships, in one page. Doubles as visual regression bait.
44
---
55

6-
import { Card, CardGrid, LinkCard, Tabs, TabItem, Steps, Aside } from '@astrojs/starlight/components';
6+
import { Badge, Card, CardGrid, FileTree, Icon, LinkButton, LinkCard, Tabs, TabItem, Steps, Aside } from '@astrojs/starlight/components';
77
import Glitch from '@abstractdata/starlight-theme/components/Glitch.astro';
88

99
Every component, callout, code language, and styling primitive the theme ships — visible at once. Use this page to spot regressions after any visual change.
@@ -256,6 +256,120 @@ def apply(config: ThemeConfig) -> None:
256256
href="/migrating/"
257257
/>
258258

259+
## Expressive code features
260+
261+
These meta-features are part of Astro's expressive-code integration and are worth verifying in both dark and light modes.
262+
263+
### File title + line highlight
264+
265+
```ts title="src/plugin/index.ts" {3,7-9}
266+
import type { StarlightPlugin } from '@astrojs/starlight/types';
267+
268+
export interface Config {
269+
motion: 'full' | 'calm';
270+
credit: 'auto' | 'hide';
271+
version?: string;
272+
}
273+
274+
export default function plugin(opts: Config): StarlightPlugin {
275+
return { name: '@abstractdata/starlight-theme', hooks: {} };
276+
}
277+
```
278+
279+
### Diff markers
280+
281+
```ts del={2} ins={3}
282+
const motion = opts.motion ?? 'full';
283+
const motion = opts.motion ?? 'calm';
284+
```
285+
286+
### Line numbers
287+
288+
```bash showLineNumbers
289+
bun install
290+
bun dev
291+
bun run build
292+
bun run preview
293+
```
294+
295+
### Terminal frame
296+
297+
```bash frame="terminal"
298+
$ bun create @abstractdata/docs my-project
299+
┌─[ ABSTRACT DATA · DOCS ]─────────────────┐
300+
│ Scaffolding a branded Starlight site │
301+
└──────────────────────────────────────────┘
302+
303+
✓ my-project scaffolded.
304+
```
305+
306+
### Code + title together
307+
308+
```json title="scripts/ts-autodoc.json"
309+
{
310+
"entryPoints": ["../../my-lib/src/index.ts"],
311+
"tsconfig": "../../my-lib/tsconfig.json",
312+
"outputDir": "src/content/docs/api/ts"
313+
}
314+
```
315+
316+
## Badge
317+
318+
All five variants Starlight ships:
319+
320+
<Badge text="New" variant="tip" />
321+
<Badge text="Caution" variant="caution" />
322+
<Badge text="Danger" variant="danger" />
323+
<Badge text="Note" variant="note" />
324+
<Badge text="Success" variant="success" />
325+
326+
Badges inline with a heading:
327+
328+
### Feature <Badge text="Beta" variant="caution" /> <Badge text="v0.4+" variant="tip" />
329+
330+
## FileTree
331+
332+
```
333+
<FileTree>
334+
```
335+
336+
<FileTree>
337+
- packages/
338+
- starlight-theme/
339+
- src/
340+
- components/
341+
- Footer.astro
342+
- Glitch.astro
343+
- Hero.astro
344+
- SocialIcons.astro
345+
- **VersionPicker.astro** New in v0.4
346+
- styles/
347+
- theme.css
348+
- hud.css
349+
- index.ts The plugin entry
350+
- create-docs/
351+
- bin/
352+
- cli.js
353+
- apps/
354+
- playground/
355+
</FileTree>
356+
357+
## Icon
358+
359+
A sample of Starlight's built-in icon set (Heroicons + Phosphor subset):
360+
361+
<Icon name="rocket" /> <Icon name="star" /> <Icon name="approve-check" /> <Icon name="warning" /> <Icon name="information" /> <Icon name="github" /> <Icon name="external" />
362+
363+
Icon sizes:
364+
365+
<Icon name="rocket" size="1rem" /> <Icon name="rocket" size="1.5rem" /> <Icon name="rocket" size="2rem" />
366+
367+
## LinkButton
368+
369+
<LinkButton href="/quickstart/">Get started</LinkButton>
370+
<LinkButton href="/quickstart/" variant="secondary">Read the docs</LinkButton>
371+
<LinkButton href="https://github.com/Abstract-Data/abstract-data-doc-theme" variant="minimal" icon="github" target="_blank">View on GitHub</LinkButton>
372+
259373
## Blockquote
260374

261375
> "Documentation, engineered."

‎packages/create-docs/bin/cli.js‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,16 @@ try {
159159
cwd: targetDir,
160160
stdio: 'ignore',
161161
});
162-
} catch {
162+
} catch (err) {
163163
// Non-fatal — user can `git init` manually.
164+
const isNotFound =
165+
err?.code === 'ENOENT' ||
166+
/not found|no such file|command not found/i.test(err?.message ?? '');
167+
if (isNotFound) {
168+
log(`${c.dim} (git not found in PATH — run ${c.reset}${c.bold}git init${c.reset}${c.dim} inside ${c.reset}${c.bold}${projectName}/${c.reset}${c.dim} to start version-tracking your project)${c.reset}`);
169+
} else {
170+
log(`${c.dim} (git skipped: ${(err?.message ?? 'unknown error').split('\n')[0]} — run git init manually)${c.reset}`);
171+
}
164172
}
165173

166174
// ─── Done ─────────────────────────────────────────────────────────────

‎packages/starlight-theme/src/components/VersionPicker.astro‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@ if (!propVersions || propVersions.length === 0) {
126126
// No `docs` collection or no version frontmatter — render nothing.
127127
versions = [];
128128
}
129+
130+
// Warn at build time so developers know why the picker is absent.
131+
// Fires only in auto-discovery mode (no `versions` prop passed).
132+
if (versions.length === 0) {
133+
console.warn(
134+
'[VersionPicker] Auto-discovery found no pages with `version:` frontmatter. ' +
135+
'The picker will not render until at least one page has `version: "<tag>"` in its frontmatter. ' +
136+
'See the versioned-docs recipe or pass a `versions` prop manually to suppress this warning.',
137+
);
138+
}
129139
}
130140
131141
// ─── Detect current version from URL ──────────────────────────────────

‎packages/template/package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"dev": "astro dev",
99
"build": "astro check && astro build",
1010
"preview": "astro preview",
11-
"typecheck": "astro check"
11+
"typecheck": "astro check",
12+
"docs:python": "node scripts/build-python-docs.mjs",
13+
"docs:ts": "node scripts/build-ts-docs.mjs"
1214
},
1315
"dependencies": {
1416
"@abstractdata/starlight-theme": "workspace:*",

‎scripts/sync-theme-version.mjs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ const updated = cli.replace(
7272

7373
writeFileSync(CLI_FILE, updated);
7474

75+
// ─── Verify write ─────────────────────────────────────────────────────
76+
// Read back the file to confirm the regex replacement landed correctly.
77+
// Catches edge cases like filesystem write failures or a second THEME_VERSION
78+
// declaration shadowing the first.
79+
const readBack = readFileSync(CLI_FILE, 'utf8');
80+
const readBackMatch = readBack.match(/^const THEME_VERSION = '(\^?[\d.]+)';/m);
81+
if (!readBackMatch || readBackMatch[1] !== wantedRange) {
82+
die(
83+
`Post-write verification failed: expected THEME_VERSION = '${wantedRange}' ` +
84+
`but found '${readBackMatch?.[1] ?? '<no match>'}' in ${CLI_FILE}.\n` +
85+
` The file may have been written incorrectly — inspect it before publishing.`,
86+
);
87+
}
88+
7589
console.log(
7690
`${c.green}✓${c.reset} ${c.dim}Synced${c.reset} ${c.cyan}THEME_VERSION${c.reset}: ${beforeMatch[1]} ${c.dim}→${c.reset} ${c.gold}${wantedRange}${c.reset}`,
7791
);

0 commit comments

Comments
 (0)