Skip to content

Commit 27165bf

Browse files
committed
chore: add DocsBadge to all documentation pages
- Add DocsBadge component to all docs (en, ja, ko) - Add VerifiedBadge and DocsBadge component source files - Remove moon.yml (moved to t-ruby monorepo)
1 parent 8802e28 commit 27165bf

File tree

146 files changed

+2574
-2150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+2574
-2150
lines changed

docs/cli/commands.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ title: Commands
44
description: trc CLI commands reference
55
---
66

7+
<DocsBadge />
8+
9+
710
# Commands
811

912
The `trc` command-line interface is the primary tool for working with T-Ruby. It compiles `.trb` files to Ruby, type-checks your code, and generates RBS signatures.

docs/cli/compiler-options.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ title: Compiler Options
44
description: All available compiler options
55
---
66

7+
<DocsBadge />
8+
9+
710
# Compiler Options
811

912
T-Ruby's compiler provides extensive options to control compilation, type checking, and code generation. This reference covers all available command-line flags and their effects.
@@ -34,7 +37,7 @@ In strict mode:
3437
- No implicit `any` types
3538
- Strict nil checking enabled
3639

37-
```ruby
40+
```trb
3841
# Strict mode requires full typing
3942
def process(data: Array<String>): Hash<String, Integer>
4043
@count: Integer = 0
@@ -73,7 +76,7 @@ Disallow implicit `any` types.
7376
trc compile --no-implicit-any src/
7477
```
7578

76-
```ruby
79+
```trb
7780
# Error with --no-implicit-any
7881
def process(data) # Error: implicit any
7982
# ...
@@ -93,7 +96,7 @@ Enable strict nil checking.
9396
trc compile --strict-nil src/
9497
```
9598

96-
```ruby
99+
```trb
97100
# Error with --strict-nil
98101
def find_user(id: Integer): User # Error: might return nil
99102
users.find { |u| u.id == id }
@@ -113,7 +116,7 @@ Warn on unused variables and parameters.
113116
trc compile --no-unused-vars src/
114117
```
115118

116-
```ruby
119+
```trb
117120
# Warning with --no-unused-vars
118121
def calculate(x: Integer, y: Integer): Integer
119122
x * 2 # Warning: y is unused
@@ -133,7 +136,7 @@ Require checks before array/hash access.
133136
trc compile --no-unchecked-indexed-access src/
134137
```
135138

136-
```ruby
139+
```trb
137140
# Error with --no-unchecked-indexed-access
138141
users: Array<User> = get_users()
139142
user = users[0] # Error: might be nil
@@ -152,7 +155,7 @@ Require explicit return types for all functions.
152155
trc compile --require-return-types src/
153156
```
154157

155-
```ruby
158+
```trb
156159
# Error with --require-return-types
157160
def calculate(x: Integer) # Error: missing return type
158161
x * 2

docs/cli/configuration.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ title: Configuration
44
description: T-Ruby configuration file reference
55
---
66

7+
<DocsBadge />
8+
9+
710
# Configuration
811

912
T-Ruby uses a `trc.yaml` file to configure compiler behavior, source files, output locations, and type checking rules. This reference covers all available configuration options.
@@ -251,7 +254,7 @@ compiler:
251254
- No implicit `any` types allowed
252255
- Strict nil checking enabled
253256

254-
```ruby
257+
```trb
255258
# Required in strict mode
256259
def process(data: Array<String>): Hash<String, Integer>
257260
@count: Integer = 0
@@ -267,7 +270,7 @@ end
267270
- Local variables can be inferred
268271
- Warns on implicit `any`
269272

270-
```ruby
273+
```trb
271274
# OK in standard mode
272275
def process(data: Array<String>): Hash<String, Integer>
273276
@count: Integer = 0
@@ -314,7 +317,7 @@ Supported versions: `"2.7"`, `"3.0"`, `"3.1"`, `"3.2"`, `"3.3"`
314317

315318
Example - Pattern matching:
316319

317-
```ruby
320+
```trb
318321
# Input (.trb)
319322
case value
320323
in { name: String => n }
@@ -369,7 +372,7 @@ compiler:
369372
370373
**no_implicit_any**
371374
372-
```ruby
375+
```trb
373376
# Error when no_implicit_any: true
374377
def process(data) # Error: implicit 'any' type
375378
# ...
@@ -383,7 +386,7 @@ end
383386

384387
**no_unused_vars**
385388

386-
```ruby
389+
```trb
387390
# Warning when no_unused_vars: true
388391
def calculate(x: Integer, y: Integer): Integer
389392
result = x * 2 # Warning: 'y' is unused
@@ -393,7 +396,7 @@ end
393396

394397
**strict_nil**
395398

396-
```ruby
399+
```trb
397400
# Error when strict_nil: true
398401
def find_user(id: Integer): User # Error: might return nil
399402
users.find { |u| u.id == id }
@@ -407,7 +410,7 @@ end
407410

408411
**no_unchecked_indexed_access**
409412

410-
```ruby
413+
```trb
411414
# Error when no_unchecked_indexed_access: true
412415
users: Array<User> = get_users()
413416
user = users[0] # Error: might be nil

docs/getting-started/editor-setup.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ title: Editor Setup
44
description: Set up VS Code, Neovim, and other editors for T-Ruby
55
---
66

7+
<DocsBadge />
8+
9+
710
# Editor Setup
811

912
Get the best T-Ruby development experience by configuring your editor with syntax highlighting, type checking, and autocomplete.

docs/getting-started/first-trb-file.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ title: Your First .trb File
44
description: Create and compile your first T-Ruby file
55
---
66

7+
<DocsBadge />
8+
9+
710
# Your First .trb File
811

912
This guide takes you through creating a T-Ruby file step by step, explaining each concept as we go.
@@ -19,7 +22,7 @@ A `.trb` file is a T-Ruby source file. It's essentially Ruby code with type anno
1922

2023
Let's create a file called `calculator.trb` that implements a simple calculator:
2124

22-
```ruby title="calculator.trb"
25+
```trb title="calculator.trb"
2326
# calculator.trb - A simple typed calculator
2427
2528
# Basic arithmetic operations with type annotations
@@ -44,7 +47,7 @@ end
4447

4548
Let's break down the syntax:
4649

47-
```ruby
50+
```trb
4851
def add(a: Integer, b: Integer): Integer
4952
# ^^^ ^ ^^^^^^^ ^ ^^^^^^^ ^^^^^^^
5053
# | | | | | |
@@ -60,7 +63,7 @@ def add(a: Integer, b: Integer): Integer
6063

6164
Let's expand our calculator with more advanced features:
6265

63-
```ruby title="calculator.trb"
66+
```trb title="calculator.trb"
6467
# Type alias for cleaner code
6568
type Number = Integer | Float
6669
@@ -97,7 +100,7 @@ end
97100

98101
The `|` operator creates a union type:
99102

100-
```ruby
103+
```trb
101104
type Number = Integer | Float # Can be Integer OR Float
102105
103106
def safe_divide(a: Number, b: Number): Float | nil
@@ -111,7 +114,7 @@ end
111114

112115
The `<T>` syntax defines a generic type parameter:
113116

114-
```ruby
117+
```trb
115118
def max<T: Comparable>(a: T, b: T): T
116119
# ^^ ^^^^^^^^^^
117120
# | |
@@ -128,7 +131,7 @@ max("a", "b") # T is String
128131

129132
Let's create a Calculator class:
130133

131-
```ruby title="calculator.trb"
134+
```trb title="calculator.trb"
132135
class Calculator
133136
# Instance variable with type annotation
134137
@history: Array<String>
@@ -229,7 +232,7 @@ class Calculator
229232
end
230233
```
231234

232-
```ruby title="build/calculator.rbs"
235+
```rbs title="build/calculator.rbs"
233236
type Number = Integer | Float
234237
235238
class Calculator
@@ -249,7 +252,7 @@ end
249252

250253
### Optional Parameters
251254

252-
```ruby
255+
```trb
253256
def greet(name: String, greeting: String = "Hello"): String
254257
"#{greeting}, #{name}!"
255258
end
@@ -260,15 +263,15 @@ greet("Alice", "Hi") # "Hi, Alice!"
260263

261264
### Nullable Types (Optional Shorthand)
262265

263-
```ruby
266+
```trb
264267
# These are equivalent:
265268
def find(id: Integer): User | nil
266269
def find(id: Integer): User? # Shorthand
267270
```
268271

269272
### Block Parameters
270273

271-
```ruby
274+
```rbs
272275
def each_item(items: Array<String>, &block: (String) -> void): void
273276
items.each(&block)
274277
end

docs/getting-started/installation.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ title: Installation
44
description: How to install T-Ruby
55
---
66

7+
<DocsBadge />
8+
9+
710
# Installation
811

912
This guide will help you install T-Ruby on your system. T-Ruby requires Ruby 3.0 or later.

docs/getting-started/project-configuration.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ title: Project Configuration
44
description: Configure T-Ruby for your project
55
---
66

7+
<DocsBadge />
8+
9+
710
# Project Configuration
811

912
For larger projects, T-Ruby uses a configuration file to manage compiler options, paths, and behavior.

docs/getting-started/quick-start.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ title: Quick Start
44
description: Get started with T-Ruby in 5 minutes
55
---
66

7+
<DocsBadge />
8+
9+
710
# Quick Start
811

912
Let's get you writing typed Ruby in under 5 minutes. This guide assumes you've already [installed T-Ruby](/docs/getting-started/installation).
@@ -19,7 +22,7 @@ cd my-truby-project
1922

2023
Create a file called `hello.trb`:
2124

22-
```ruby title="hello.trb"
25+
```trb title="hello.trb"
2326
# A simple typed function
2427
def greet(name: String): String
2528
"Hello, #{name}!"
@@ -81,7 +84,7 @@ puts greet("World")
8184
puts add(5, 3)
8285
```
8386

84-
```ruby title="build/hello.rbs"
87+
```rbs title="build/hello.rbs"
8588
def greet: (String name) -> String
8689
def add: (Integer a, Integer b) -> Integer
8790
```
@@ -90,7 +93,7 @@ def add: (Integer a, Integer b) -> Integer
9093

9194
Now let's see type checking in action. Modify `hello.trb` to introduce a bug:
9295

93-
```ruby title="hello.trb (with bug)"
96+
```trb title="hello.trb (with bug)"
9497
def greet(name: String): String
9598
"Hello, #{name}!"
9699
end
@@ -152,7 +155,7 @@ You've written and compiled your first T-Ruby code! Here's where to go next:
152155

153156
Here's a slightly more complex example to play with:
154157

155-
```ruby title="user.trb"
158+
```trb title="user.trb"
156159
# Define a type alias
157160
type UserId = Integer
158161

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ title: T-Ruby vs Others
44
description: Comparison of T-Ruby with TypeScript, RBS, and Sorbet
55
---
66

7+
<DocsBadge />
8+
9+
710
# T-Ruby vs Others
811

912
The Ruby ecosystem has several approaches to static typing. This page compares T-Ruby with other solutions to help you understand where T-Ruby fits in.
@@ -41,7 +44,7 @@ class User
4144
end
4245
```
4346

44-
```ruby title="sig/user.rbs"
47+
```rbs title="sig/user.rbs"
4548
class User
4649
@name: String
4750
@age: Integer
@@ -55,7 +58,7 @@ end
5558

5659
Types are written inline:
5760

58-
```ruby title="lib/user.trb"
61+
```trb title="lib/user.trb"
5962
class User
6063
@name: String
6164
@age: Integer
@@ -119,7 +122,7 @@ end
119122

120123
### T-Ruby Approach
121124

122-
```ruby title="lib/calculator.trb"
125+
```trb title="lib/calculator.trb"
123126
class Calculator
124127
def add(a: Integer, b: Integer): Integer
125128
a + b
@@ -153,7 +156,7 @@ greet(123) # Raises TypeError at runtime if runtime checks enabled
153156
```
154157

155158
**T-Ruby approach:**
156-
```ruby
159+
```trb
157160
# Types are compile-time only
158161
def greet(name: String): String
159162
"Hello, #{name}"
@@ -193,7 +196,7 @@ function processUser<T extends User>(user: T): string {
193196
}
194197
```
195198

196-
```ruby title="T-Ruby"
199+
```trb title="T-Ruby"
197200
def greet(name: String): String
198201
"Hello, #{name}!"
199202
end

0 commit comments

Comments
 (0)