@@ -11,18 +11,35 @@ description: Get started with T-Ruby in 5 minutes
1111
1212Let's get you writing typed Ruby in under 5 minutes. This guide assumes you've already [ installed T-Ruby] ( /docs/getting-started/installation ) .
1313
14- ## Step 1: Create a Project Directory
14+ ## Step 1: Initialize a Project
15+
16+ Create a ` trbconfig.yml ` in your project root to configure source and output directories. You can generate one with ` trc --init ` :
17+
18+ ``` bash
19+ mkdir my-project && cd my-project
20+ trc --init
21+ ```
22+
23+ This creates:
24+ - ` trbconfig.yml ` - [ compiler configuration] ( /docs/cli/configuration )
25+ - ` src/ ` - source directory for .trb files
26+ - ` build/ ` - output directory for compiled files
27+
28+ ## Step 2: Start Watch Mode
29+
30+ Run watch mode for automatic compilation when files change:
1531
1632``` bash
17- mkdir my-truby-project
18- cd my-truby-project
33+ trc --watch
1934```
2035
21- ## Step 2: Write Your First T-Ruby File
36+ Keep this terminal open and continue to the next step.
37+
38+ ## Step 3: Write Your First T-Ruby File
2239
23- Create a file called ` hello.trb ` :
40+ Open a new terminal and create a file called ` src/ hello.trb` :
2441
25- ``` trb title="hello.trb"
42+ ``` trb title="src/ hello.trb"
2643# A simple typed function
2744def greet(name: String): String
2845 "Hello, #{name}!"
@@ -38,21 +55,9 @@ puts greet("World")
3855puts add(5, 3)
3956```
4057
41- ## Step 3: Compile
42-
43- Run the T-Ruby compiler:
44-
45- ``` bash
46- trc hello.trb
47- ```
48-
49- This creates two files in the ` build/ ` directory:
50-
51- ```
52- build/
53- ├── hello.rb # Compiled Ruby code
54- └── hello.rbs # Type signatures
55- ```
58+ When you save the file, watch mode automatically compiles it. Two files are created in the ` build/ ` directory:
59+ - ` hello.rb ` - compiled Ruby code
60+ - ` hello.rbs ` - type signatures
5661
5762## Step 4: Run Your Code
5863
@@ -120,16 +125,6 @@ Error: hello.trb:6:12
120125
121126The code won't compile until you fix the type error.
122127
123- ## Using Watch Mode
124-
125- For development, use watch mode to automatically recompile on changes:
126-
127- ``` bash
128- trc watch .
129- ```
130-
131- Now every time you save a ` .trb ` file, it's automatically compiled.
132-
133128## Quick Reference
134129
135130Here's a summary of the commands you'll use most:
@@ -141,7 +136,7 @@ Here's a summary of the commands you'll use most:
141136| ` trc . ` | Compile all .trb files in current directory |
142137| ` trc watch . ` | Watch and auto-compile on changes |
143138| ` trc check file.trb ` | Type-check without generating output |
144- | ` trc init ` | Initialize a new T-Ruby project |
139+ | ` trc -- init ` | Initialize a new T-Ruby project |
145140
146141## What's Next?
147142
@@ -164,7 +159,7 @@ class User
164159 @id: UserId
165160 @name: String
166161 @email: String
167- @active: Bool
162+ @active: Boolean
168163
169164 def initialize(id: UserId, name: String, email: String): void
170165 @id = id
@@ -181,7 +176,7 @@ class User
181176 @active = false
182177 end
183178
184- def active?: Bool
179+ def active?: Boolean
185180 @active
186181 end
187182end
0 commit comments