Skip to content

Commit 03c22f2

Browse files
Correct variable use
1 parent 2238373 commit 03c22f2

7 files changed

Lines changed: 39 additions & 35 deletions

File tree

_scripts/compile_blocks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ def main():
122122

123123
md_files = sorted(
124124
p for p in Path('.').rglob('*.md')
125-
if '.jekyll-cache' not in p.parts and 'vendor' not in p.parts
125+
if '.jekyll-cache' not in p.parts
126+
and 'vendor' not in p.parts
127+
and 'multilingual-src' not in p.parts # CI checkout lives inside docs root
126128
)
127129

128130
total = compiled = skipped = cached = 0

_tests/test_code_blocks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ def _collect_blocks():
8989

9090
md_files = sorted(
9191
p for p in REPO_ROOT.rglob('*.md')
92-
if '.jekyll-cache' not in p.parts and 'vendor' not in p.parts
92+
if '.jekyll-cache' not in p.parts
93+
and 'vendor' not in p.parts
94+
and 'multilingual-src' not in p.parts # CI checkout lives inside docs root
9395
)
9496

9597
for md_file in md_files:

getting-started/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ Create a file `hello_en.ml`:
8787
let message = "Hello, multilingual world!"
8888
let count = 3
8989

90-
for i in range(count):
91-
print(f"[{i}] {message}")
90+
for idx in range(count):
91+
print(f"[{idx}] {message}")
9292
```
9393

9494
Run it:

getting-started/quick-start.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,24 +136,24 @@ if (n := len(data)) > 3:
136136
### for loop
137137

138138
```python
139-
for i in range(5):
140-
print(i) # 0, 1, 2, 3, 4
139+
for idx in range(5):
140+
print(idx) # 0, 1, 2, 3, 4
141141

142142
# Iterate over a list
143143
let fruits = ["apple", "banana", "cherry"]
144144
for fruit in fruits:
145145
print(fruit)
146146

147147
# With enumerate
148-
for i, fruit in enumerate(fruits):
149-
print(f"{i}: {fruit}")
148+
for idx, fruit in enumerate(fruits):
149+
print(f"{idx}: {fruit}")
150150
```
151151

152152
### for / else
153153

154154
```python
155-
for i in range(5):
156-
if i == 3:
155+
for idx in range(5):
156+
if idx == 3:
157157
break
158158
else:
159159
print("Loop completed without break")
@@ -171,12 +171,12 @@ while count < 5:
171171
### break and continue
172172

173173
```python
174-
for i in range(10):
175-
if i % 2 == 0:
174+
for idx in range(10):
175+
if idx % 2 == 0:
176176
continue # skip even
177-
if i > 7:
177+
if idx > 7:
178178
break
179-
print(i) # 1, 3, 5, 7
179+
print(idx) # 1, 3, 5, 7
180180
```
181181

182182
---

getting-started/repl.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ let y = 3
223223
print(x + y)
224224

225225
let total = 0
226-
for i in range(4):
227-
total = total + i
226+
for idx in range(4):
227+
total = total + idx
228228
print(total)
229229
```
230230

language-guide/control-flow.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ sonst:
149149
### English
150150

151151
```python
152-
for i in range(5):
153-
print(i)
152+
for idx in range(5):
153+
print(idx)
154154

155155
# With else
156156
for item in [1, 2, 3]:
@@ -219,12 +219,12 @@ for index, letter in pairs:
219219
print(f"{index}: {letter}")
220220

221221
# enumerate
222-
for i, val in enumerate(["x", "y", "z"]):
223-
print(i, val)
222+
for idx, val in enumerate(["x", "y", "z"]):
223+
print(idx, val)
224224

225225
# zip
226-
for a, b in zip([1, 2, 3], ["one", "two", "three"]):
227-
print(a, b)
226+
for aa, bb in zip([1, 2, 3], ["one", "two", "three"]):
227+
print(aa, bb)
228228
```
229229

230230
---
@@ -432,20 +432,20 @@ These keywords are universal (not localized) across all languages.
432432
### break — Exit a loop early
433433

434434
```python
435-
for i in range(100):
436-
if i == 10:
435+
for idx in range(100):
436+
if idx == 10:
437437
break
438-
print(i)
438+
print(idx)
439439
# prints 0 through 9
440440
```
441441

442442
### continue — Skip current iteration
443443

444444
```python
445-
for i in range(10):
446-
if i % 2 == 0:
445+
for idx in range(10):
446+
if idx % 2 == 0:
447447
continue
448-
print(i)
448+
print(idx)
449449
# prints 1, 3, 5, 7, 9
450450
```
451451

@@ -465,9 +465,9 @@ def not_implemented_yet():
465465

466466
```python
467467
# Multiplication table
468-
for i in range(1, 4):
469-
for j in range(1, 4):
470-
print(f"{i}×{j}={i*j}", end=" ")
468+
for ii in range(1, 4):
469+
for jj in range(1, 4):
470+
print(f"{ii}×{jj}={ii*jj}", end=" ")
471471
print()
472472
```
473473

@@ -489,8 +489,8 @@ pour i dans intervalle(1, 4):
489489
let target = 7
490490
let numbers = [1, 3, 5, 7, 9]
491491

492-
for n in numbers:
493-
if n == target:
492+
for num in numbers:
493+
if num == target:
494494
print(f"Found {target}")
495495
break
496496
else:

language-guide/syntax.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ let add = lambda x, y: x + y
277277

278278
Tuple target:
279279
```python
280-
for i, v in enumerate([10, 20, 30]):
281-
print(i, v)
280+
for idx, val in enumerate([10, 20, 30]):
281+
print(idx, val)
282282
```
283283

284284
### while loop

0 commit comments

Comments
 (0)