Skip to content

Commit 822073c

Browse files
committed
chore: developとのマージコンフリクトを解消
2 parents ce36f79 + cd1b524 commit 822073c

File tree

9 files changed

+281
-4
lines changed

9 files changed

+281
-4
lines changed

.github/workflows/docs.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ on:
66
paths:
77
- "packages/*/src/**"
88
- "packages/*/README.md"
9-
- "README.md"
10-
- "typedoc.json"
11-
- "typedoc.llms.json"
129
- "packages/*/typedoc.json"
10+
- "packages/*/typedoc.monorepo.json"
1311
- "packages/*/tsconfig.typedoc.json"
12+
- "typedoc.llms.json"
1413
- "scripts/build-llms.ts"
14+
- "scripts/build-versioned-docs.ts"
1515
- ".github/workflows/docs.yml"
1616
workflow_dispatch:
1717

@@ -29,13 +29,19 @@ jobs:
2929
runs-on: ubuntu-latest
3030
steps:
3131
- uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
fetch-tags: true
3235

3336
- uses: oven-sh/setup-bun@v2
3437
with:
3538
bun-version: latest
3639

3740
- run: bun install --frozen-lockfile
3841

42+
- name: Import versioned API docs from release tags
43+
run: bun run docs:api:import
44+
3945
- run: bun run docs:all
4046

4147
- uses: actions/upload-pages-artifact@v3

bun.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@
2828
"docs": "typedoc",
2929
"docs:watch": "typedoc --watch",
3030
"docs:llms": "typedoc --options typedoc.llms.json && bun scripts/build-llms.ts",
31-
"docs:all": "bun run docs && bun run docs:llms"
31+
"docs:api": "bun scripts/build-versioned-docs.ts",
32+
"docs:api:import": "bun scripts/import-release-docs.ts",
33+
"docs:all": "bun run docs:api && bun run docs:llms"
3234
},
3335
"devDependencies": {
3436
"@nx/js": "^22.4.5",
37+
"@r74tech/typedoc-plugin-monorepo-versions": "^1.0.1",
3538
"@swc-node/register": "^1.11.1",
3639
"@swc/core": "^1.15.11",
3740
"@types/bun": "latest",

packages/ast/typedoc.monorepo.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://typedoc.org/schema.json",
3+
"entryPoints": ["src/**/*.ts"],
4+
"tsconfig": "tsconfig.json",
5+
"validation": {
6+
"notExported": false
7+
},
8+
"versions": {
9+
"stable": "auto",
10+
"dev": "auto",
11+
"packageFile": "package.json",
12+
"makeRelativeLinks": true,
13+
"monorepo": {
14+
"name": "ast",
15+
"root": "../../docs"
16+
}
17+
},
18+
"plugin": ["@r74tech/typedoc-plugin-monorepo-versions"]
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://typedoc.org/schema.json",
3+
"entryPoints": ["src/**/*.ts"],
4+
"tsconfig": "tsconfig.typedoc.json",
5+
"validation": {
6+
"notExported": false
7+
},
8+
"versions": {
9+
"stable": "auto",
10+
"dev": "auto",
11+
"packageFile": "package.json",
12+
"makeRelativeLinks": true,
13+
"monorepo": {
14+
"name": "parser",
15+
"root": "../../docs"
16+
}
17+
},
18+
"plugin": ["@r74tech/typedoc-plugin-monorepo-versions"]
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://typedoc.org/schema.json",
3+
"entryPoints": ["src/**/*.ts"],
4+
"tsconfig": "tsconfig.typedoc.json",
5+
"validation": {
6+
"notExported": false
7+
},
8+
"versions": {
9+
"stable": "auto",
10+
"dev": "auto",
11+
"packageFile": "package.json",
12+
"makeRelativeLinks": true,
13+
"monorepo": {
14+
"name": "render",
15+
"root": "../../docs"
16+
}
17+
},
18+
"plugin": ["@r74tech/typedoc-plugin-monorepo-versions"]
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://typedoc.org/schema.json",
3+
"entryPoints": ["src/**/*.ts"],
4+
"tsconfig": "tsconfig.json",
5+
"validation": {
6+
"notExported": false
7+
},
8+
"versions": {
9+
"stable": "auto",
10+
"dev": "auto",
11+
"packageFile": "package.json",
12+
"makeRelativeLinks": true,
13+
"monorepo": {
14+
"name": "runtime",
15+
"root": "../../docs"
16+
}
17+
},
18+
"plugin": ["@r74tech/typedoc-plugin-monorepo-versions"]
19+
}

scripts/build-versioned-docs.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bun
2+
/**
3+
* Build versioned API docs for each package using typedoc-plugin-monorepo-versions.
4+
*
5+
* Usage:
6+
* bun scripts/build-versioned-docs.ts
7+
*/
8+
9+
import { $ } from "bun";
10+
import path from "path";
11+
import fs from "fs";
12+
13+
const PACKAGES = ["ast", "parser", "render", "runtime"];
14+
const ROOT = path.resolve(import.meta.dir, "..");
15+
16+
console.log(`Output: ${path.join(ROOT, "docs")}`);
17+
console.log(`Packages: ${PACKAGES.join(", ")}\n`);
18+
19+
for (const pkg of PACKAGES) {
20+
const pkgDir = path.join(ROOT, "packages", pkg);
21+
const configPath = path.join(pkgDir, "typedoc.monorepo.json");
22+
23+
if (!fs.existsSync(configPath)) {
24+
console.log(`Skipping ${pkg}: no typedoc.monorepo.json`);
25+
continue;
26+
}
27+
28+
console.log(`Building docs for ${pkg}...`);
29+
const result =
30+
await $`bunx typedoc --options ${configPath}`
31+
.cwd(pkgDir)
32+
.nothrow();
33+
34+
if (result.exitCode !== 0) {
35+
console.error(`Failed to build docs for ${pkg} (exit code ${result.exitCode})`);
36+
} else {
37+
console.log(`Done: ${pkg}\n`);
38+
}
39+
}
40+
41+
console.log("All packages processed.");

scripts/import-release-docs.ts

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/usr/bin/env bun
2+
/**
3+
* Import docs from existing release tags.
4+
* Checks out each release tag, builds docs for the corresponding package,
5+
* then returns to the original branch.
6+
*
7+
* Usage:
8+
* bun scripts/import-release-docs.ts
9+
*
10+
* This is a one-time migration script. Run it to populate versioned docs
11+
* from existing release history.
12+
*/
13+
14+
import { $ } from "bun";
15+
import path from "path";
16+
import fs from "fs";
17+
18+
const ROOT = path.resolve(import.meta.dir, "..");
19+
20+
// Package name mapping: tag prefix → directory name
21+
const PKG_MAP: Record<string, string> = {
22+
"@wdprlib/ast": "ast",
23+
"@wdprlib/parser": "parser",
24+
"@wdprlib/render": "render",
25+
"@wdprlib/runtime": "runtime",
26+
};
27+
28+
// Get current branch to return to
29+
const currentBranch = (await $`git rev-parse --abbrev-ref HEAD`.cwd(ROOT).text()).trim();
30+
console.log(`Current branch: ${currentBranch}\n`);
31+
32+
// Get all tags
33+
const tagsRaw = (await $`git tag -l`.cwd(ROOT).text()).trim();
34+
const tags = tagsRaw.split("\n").filter(Boolean);
35+
36+
// Parse tags into package+version pairs
37+
const releases: { tag: string; pkg: string; version: string }[] = [];
38+
for (const tag of tags) {
39+
for (const [prefix, dir] of Object.entries(PKG_MAP)) {
40+
if (tag.startsWith(`${prefix}@`)) {
41+
const version = tag.slice(prefix.length + 1);
42+
releases.push({ tag, pkg: dir, version });
43+
}
44+
}
45+
}
46+
47+
// Sort by package then version
48+
releases.sort((a, b) => a.pkg.localeCompare(b.pkg) || a.version.localeCompare(b.version));
49+
50+
console.log(`Found ${releases.length} release tags:\n`);
51+
for (const r of releases) {
52+
console.log(` ${r.tag}${r.pkg}@${r.version}`);
53+
}
54+
console.log();
55+
56+
const results: { tag: string; status: string }[] = [];
57+
58+
for (const { tag, pkg, version } of releases) {
59+
console.log(`--- ${tag} ---`);
60+
61+
// Checkout the tag
62+
const checkout = await $`git checkout ${tag} --force`.cwd(ROOT).nothrow().quiet();
63+
if (checkout.exitCode !== 0) {
64+
console.error(` Failed to checkout ${tag}`);
65+
results.push({ tag, status: "checkout failed" });
66+
continue;
67+
}
68+
69+
// Install dependencies (might differ per tag)
70+
const install = await $`bun install --frozen-lockfile`.cwd(ROOT).nothrow().quiet();
71+
if (install.exitCode !== 0) {
72+
// Try without frozen lockfile
73+
await $`bun install`.cwd(ROOT).nothrow().quiet();
74+
}
75+
76+
const pkgDir = path.join(ROOT, "packages", pkg);
77+
78+
// Check if source exists at this tag
79+
if (!fs.existsSync(path.join(pkgDir, "src"))) {
80+
console.log(` Skipping: packages/${pkg}/src not found at ${tag}`);
81+
results.push({ tag, status: "no src" });
82+
continue;
83+
}
84+
85+
// Write the monorepo config (it may not exist at this tag)
86+
const configContent = JSON.stringify(
87+
{
88+
$schema: "https://typedoc.org/schema.json",
89+
entryPoints: ["src/**/*.ts"],
90+
tsconfig: fs.existsSync(path.join(pkgDir, "tsconfig.typedoc.json"))
91+
? "tsconfig.typedoc.json"
92+
: "tsconfig.json",
93+
plugin: ["@r74tech/typedoc-plugin-monorepo-versions"],
94+
validation: {
95+
notExported: false,
96+
},
97+
versions: {
98+
stable: "auto",
99+
dev: "auto",
100+
packageFile: "package.json",
101+
makeRelativeLinks: true,
102+
monorepo: {
103+
name: pkg,
104+
root: "../../docs",
105+
},
106+
},
107+
},
108+
null,
109+
"\t",
110+
);
111+
const configPath = path.join(pkgDir, "typedoc.monorepo.json");
112+
fs.writeFileSync(configPath, configContent);
113+
114+
// Build docs
115+
const build =
116+
await $`bunx typedoc --options ${configPath}`
117+
.cwd(pkgDir)
118+
.nothrow();
119+
120+
if (build.exitCode !== 0) {
121+
console.error(` Build failed for ${tag}`);
122+
results.push({ tag, status: "build failed" });
123+
} else {
124+
console.log(` Success: ${pkg}@${version}\n`);
125+
results.push({ tag, status: "ok" });
126+
}
127+
}
128+
129+
// Return to original branch
130+
await $`git checkout ${currentBranch} --force`.cwd(ROOT);
131+
await $`bun install`.cwd(ROOT).nothrow().quiet();
132+
133+
console.log("\n=== Results ===");
134+
for (const { tag, status } of results) {
135+
const icon = status === "ok" ? "[OK]" : "[FAIL]";
136+
console.log(` ${icon} ${tag}: ${status}`);
137+
}
138+
139+
const ok = results.filter((r) => r.status === "ok").length;
140+
console.log(`\n${ok}/${results.length} tags imported successfully.`);

0 commit comments

Comments
 (0)