Skip to content

Commit ceddab9

Browse files
committed
docs: auto-generate schema docs and remove from README.md
It was a huge time sink manually maintaining the schema tables in README.md, and resolving resulting merge conflicts. So instead auto-generate these into SCHEMAS.md.
1 parent 3ebad48 commit ceddab9

File tree

10 files changed

+719
-320
lines changed

10 files changed

+719
-320
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hypercerts-org/lexicon": minor
3+
---
4+
5+
Move schema documentation tables from README.md to auto-generated SCHEMAS.md to reduce git merge conflicts. The SCHEMAS.md file is now auto-generated from lexicon definitions and included in the distributed package.

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Custom merge driver for auto-generated files
2+
# When SCHEMAS.md has conflicts, regenerate it and use the result
3+
SCHEMAS.md merge=schemas

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ dist/
44
generated/
55
pnpm-lock.yaml
66
/tmp/
7+
lexicons.md

AGENTS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ and type declaration files in `dist/`.
5858

5959
## Development Commands
6060

61+
**⚠️ IMPORTANT FOR AI AGENTS**: Always run scripts through npm scripts (e.g., `npm run gen-schemas-md`) rather than executing Node.js files directly (e.g., `node scripts/generate-schemas.js`). This ensures proper environment setup and consistency with the project's workflow.
62+
6163
### Code Generation
6264

6365
```bash
@@ -70,6 +72,9 @@ npm run gen-index
7072
# Build distributable bundles
7173
npm run build
7274

75+
# Generate SCHEMAS.md from lexicon definitions
76+
npm run gen-schemas-md
77+
7378
# Generate markdown documentation from lexicons
7479
npm run gen-md
7580

@@ -205,6 +210,7 @@ lexicons/ # Source of truth (committed)
205210
scripts/ # Build scripts (committed)
206211
create-shims.sh # Generate type shims for external lexicons
207212
generate-exports.js # Auto-generate generated/exports.ts
213+
generate-schemas.js # Auto-generate SCHEMAS.md from lexicons
208214
209215
generated/ # Auto-generated (gitignored)
210216
index.ts # Generated client (not exposed)

README.md

Lines changed: 6 additions & 317 deletions
Large diffs are not rendered by default.

SCHEMAS.md

Lines changed: 295 additions & 0 deletions
Large diffs are not rendered by default.

lexicons/org/hypercerts/claim/evaluation.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
},
5858
"measurements": {
5959
"type": "array",
60-
"description": "Optional references to the measurements that contributed to this evaluation. The record(s) referenced must conform with the lexicon org.hypercerts.claim.measurement ",
60+
"description": "Optional references to the measurements that contributed to this evaluation. The record(s) referenced must conform with the lexicon org.hypercerts.claim.measurement",
6161
"items": {
6262
"type": "ref",
6363
"ref": "com.atproto.repo.strongRef"

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"files": [
2323
"dist",
2424
"lexicons",
25+
"SCHEMAS.md",
2526
"CHANGELOG.md"
2627
],
2728
"keywords": [
@@ -38,11 +39,12 @@
3839
},
3940
"scripts": {
4041
"list": "find ./lexicons -name '*.json'",
41-
"check": "npm run gen-api && npm run lint && npm run typecheck && npm run build && npm run test",
42+
"check": "npm run gen-schemas-md && npm run gen-api && npm run lint && npm run typecheck && npm run build && npm run test",
4243
"build": "rollup -c && npm run build:types",
4344
"build:types": "tsc --project tsconfig.build.json",
4445
"gen-api": "find ./lexicons -name '*.json' | xargs lex gen-api --yes ./generated && ./scripts/create-shims.sh && npm run gen-index",
4546
"gen-md": "find ./lexicons -name '*.json' | xargs lex gen-md --yes ./lexicons.md",
47+
"gen-schemas-md": "node ./scripts/generate-schemas.js",
4648
"//gen-ts": "UNUSED - use gen-api instead",
4749
"gen-ts": "find ./lexicons -name '*.json' | xargs lex gen-ts-obj > generated/DO-NOT-USE-lexicons.ts",
4850
"gen-index": "node ./scripts/generate-exports.js",
@@ -59,7 +61,7 @@
5961
"changeset": "changeset",
6062
"version-packages": "changeset version && npm install --package-lock-only",
6163
"release": "npm run check && changeset publish",
62-
"prepare": "husky"
64+
"prepare": "husky && ./scripts/setup-merge-driver.sh"
6365
},
6466
"dependencies": {
6567
"@atcute/leaflet": "^1.0.15",

0 commit comments

Comments
 (0)