Skip to content

Commit 04ba3ec

Browse files
committed
docs: Array<T> 문법을 T[] 형태로 변경
- 영어 문서 (docs/) Array<> → [] 변환 - 한국어 문서 (i18n/ko/) Array<> → [] 변환 - Array<T>.new 생성자 호출은 유지 - RBS 문법 (Array[T])은 변경 없음
1 parent 8027cb1 commit 04ba3ec

39 files changed

+602
-520
lines changed

.github/workflows/sync-release.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Sync Release Docs
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Released version'
8+
required: true
9+
base_tag:
10+
description: 'Base tag (5 releases ago)'
11+
required: true
12+
recent_tags:
13+
description: 'Recent 5 tags (comma-separated)'
14+
required: true
15+
changed_files:
16+
description: 'Changed files since base tag'
17+
required: true
18+
19+
permissions:
20+
contents: write
21+
22+
jobs:
23+
update-docs:
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: Fetch t-ruby source
30+
run: |
31+
git clone https://github.com/type-ruby/t-ruby.git /tmp/t-ruby
32+
cd /tmp/t-ruby
33+
git fetch --tags
34+
35+
- name: Generate diff context (last 5 releases)
36+
run: |
37+
cd /tmp/t-ruby
38+
git diff ${{ inputs.base_tag }}..v${{ inputs.version }} > /tmp/release_diff.txt
39+
git log ${{ inputs.base_tag }}..v${{ inputs.version }} --oneline > /tmp/commit_log.txt
40+
git show v${{ inputs.version }}:CHANGELOG.md > /tmp/current_changelog.txt
41+
42+
- name: Update docs with Claude Code
43+
uses: anthropics/claude-code-action@v1
44+
with:
45+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
46+
prompt: |
47+
t-ruby v${{ inputs.version }}이 릴리스되었습니다.
48+
49+
## 컨텍스트
50+
- 컴파일러 소스: /tmp/t-ruby
51+
- 현재 저장소: 문서 사이트 (t-ruby.github.io)
52+
- 현재 릴리스: v${{ inputs.version }}
53+
- 분석 범위: 최근 5개 릴리스 (${{ inputs.recent_tags }})
54+
- 비교 시작점: ${{ inputs.base_tag }}
55+
- 변경된 파일 목록: ${{ inputs.changed_files }}
56+
- 상세 diff: /tmp/release_diff.txt
57+
- 커밋 로그: /tmp/commit_log.txt
58+
- 현재 CHANGELOG: /tmp/current_changelog.txt
59+
60+
## 작업
61+
1. static/version.json의 compiler 버전을 ${{ inputs.version }}으로 업데이트
62+
2. /tmp/t-ruby/CHANGELOG.md를 docs/project/changelog.md로 동기화
63+
3. 최근 5개 릴리스의 변경사항을 분석하여 문서 업데이트:
64+
- 새 기능 추가 → 관련 문서 생성/수정
65+
- API 변경 → 레퍼런스 업데이트
66+
- 기능 제거 → 문서 삭제 또는 deprecated 표시
67+
- 이전 릴리스에서 누락된 문서 변경도 보완
68+
4. 다국어(i18n/ko, i18n/ja) 문서도 필요시 업데이트
69+
70+
변경사항이 있으면 커밋해주세요.
71+
72+
- name: Push changes
73+
run: |
74+
git config user.name "github-actions[bot]"
75+
git config user.email "github-actions[bot]@users.noreply.github.com"
76+
git add -A
77+
if git diff --staged --quiet; then
78+
echo "No changes to commit"
79+
else
80+
git commit -m "docs: sync v${{ inputs.version }} release"
81+
git push origin main
82+
fi

docs/cli/compiler-options.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ In strict mode:
3939

4040
```trb
4141
# Strict mode requires full typing
42-
def process(data: Array<String>): Hash<String, Integer>
42+
def process(data: String[]): Hash<String, Integer>
4343
@count: Integer = 0
4444
result: Hash<String, Integer> = {}
4545
result
@@ -138,7 +138,7 @@ trc compile --no-unchecked-indexed-access src/
138138

139139
```trb
140140
# Error with --no-unchecked-indexed-access
141-
users: Array<User> = get_users()
141+
users: User[] = get_users()
142142
user = users[0] # Error: might be nil
143143
144144
# Must check first

docs/cli/configuration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ compiler:
256256

257257
```trb
258258
# Required in strict mode
259-
def process(data: Array<String>): Hash<String, Integer>
259+
def process(data: String[]): Hash<String, Integer>
260260
@count: Integer = 0
261261
result: Hash<String, Integer> = {}
262262
# ...
@@ -272,7 +272,7 @@ end
272272

273273
```trb
274274
# OK in standard mode
275-
def process(data: Array<String>): Hash<String, Integer>
275+
def process(data: String[]): Hash<String, Integer>
276276
@count: Integer = 0
277277
result = {} # Type inferred
278278
# ...
@@ -412,7 +412,7 @@ end
412412

413413
```trb
414414
# Error when no_unchecked_indexed_access: true
415-
users: Array<User> = get_users()
415+
users: User[] = get_users()
416416
user = users[0] # Error: might be nil
417417
418418
# OK - Check first

docs/getting-started/understanding-trb-files.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Let's create a Calculator class:
134134
```trb title="calculator.trb"
135135
class Calculator
136136
# Instance variable with type annotation
137-
@history: Array<String>
137+
@history: String[]
138138
139139
def initialize: void
140140
@history = []
@@ -168,7 +168,7 @@ class Calculator
168168
result
169169
end
170170
171-
def history: Array<String>
171+
def history: String[]
172172
@history.dup
173173
end
174174
@@ -272,7 +272,7 @@ def find(id: Integer): User? # Shorthand
272272
### Block Parameters
273273

274274
```rbs
275-
def each_item(items: Array<String>, &block: (String) -> void): void
275+
def each_item(items: String[], &block: (String) -> void): void
276276
items.each(&block)
277277
end
278278
@@ -314,7 +314,7 @@ Error: calculator.trb:2:15
314314

315315
1. **Start with public APIs** - Type your public methods first
316316
2. **Use type aliases** - Make complex types readable
317-
3. **Prefer specific types** - `Array<String>` over `Array`
317+
3. **Prefer specific types** - `String[]` over `Array`
318318
4. **Document with types** - Types serve as documentation
319319

320320
## Next Steps

docs/introduction/t-ruby-vs-others.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class Calculator
128128
a + b
129129
end
130130
131-
def join(items: Array<String>): String
131+
def join(items: String[]): String
132132
items.join(", ")
133133
end
134134
end
@@ -217,7 +217,7 @@ end
217217
- Type erasure (no runtime overhead)
218218
- Gradual typing support
219219
- Union types (`String | Integer`)
220-
- Generic types (`Array<T>`)
220+
- Generic types (`T[]`)
221221
- Interface definitions
222222

223223
### Differences

docs/introduction/what-is-t-ruby.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def calculate(x: Integer, y: Integer): Integer
5656
end
5757
5858
# Partially typed (return type inferred)
59-
def process(data: Array<String>)
59+
def process(data: String[])
6060
data.map(&:upcase)
6161
end
6262

docs/introduction/why-t-ruby.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def transform(data, options = {})
7272
end
7373
7474
# With types - crystal clear
75-
def transform(data: Array<Record>, options: TransformOptions?): TransformResult
75+
def transform(data: Record[], options: TransformOptions?): TransformResult
7676
# ...
7777
end
7878
```
@@ -148,7 +148,7 @@ Types add some overhead. For very small scripts or quick prototypes, untyped Rub
148148
puts "Hello, #{ARGV[0]}!"
149149
150150
# No need for:
151-
# def main(args: Array<String>): void
151+
# def main(args: String[]): void
152152
# puts "Hello, #{args[0]}!"
153153
# end
154154
```

docs/learn/advanced/intersection-types.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ end
162162
163163
interface Validatable
164164
def valid?: Boolean
165-
def errors: Array<String>
165+
def errors: String[]
166166
end
167167
168168
interface Persistable
@@ -179,7 +179,7 @@ class Article
179179
180180
@title: String
181181
@content: String
182-
@errors: Array<String>
182+
@errors: String[]
183183
184184
def initialize(title: String, content: String): void
185185
@title = title
@@ -203,7 +203,7 @@ class Article
203203
@errors.empty?
204204
end
205205
206-
def errors: Array<String>
206+
def errors: String[]
207207
@errors
208208
end
209209
@@ -248,7 +248,7 @@ type BaseEntity = Identifiable & Timestamped
248248
type DeletableEntity = Identifiable & Timestamped & SoftDeletable
249249
250250
class Repository<T: BaseEntity>
251-
@items: Array<T>
251+
@items: T[]
252252
253253
def initialize: void
254254
@items = []
@@ -258,25 +258,25 @@ class Repository<T: BaseEntity>
258258
@items.find { |item| item.id == id }
259259
end
260260
261-
def all: Array<T>
261+
def all: T[]
262262
@items.dup
263263
end
264264
265-
def recent(limit: Integer = 10): Array<T>
265+
def recent(limit: Integer = 10): T[]
266266
@items.sort_by { |item| item.created_at }.reverse.take(limit)
267267
end
268268
end
269269
270270
class SoftDeleteRepository<T: DeletableEntity> < Repository<T>
271-
def all: Array<T>
271+
def all: T[]
272272
@items.reject { |item| item.deleted? }
273273
end
274274
275-
def with_deleted: Array<T>
275+
def with_deleted: T[]
276276
@items.dup
277277
end
278278
279-
def only_deleted: Array<T>
279+
def only_deleted: T[]
280280
@items.select { |item| item.deleted? }
281281
end
282282
end
@@ -428,7 +428,7 @@ end
428428
429429
# Collection that requires multiple capabilities
430430
class ValidatedCollection<T: Identifiable & Validatable>
431-
@items: Array<T>
431+
@items: T[]
432432
433433
def initialize: void
434434
@items = []
@@ -447,11 +447,11 @@ class ValidatedCollection<T: Identifiable & Validatable>
447447
@items.find { |item| item.id == id }
448448
end
449449
450-
def all_valid: Array<T>
450+
def all_valid: T[]
451451
@items.select { |item| item.valid? }
452452
end
453453
454-
def all_invalid: Array<T>
454+
def all_invalid: T[]
455455
@items.reject { |item| item.valid? }
456456
end
457457
end
@@ -638,7 +638,7 @@ class FormBuilder
638638
implements Buildable, Validatable, Resettable
639639
640640
@fields: Hash<String, String>
641-
@errors: Array<String>
641+
@errors: String[]
642642
643643
def initialize: void
644644
@fields = {}
@@ -690,9 +690,9 @@ class WorkflowState
690690
implements State, Transitionable, Observable
691691
692692
@name: String
693-
@allowed_transitions: Array<String>
693+
@allowed_transitions: String[]
694694
695-
def initialize(name: String, allowed_transitions: Array<String>): void
695+
def initialize(name: String, allowed_transitions: String[]): void
696696
@name = name
697697
@allowed_transitions = allowed_transitions
698698
end

docs/learn/advanced/type-aliases.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def create_user(data: Hash<Symbol, String | Integer | Boolean>): Integer
3737
end
3838
3939
# Hard to understand what this represents
40-
users: Array<Hash<Symbol, String | Integer | Boolean>> = []
40+
users: Hash<Symbol, String | Integer | Boolean>[] = []
4141
```
4242

4343
### With Type Aliases
@@ -60,7 +60,7 @@ def create_user(data: UserData): Integer
6060
end
6161
6262
# Clear what this represents
63-
users: Array<UserData> = []
63+
users: UserData[] = []
6464
```
6565

6666
## Basic Type Aliases
@@ -261,10 +261,10 @@ type Quantity = Integer
261261
262262
type Product = Hash<Symbol, ProductId | String | Price>
263263
type OrderItem = Hash<Symbol, ProductId | Quantity | Price>
264-
type Order = Hash<Symbol, OrderId | CustomerId | Array<OrderItem> | String>
264+
type Order = Hash<Symbol, OrderId | CustomerId | OrderItem[] | String>
265265
266266
# Using domain types
267-
def create_order(customer_id: CustomerId, items: Array<OrderItem>): Order
267+
def create_order(customer_id: CustomerId, items: OrderItem[]): Order
268268
{
269269
id: generate_order_id(),
270270
customer_id: customer_id,
@@ -273,7 +273,7 @@ def create_order(customer_id: CustomerId, items: Array<OrderItem>): Order
273273
}
274274
end
275275
276-
def calculate_total(items: Array<OrderItem>): Price
276+
def calculate_total(items: OrderItem[]): Price
277277
items.reduce(0.0) { |sum, item| sum + item[:price] * item[:quantity] }
278278
end
279279
```
@@ -356,15 +356,15 @@ type Supplier<T> = Proc<T>
356356
type Comparator<T> = Proc<T, T, Integer>
357357
358358
# Using function types
359-
def filter<T>(array: Array<T>, predicate: Predicate<T>): Array<T>
359+
def filter<T>(array: T[], predicate: Predicate<T>): T[]
360360
array.select { |item| predicate.call(item) }
361361
end
362362
363-
def map<T, U>(array: Array<T>, mapper: Mapper<T, U>): Array<U>
363+
def map<T, U>(array: T[], mapper: Mapper<T, U>): U[]
364364
array.map { |item| mapper.call(item) }
365365
end
366366
367-
def for_each<T>(array: Array<T>, consumer: Consumer<T>): void
367+
def for_each<T>(array: T[], consumer: Consumer<T>): void
368368
array.each { |item| consumer.call(item) }
369369
end
370370
@@ -426,7 +426,7 @@ In the future, T-Ruby will support recursive type aliases for tree structures an
426426
# Tree structure
427427
type TreeNode<T> = {
428428
value: T,
429-
children: Array<TreeNode<T>>
429+
children: TreeNode<T>[]
430430
}
431431
432432
# Linked list

docs/learn/basics/type-annotations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ member_price = calculate_discount(100.0, 10, true)
227227
You can also annotate block parameters:
228228

229229
```trb title="blocks.trb"
230-
def process_numbers(numbers: Array<Integer>)
230+
def process_numbers(numbers: Integer[])
231231
numbers.map do |n: Integer|
232232
n * 2
233233
end

0 commit comments

Comments
 (0)