Skip to content

Commit d63779e

Browse files
committed
Updated docs.
1 parent 82e9b37 commit d63779e

File tree

33 files changed

+2931
-1872
lines changed

33 files changed

+2931
-1872
lines changed

doc/docs/.vitepress/config.mts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ function createSidebar(basePath: string, locale: SidebarLocale) {
299299
text: text.attributes,
300300
link: `${basePath}/language-basics/attributes`,
301301
},
302+
{ text: text.module, link: `${basePath}/language-basics/module` },
302303
],
303304
},
304305
{
@@ -389,7 +390,6 @@ function createSidebar(basePath: string, locale: SidebarLocale) {
389390
collapsed: true,
390391
items: [
391392
{ text: text.macro, link: `${basePath}/advanced/macro` },
392-
{ text: text.module, link: `${basePath}/advanced/module` },
393393
{
394394
text: text.lineDecorators,
395395
link: `${basePath}/advanced/line-decorators`,
@@ -510,6 +510,11 @@ export default defineConfig({
510510
document.head.appendChild(s);
511511
})();`,
512512
],
513+
[
514+
"style",
515+
{},
516+
".dark .vp-code span{color:var(--shiki-dark,inherit)}html:not(.dark) .vp-code span{color:var(--shiki-light,inherit)}",
517+
],
513518
],
514519
vite: {
515520
publicDir: resolve(__dirname, "public"),

doc/docs/de/doc/advanced/do.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,27 @@ print var -- nil hier
2020

2121
</YueDisplay>
2222

23-
YueScripts **do** kann auch als Ausdruck verwendet werden. So kannst du mehrere Zeilen in einem Ausdruck kombinieren. Das Ergebnis des `do`-Ausdrucks ist die letzte Anweisung im Block.
23+
YueScripts **do** kann auch als Ausdruck verwendet werden. So kannst du mehrere Zeilen in einem Ausdruck kombinieren. Das Ergebnis des `do`-Ausdrucks ist die letzte Anweisung im Block. `do`-Ausdrücke unterstützen die Verwendung von `break`, um den Kontrollfluss zu unterbrechen und mehrere Rückgabewerte vorzeitig zurückzugeben.
24+
25+
```yuescript
26+
status, value = do
27+
n = 12
28+
if n > 10
29+
break "large", n
30+
break "small", n
31+
```
32+
33+
<YueDisplay>
34+
35+
```yue
36+
status, value = do
37+
n = 12
38+
if n > 10
39+
break "large", n
40+
break "small", n
41+
```
42+
43+
</YueDisplay>
2444

2545
```yuescript
2646
counter = do

doc/docs/de/doc/control-flow/for-loop.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ doubled_evens = for i = 1, 20
8686

8787
</YueDisplay>
8888

89-
Zusätzlich unterstützen `for`-Schleifen `break` mit Rückgabewert, sodass die Schleife selbst als Ausdruck verwendet werden kann, der früh mit einem sinnvollen Ergebnis endet.
89+
Zusätzlich unterstützen `for`-Schleifen `break` mit Rückgabewerten, sodass die Schleife selbst als Ausdruck verwendet werden kann, der früh mit einem sinnvollen Ergebnis endet. `for`-Ausdrücke unterstützen mehrere `break`-Werte.
9090

9191
Beispiel: die erste Zahl größer als 10 finden:
9292

@@ -106,6 +106,20 @@ first_large = for n in *numbers
106106

107107
Diese `break`-mit-Wert-Syntax ermöglicht knappe und ausdrucksstarke Such- bzw. Early-Exit-Muster direkt in Schleifenausdrücken.
108108

109+
```yuescript
110+
key, score = for k, v in pairs data
111+
break k, v * 10 if k == "target"
112+
```
113+
114+
<YueDisplay>
115+
116+
```yue
117+
key, score = for k, v in pairs data
118+
break k, v * 10 if k == "target"
119+
```
120+
121+
</YueDisplay>
122+
109123
Du kannst Werte auch filtern, indem du den `for`-Ausdruck mit `continue` kombinierst.
110124

111125
`for`-Schleifen am Ende eines Funktionsrumpfs werden nicht in eine Tabelle für einen Rückgabewert gesammelt (stattdessen gibt die Funktion `nil` zurück). Du kannst entweder explizit `return` verwenden oder die Schleife in eine Listen-Comprehension umwandeln.

doc/docs/de/doc/control-flow/while-loop.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,25 @@ until running == false do my_function!
4545

4646
</YueDisplay>
4747

48-
Wie bei `for`-Schleifen kann die `while`-Schleife auch als Ausdruck verwendet werden. Damit eine Funktion den akkumulierten Wert einer `while`-Schleife zurückgibt, muss die Anweisung explizit mit `return` zurückgegeben werden.
48+
Wie bei `for`-Schleifen kann die `while`-Schleife auch als Ausdruck verwendet werden. `while`- und `until`-Ausdrücke unterstützen `break` mit mehreren Rückgabewerten.
49+
50+
```yuescript
51+
value, doubled = while true
52+
n = get_next!
53+
break n, n * 2 if n > 10
54+
```
55+
56+
<YueDisplay>
57+
58+
```yue
59+
value, doubled = while true
60+
n = get_next!
61+
break n, n * 2 if n > 10
62+
```
63+
64+
</YueDisplay>
65+
66+
Damit eine Funktion den akkumulierten Wert einer `while`-Schleife zurückgibt, muss die Anweisung explizit mit `return` zurückgegeben werden.
4967

5068
## Repeat-Schleife
5169

@@ -70,3 +88,25 @@ until i == 0
7088
```
7189

7290
</YueDisplay>
91+
92+
`repeat`-Ausdrücke unterstützen ebenfalls `break` mit mehreren Rückgabewerten:
93+
94+
```yuescript
95+
i = 1
96+
value, scaled = repeat
97+
break i, i * 100 if i > 3
98+
i += 1
99+
until false
100+
```
101+
102+
<YueDisplay>
103+
104+
```yue
105+
i = 1
106+
value, scaled = repeat
107+
break i, i * 100 if i > 3
108+
i += 1
109+
until false
110+
```
111+
112+
</YueDisplay>

doc/docs/de/doc/objects/with-statement.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,50 @@ file = with File "Lieblingsessen.txt"
4444

4545
</YueDisplay>
4646

47+
`with`-Ausdrücke unterstützen `break` mit genau einem Wert:
48+
49+
```yuescript
50+
result = with obj
51+
break .value
52+
```
53+
54+
<YueDisplay>
55+
56+
```yue
57+
result = with obj
58+
break .value
59+
```
60+
61+
</YueDisplay>
62+
63+
Sobald `break value` in `with` verwendet wird, gibt der `with`-Ausdruck nicht mehr sein Zielobjekt zurück, sondern den von `break` gelieferten Wert.
64+
65+
```yuescript
66+
a = with obj
67+
.x = 1
68+
-- a ist obj
69+
70+
b = with obj
71+
break .x
72+
-- b ist .x, nicht obj
73+
```
74+
75+
<YueDisplay>
76+
77+
```yue
78+
a = with obj
79+
.x = 1
80+
-- a ist obj
81+
82+
b = with obj
83+
break .x
84+
-- b ist .x, nicht obj
85+
```
86+
87+
</YueDisplay>
88+
89+
Im Unterschied zu `for` / `while` / `repeat` / `do` unterstützt `with` nur einen `break`-Wert.
90+
4791
Oder …
4892

4993
```yuescript

doc/docs/doc/advanced/do.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,28 @@ print var -- nil here
2222

2323
YueScript's **do** can also be used an expression . Allowing you to combine multiple lines into one. The result of the do expression is the last statement in its body.
2424

25+
`do` expressions also support using `break` to interrupt control flow and return multiple values early:
26+
27+
```yuescript
28+
status, value = do
29+
n = 12
30+
if n > 10
31+
break "large", n
32+
break "small", n
33+
```
34+
35+
<YueDisplay>
36+
37+
```yue
38+
status, value = do
39+
n = 12
40+
if n > 10
41+
break "large", n
42+
break "small", n
43+
```
44+
45+
</YueDisplay>
46+
2547
```yuescript
2648
counter = do
2749
i = 0

doc/docs/doc/control-flow/for-loop.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ doubled_evens = for i = 1, 20
8686

8787
</YueDisplay>
8888

89-
In addition, for loops support break with a return value, allowing the loop itself to be used as an expression that exits early with a meaningful result.
89+
In addition, for loops support break with return values, allowing the loop itself to be used as an expression that exits early with meaningful results.
9090

9191
For example, to find the first number greater than 10:
9292

@@ -106,6 +106,22 @@ first_large = for n in *numbers
106106

107107
This break-with-value syntax enables concise and expressive search or early-exit patterns directly within loop expressions.
108108

109+
For loop expressions can break with multiple values:
110+
111+
```yuescript
112+
key, score = for k, v in pairs data
113+
break k, v * 10 if k == "target"
114+
```
115+
116+
<YueDisplay>
117+
118+
```yue
119+
key, score = for k, v in pairs data
120+
break k, v * 10 if k == "target"
121+
```
122+
123+
</YueDisplay>
124+
109125
You can also filter values by combining the for loop expression with the continue statement.
110126

111127
For loops at the end of a function body are not accumulated into a table for a return value (Instead the function will return nil). Either an explicit return statement can be used, or the loop can be converted into a list comprehension.

doc/docs/doc/control-flow/while-loop.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,25 @@ until running == false do my_function!
4545

4646
</YueDisplay>
4747

48-
Like for loops, the while loop can also be used an expression. Additionally, for a function to return the accumulated value of a while loop, the statement must be explicitly returned.
48+
Like for loops, the while loop can also be used as an expression. While and until loop expressions support `break` with multiple return values.
49+
50+
```yuescript
51+
value, doubled = while true
52+
n = get_next!
53+
break n, n * 2 if n > 10
54+
```
55+
56+
<YueDisplay>
57+
58+
```yue
59+
value, doubled = while true
60+
n = get_next!
61+
break n, n * 2 if n > 10
62+
```
63+
64+
</YueDisplay>
65+
66+
Additionally, for a function to return the accumulated value of a while loop, the statement must be explicitly returned.
4967

5068
## Repeat Loop
5169

@@ -70,3 +88,25 @@ until i == 0
7088
```
7189

7290
</YueDisplay>
91+
92+
Repeat loop expressions also support `break` with multiple return values:
93+
94+
```yuescript
95+
i = 1
96+
value, scaled = repeat
97+
break i, i * 100 if i > 3
98+
i += 1
99+
until false
100+
```
101+
102+
<YueDisplay>
103+
104+
```yue
105+
i = 1
106+
value, scaled = repeat
107+
break i, i * 100 if i > 3
108+
i += 1
109+
until false
110+
```
111+
112+
</YueDisplay>
File renamed without changes.

0 commit comments

Comments
 (0)