Skip to content

Commit 56b76f6

Browse files
committed
Updated docs.
1 parent d4e8b14 commit 56b76f6

15 files changed

Lines changed: 535 additions & 0 deletions

File tree

doc/docs/de/doc/advanced/macro.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,62 @@ print "Gültiger Enum-Typ:", $BodyType Static
229229

230230
</YueDisplay>
231231

232+
## Mehrzeiligen Yue-Code erzeugen
233+
234+
Wenn ein Makro mehrzeiligen Yue-Code zurückgibt, ist eine mehrzeilige Zeichenkette in Anführungszeichen nicht zu empfehlen. Verwende stattdessen bevorzugt `-> |`.
235+
236+
Eine Zeichenkette in Anführungszeichen behält den Text wörtlich bei, während ein YAML-Mehrzeilen-String die gemeinsame führende Einrückung entfernt. Dadurch bleiben erzeugte Yue-Blöcke in der Regel stabiler, besonders wenn der erzeugte Code Kommentare oder verschachtelte Blöcke enthält.
237+
238+
```yuescript
239+
macro default_conf = (conf) -> "
240+
-- useful; only set once
241+
#{conf}.identity = 'LOVE'
242+
#{conf}.version = \"11.5\"
243+
"
244+
245+
love.conf = (t) ->
246+
$default_conf t
247+
```
248+
249+
<YueDisplay>
250+
251+
```yue
252+
macro default_conf = (conf) -> "
253+
-- useful; only set once
254+
#{conf}.identity = 'LOVE'
255+
#{conf}.version = \"11.5\"
256+
"
257+
258+
love.conf = (t) ->
259+
$default_conf t
260+
```
261+
262+
</YueDisplay>
263+
264+
```yuescript
265+
macro default_conf = (conf) -> |
266+
-- useful; only set once
267+
#{conf}.identity = 'LOVE'
268+
#{conf}.version = "11.5"
269+
270+
love.conf = (t) ->
271+
$default_conf t
272+
```
273+
274+
<YueDisplay>
275+
276+
```yue
277+
macro default_conf = (conf) -> |
278+
-- useful; only set once
279+
#{conf}.identity = 'LOVE'
280+
#{conf}.version = "11.5"
281+
282+
love.conf = (t) ->
283+
$default_conf t
284+
```
285+
286+
</YueDisplay>
287+
232288
## Argument-Validierung
233289

234290
Du kannst erwartete AST-Knotentypen in der Argumentliste deklarieren und zur Compile-Zeit prüfen, ob die übergebenen Makroargumente den Erwartungen entsprechen.

doc/docs/doc/advanced/macro.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,62 @@ print "Valid enum type:", $BodyType Static
229229

230230
</YueDisplay>
231231

232+
## Generating Multi-line Yue Code
233+
234+
When a macro returns multi-line Yue code, using a quoted multi-line string is not recommended. Prefer `-> |` instead.
235+
236+
A quoted string keeps the literal text as-is, while a YAML multiline string removes the common leading indentation. This usually makes generated Yue blocks more stable, especially when the generated code contains comments or nested blocks.
237+
238+
```yuescript
239+
macro default_conf = (conf) -> "
240+
-- useful; only set once
241+
#{conf}.identity = 'LOVE'
242+
#{conf}.version = \"11.5\"
243+
"
244+
245+
love.conf = (t) ->
246+
$default_conf t
247+
```
248+
249+
<YueDisplay>
250+
251+
```yue
252+
macro default_conf = (conf) -> "
253+
-- useful; only set once
254+
#{conf}.identity = 'LOVE'
255+
#{conf}.version = \"11.5\"
256+
"
257+
258+
love.conf = (t) ->
259+
$default_conf t
260+
```
261+
262+
</YueDisplay>
263+
264+
```yuescript
265+
macro default_conf = (conf) -> |
266+
-- useful; only set once
267+
#{conf}.identity = 'LOVE'
268+
#{conf}.version = "11.5"
269+
270+
love.conf = (t) ->
271+
$default_conf t
272+
```
273+
274+
<YueDisplay>
275+
276+
```yue
277+
macro default_conf = (conf) -> |
278+
-- useful; only set once
279+
#{conf}.identity = 'LOVE'
280+
#{conf}.version = "11.5"
281+
282+
love.conf = (t) ->
283+
$default_conf t
284+
```
285+
286+
</YueDisplay>
287+
232288
## Argument Validation
233289

234290
You can declare the expected AST node types in the argument list, and check whether the incoming macro arguments meet the expectations at compile time.

doc/docs/id-id/doc/advanced/macro.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,62 @@ print "Valid enum type:", $BodyType Static
229229

230230
</YueDisplay>
231231

232+
## Menghasilkan kode Yue multi-baris
233+
234+
Saat macro mengembalikan kode Yue multi-baris, penggunaan string multi-baris di dalam tanda kutip tidak direkomendasikan. Sebaiknya gunakan `-> |`.
235+
236+
String bertanda kutip mempertahankan teks apa adanya, sedangkan string multi-baris YAML menghapus indentasi awal yang sama. Ini biasanya membuat blok Yue yang dihasilkan lebih stabil, terutama ketika kode yang dihasilkan berisi komentar atau blok bertingkat.
237+
238+
```yuescript
239+
macro default_conf = (conf) -> "
240+
-- useful; only set once
241+
#{conf}.identity = 'LOVE'
242+
#{conf}.version = \"11.5\"
243+
"
244+
245+
love.conf = (t) ->
246+
$default_conf t
247+
```
248+
249+
<YueDisplay>
250+
251+
```yue
252+
macro default_conf = (conf) -> "
253+
-- useful; only set once
254+
#{conf}.identity = 'LOVE'
255+
#{conf}.version = \"11.5\"
256+
"
257+
258+
love.conf = (t) ->
259+
$default_conf t
260+
```
261+
262+
</YueDisplay>
263+
264+
```yuescript
265+
macro default_conf = (conf) -> |
266+
-- useful; only set once
267+
#{conf}.identity = 'LOVE'
268+
#{conf}.version = "11.5"
269+
270+
love.conf = (t) ->
271+
$default_conf t
272+
```
273+
274+
<YueDisplay>
275+
276+
```yue
277+
macro default_conf = (conf) -> |
278+
-- useful; only set once
279+
#{conf}.identity = 'LOVE'
280+
#{conf}.version = "11.5"
281+
282+
love.conf = (t) ->
283+
$default_conf t
284+
```
285+
286+
</YueDisplay>
287+
232288
## Validasi Argumen
233289

234290
Anda dapat mendeklarasikan tipe node AST yang diharapkan dalam daftar argumen, dan memeriksa apakah argumen macro yang masuk memenuhi harapan pada waktu kompilasi.

doc/docs/pt-br/doc/advanced/macro.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,62 @@ print "Valid enum type:", $BodyType Static
228228

229229
</YueDisplay>
230230

231+
## Gerando código Yue em múltiplas linhas
232+
233+
Quando uma macro retorna código Yue em múltiplas linhas, não é recomendado usar uma string multilinha entre aspas. Prefira `-> |`.
234+
235+
Uma string entre aspas preserva o texto literal, enquanto uma string multilinha estilo YAML remove a indentação inicial comum. Isso normalmente deixa os blocos Yue gerados mais estáveis, especialmente quando o código gerado contém comentários ou blocos aninhados.
236+
237+
```yuescript
238+
macro default_conf = (conf) -> "
239+
-- useful; only set once
240+
#{conf}.identity = 'LOVE'
241+
#{conf}.version = \"11.5\"
242+
"
243+
244+
love.conf = (t) ->
245+
$default_conf t
246+
```
247+
248+
<YueDisplay>
249+
250+
```yue
251+
macro default_conf = (conf) -> "
252+
-- useful; only set once
253+
#{conf}.identity = 'LOVE'
254+
#{conf}.version = \"11.5\"
255+
"
256+
257+
love.conf = (t) ->
258+
$default_conf t
259+
```
260+
261+
</YueDisplay>
262+
263+
```yuescript
264+
macro default_conf = (conf) -> |
265+
-- useful; only set once
266+
#{conf}.identity = 'LOVE'
267+
#{conf}.version = "11.5"
268+
269+
love.conf = (t) ->
270+
$default_conf t
271+
```
272+
273+
<YueDisplay>
274+
275+
```yue
276+
macro default_conf = (conf) -> |
277+
-- useful; only set once
278+
#{conf}.identity = 'LOVE'
279+
#{conf}.version = "11.5"
280+
281+
love.conf = (t) ->
282+
$default_conf t
283+
```
284+
285+
</YueDisplay>
286+
231287
## Validação de argumentos
232288

233289
Você pode declarar os tipos de nós AST esperados na lista de argumentos e verificar se os argumentos da macro recebidos atendem às expectativas em tempo de compilação.

doc/docs/zh/doc/advanced/macro.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,62 @@ print "有效的枚举类型:", $BodyType Static
229229

230230
</YueDisplay>
231231

232+
## 生成多行 Yue 代码
233+
234+
&emsp;&emsp;当宏返回多行 Yue 代码时,不推荐使用带引号的多行字符串,建议优先使用 `-> |`
235+
236+
&emsp;&emsp;带引号的字符串会按字面保留文本;而 YAML 风格多行字符串会移除公共前导缩进。对宏生成的 Yue 代码来说,这通常能让代码块结构更稳定,尤其是在生成代码里包含注释或嵌套块时。
237+
238+
```yuescript
239+
macro default_conf = (conf) -> "
240+
-- useful; only set once
241+
#{conf}.identity = 'LOVE'
242+
#{conf}.version = \"11.5\"
243+
"
244+
245+
love.conf = (t) ->
246+
$default_conf t
247+
```
248+
249+
<YueDisplay>
250+
251+
```yue
252+
macro default_conf = (conf) -> "
253+
-- useful; only set once
254+
#{conf}.identity = 'LOVE'
255+
#{conf}.version = \"11.5\"
256+
"
257+
258+
love.conf = (t) ->
259+
$default_conf t
260+
```
261+
262+
</YueDisplay>
263+
264+
```yuescript
265+
macro default_conf = (conf) -> |
266+
-- useful; only set once
267+
#{conf}.identity = 'LOVE'
268+
#{conf}.version = "11.5"
269+
270+
love.conf = (t) ->
271+
$default_conf t
272+
```
273+
274+
<YueDisplay>
275+
276+
```yue
277+
macro default_conf = (conf) -> |
278+
-- useful; only set once
279+
#{conf}.identity = 'LOVE'
280+
#{conf}.version = "11.5"
281+
282+
love.conf = (t) ->
283+
$default_conf t
284+
```
285+
286+
</YueDisplay>
287+
232288
## 宏参数检查
233289

234290
&emsp;&emsp;可以直接在参数列表中声明期望的 AST 节点类型,并在编译时检查传入的宏参数是否符合预期。

doc/yue-de.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,33 @@ print "Gültiger Enum-Typ:", $BodyType Static
183183
-- print "Kompilierungsfehler bei Enum-Typ:", $BodyType Unknown
184184
```
185185

186+
## Mehrzeiligen Yue-Code erzeugen
187+
188+
Wenn ein Makro mehrzeiligen Yue-Code zurückgibt, ist eine mehrzeilige Zeichenkette in Anführungszeichen nicht zu empfehlen. Verwende stattdessen bevorzugt `-> |`.
189+
190+
Eine Zeichenkette in Anführungszeichen behält den Text wörtlich bei, während ein YAML-Mehrzeilen-String die gemeinsame führende Einrückung entfernt. Dadurch bleiben erzeugte Yue-Blöcke in der Regel stabiler, besonders wenn der erzeugte Code Kommentare oder verschachtelte Blöcke enthält.
191+
192+
```yuescript
193+
macro default_conf = (conf) -> "
194+
-- useful; only set once
195+
#{conf}.identity = 'LOVE'
196+
#{conf}.version = \"11.5\"
197+
"
198+
199+
love.conf = (t) ->
200+
$default_conf t
201+
```
202+
203+
```yuescript
204+
macro default_conf = (conf) -> |
205+
-- useful; only set once
206+
#{conf}.identity = 'LOVE'
207+
#{conf}.version = "11.5"
208+
209+
love.conf = (t) ->
210+
$default_conf t
211+
```
212+
186213
## Argument-Validierung
187214

188215
Du kannst erwartete AST-Knotentypen in der Argumentliste deklarieren und zur Compile-Zeit prüfen, ob die übergebenen Makroargumente den Erwartungen entsprechen.

doc/yue-en.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,33 @@ print "Valid enum type:", $BodyType Static
183183
-- print "Compilation error with enum type:", $BodyType Unknown
184184
```
185185

186+
## Generating Multi-line Yue Code
187+
188+
When a macro returns multi-line Yue code, using a quoted multi-line string is not recommended. Prefer `-> |` instead.
189+
190+
A quoted string keeps the literal text as-is, while a YAML multiline string removes the common leading indentation. This usually makes generated Yue blocks more stable, especially when the generated code contains comments or nested blocks.
191+
192+
```yuescript
193+
macro default_conf = (conf) -> "
194+
-- useful; only set once
195+
#{conf}.identity = 'LOVE'
196+
#{conf}.version = \"11.5\"
197+
"
198+
199+
love.conf = (t) ->
200+
$default_conf t
201+
```
202+
203+
```yuescript
204+
macro default_conf = (conf) -> |
205+
-- useful; only set once
206+
#{conf}.identity = 'LOVE'
207+
#{conf}.version = "11.5"
208+
209+
love.conf = (t) ->
210+
$default_conf t
211+
```
212+
186213
## Argument Validation
187214

188215
You can declare the expected AST node types in the argument list, and check whether the incoming macro arguments meet the expectations at compile time.

0 commit comments

Comments
 (0)