Skip to content

Commit a72b06c

Browse files
nakasyouchatgpt-codex-connector[bot]Copilot
authored
feat(docs): automate block reference generation and sync (#40)
* feat(docs): automate block reference generation and sync - add multi-target block reference generator with --check mode - generate and align docs/skill reference markdown including overview - add CI check for generated references - add workflow to sync generated references on main push Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com> * fix * Update packages/skill/scripts/build-blocks.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix * Revert "Update packages/skill/scripts/build-blocks.ts" This reverts commit 6331ebf. --------- Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent f46e3a0 commit a72b06c

28 files changed

Lines changed: 454 additions & 192 deletions

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ jobs:
2323

2424
- name: Typecheck
2525
run: bun typecheck
26+
27+
- name: Check generated references
28+
run: bun run ref:check

.github/workflows/ref-sync.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Sync Generated References
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- packages/hikkaku/src/blocks/**
9+
- packages/skill/scripts/build-blocks.ts
10+
- packages/skill/package.json
11+
- package.json
12+
- bun.lock
13+
workflow_dispatch:
14+
15+
permissions:
16+
contents: write
17+
18+
jobs:
19+
sync:
20+
if: github.actor != 'github-actions[bot]'
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Bun
28+
uses: oven-sh/setup-bun@v2
29+
30+
- name: Install dependencies
31+
run: bun install --frozen-lockfile
32+
33+
- name: Generate references
34+
run: bun run ref:build
35+
36+
- name: Commit generated references
37+
run: |
38+
if git diff --quiet; then
39+
echo "No generated changes"
40+
exit 0
41+
fi
42+
43+
git config user.name "github-actions[bot]"
44+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
45+
46+
git add docs/reference/blocks packages/skill/hikkaku/rules/blocks
47+
git commit -m "chore: sync generated block references"
48+
git push

AGENTS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,8 @@
3737
```
3838
* You can use git command and gh command to commit, push and create PR.
3939
* Use "Squash and merge" to merge the PR on GitHub.
40+
41+
* commands you have to use before commiting:
42+
* `bun fmt`: apply formatting
43+
* `bun typecheck`: run type checking
44+
* `bun ref:build`: update the docs

docs/reference/blocks/control.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ title: Blocks - Control
33
impact: HIGH
44
---
55

6+
<!-- AUTO-GENERATED FILE. Do not edit manually.
7+
Edit packages/hikkaku/src/blocks and packages/skill/scripts/build-blocks.ts instead. -->
8+
69
# Control Blocks
710

811
## repeat(times, handler)
@@ -166,16 +169,15 @@ import { ifElse } from 'hikkaku/blocks'
166169
ifElse(true, () => {}, () => {})
167170
```
168171

169-
## match(...branches)
172+
## match(branches)
170173

171174
Builds chained if / else-if / else branching from condition-handler pairs.
172175

173-
Input: `...branches`.
176+
Input: `branches`.
174177

175178
Output: Scratch statement block definition that is appended to the current script stack.
176179

177-
* `branches: Array<[condition: PrimitiveSource<boolean>, handler: () => void]>` - sequence of condition/handler pairs evaluated in order
178-
* Optional trailing `defaultHandler: () => void` - handler called when no branch condition matches
180+
* `branches: Input value used by this block`
179181

180182
Example:
181183
```ts

docs/reference/blocks/data.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ title: Blocks - Data
33
impact: HIGH
44
---
55

6+
<!-- AUTO-GENERATED FILE. Do not edit manually.
7+
Edit packages/hikkaku/src/blocks and packages/skill/scripts/build-blocks.ts instead. -->
8+
69
# Variables & Lists
710

811
## getVariable(variable)

docs/reference/blocks/events.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ title: Blocks - Events
33
impact: HIGH
44
---
55

6+
<!-- AUTO-GENERATED FILE. Do not edit manually.
7+
Edit packages/hikkaku/src/blocks and packages/skill/scripts/build-blocks.ts instead. -->
8+
69
# Events
710

811
## whenFlagClicked(stack)

docs/reference/blocks/looks.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ title: Blocks - Looks
33
impact: HIGH
44
---
55

6+
<!-- AUTO-GENERATED FILE. Do not edit manually.
7+
Edit packages/hikkaku/src/blocks and packages/skill/scripts/build-blocks.ts instead. -->
8+
69
# Appearance
710

811
## say(message)

docs/reference/blocks/motion.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ title: Blocks - Motion
33
impact: HIGH
44
---
55

6+
<!-- AUTO-GENERATED FILE. Do not edit manually.
7+
Edit packages/hikkaku/src/blocks and packages/skill/scripts/build-blocks.ts instead. -->
8+
69
# Motion
710

811
## moveSteps(steps)

docs/reference/blocks/operator.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ title: Blocks - Operators
33
impact: HIGH
44
---
55

6+
<!-- AUTO-GENERATED FILE. Do not edit manually.
7+
Edit packages/hikkaku/src/blocks and packages/skill/scripts/build-blocks.ts instead. -->
8+
69
# Operators
710

811
## add(a, b)
@@ -20,7 +23,7 @@ Example:
2023
```ts
2124
import { add } from 'hikkaku/blocks'
2225

23-
add([[true, () => {}]] as any, undefined as any)
26+
add(1, 2)
2427
```
2528

2629
## subtract(a, b)
@@ -38,7 +41,7 @@ Example:
3841
```ts
3942
import { subtract } from 'hikkaku/blocks'
4043

41-
subtract([[true, () => {}]] as any, undefined as any)
44+
subtract(5, 3)
4245
```
4346

4447
## multiply(a, b)
@@ -56,7 +59,7 @@ Example:
5659
```ts
5760
import { multiply } from 'hikkaku/blocks'
5861

59-
multiply([[true, () => {}]] as any, undefined as any)
62+
multiply(3, 4)
6063
```
6164

6265
## divide(a, b)
@@ -74,7 +77,7 @@ Example:
7477
```ts
7578
import { divide } from 'hikkaku/blocks'
7679

77-
divide([[true, () => {}]] as any, undefined as any)
80+
divide(10, 2)
7881
```
7982

8083
## lt(a, b)
@@ -92,7 +95,7 @@ Example:
9295
```ts
9396
import { lt } from 'hikkaku/blocks'
9497

95-
lt([[true, () => {}]] as any, undefined as any)
98+
lt(1, 2)
9699
```
97100

98101
## equals(a, b)
@@ -110,7 +113,7 @@ Example:
110113
```ts
111114
import { equals } from 'hikkaku/blocks'
112115

113-
equals([[true, () => {}]] as any, undefined as any)
116+
equals(5, 5)
114117
```
115118

116119
## gt(a, b)
@@ -128,7 +131,7 @@ Example:
128131
```ts
129132
import { gt } from 'hikkaku/blocks'
130133

131-
gt([[true, () => {}]] as any, undefined as any)
134+
gt(10, 5)
132135
```
133136

134137
## and(a, b)
@@ -146,7 +149,7 @@ Example:
146149
```ts
147150
import { and } from 'hikkaku/blocks'
148151

149-
and([[true, () => {}]] as any, undefined as any)
152+
and(true, false)
150153
```
151154

152155
## or(a, b)
@@ -164,7 +167,7 @@ Example:
164167
```ts
165168
import { or } from 'hikkaku/blocks'
166169

167-
or([[true, () => {}]] as any, undefined as any)
170+
or(true, false)
168171
```
169172

170173
## not(operand)
@@ -181,7 +184,7 @@ Example:
181184
```ts
182185
import { not } from 'hikkaku/blocks'
183186

184-
not(undefined as any)
187+
not(false)
185188
```
186189

187190
## random(from, to)
@@ -217,7 +220,7 @@ Example:
217220
```ts
218221
import { join } from 'hikkaku/blocks'
219222

220-
join([[true, () => {}]] as any, undefined as any)
223+
join('Hello', 'World')
221224
```
222225

223226
## letterOf(letter, text)
@@ -288,7 +291,7 @@ Example:
288291
```ts
289292
import { mod } from 'hikkaku/blocks'
290293

291-
mod([[true, () => {}]] as any, undefined as any)
294+
mod(10, 3)
292295
```
293296

294297
## round(value)

docs/reference/blocks/overview.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ title: Blocks Overview
33
impact: HIGH
44
---
55

6+
<!-- AUTO-GENERATED FILE. Do not edit manually.
7+
Edit packages/hikkaku/src/blocks and packages/skill/scripts/build-blocks.ts instead. -->
8+
69
# List of Available Blocks
710

811
This document explains the function names, arguments, and behavior of exported helpers.
@@ -28,7 +31,7 @@ import { add, gotoXY } from 'hikkaku/blocks'
2831
- [Events](/reference/blocks/events)
2932
- [Looks](/reference/blocks/looks)
3033
- [Motion](/reference/blocks/motion)
31-
- [Operators](/reference/blocks/operator)
34+
- [Operator](/reference/blocks/operator)
3235
- [Procedures](/reference/blocks/procedures)
3336
- [Sensing](/reference/blocks/sensing)
3437
- [Sound](/reference/blocks/sound)

0 commit comments

Comments
 (0)