From d7452147eaa1f47520269f881b3d06c4e164dfd3 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Thu, 4 Dec 2025 09:36:42 +0800 Subject: Updated docs. [skip CI] --- doc/docs/doc/README.md | 156 +++++++++++++++++++++++----------------------- doc/docs/zh/doc/README.md | 156 +++++++++++++++++++++++----------------------- 2 files changed, 156 insertions(+), 156 deletions(-) (limited to 'doc/docs') diff --git a/doc/docs/doc/README.md b/doc/docs/doc/README.md index 11c9427..1a46e59 100755 --- a/doc/docs/doc/README.md +++ b/doc/docs/doc/README.md @@ -408,16 +408,16 @@ In YueScript, macro functions allow you to generate code at compile time. By nes ```moonscript macro Enum = (...) -> - items = {...} - itemSet = {item, true for item in *items} - (item) -> - error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item] - "\"#{item}\"" + items = {...} + itemSet = {item, true for item in *items} + (item) -> + error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item] + "\"#{item}\"" macro BodyType = $Enum( - Static - Dynamic - Kinematic + Static + Dynamic + Kinematic ) print "Valid enum type:", $BodyType Static @@ -427,16 +427,16 @@ print "Valid enum type:", $BodyType Static
 macro Enum = (...) ->
-	items = {...}
-	itemSet = {item, true for item in *items}
-	(item) ->
-		error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item]
-		"\"#{item}\""
+  items = {...}
+  itemSet = {item, true for item in *items}
+  (item) ->
+    error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item]
+    "\"#{item}\""
 
 macro BodyType = $Enum(
-	Static
-	Dynamic
-	Kinematic
+  Static
+  Dynamic
+  Kinematic
 )
 
 print "Valid enum type:", $BodyType Static
@@ -534,47 +534,47 @@ Note the evaluation behavior of chained comparisons:
 
 ```moonscript
 v = (x) ->
-	print x
-	x
+  print x
+  x
 
 print v(1) < v(2) <= v(3)
 --[[
-	output:
-	2
-	1
-	3
-	true
+  output:
+  2
+  1
+  3
+  true
 ]]
 
 print v(1) > v(2) <= v(3)
 --[[
-	output:
-	2
-	1
-	false
+  output:
+  2
+  1
+  false
 ]]
 ```
 
 
 v = (x) ->
-	print x
-	x
+  print x
+  x
 
 print v(1) < v(2) <= v(3)
 --[[
-	output:
-	2
-	1
-	3
-	true
+  output:
+  2
+  1
+  3
+  true
 ]]
 
 print v(1) > v(2) <= v(3)
 --[[
-	output:
-	2
-	1
-	false
+  output:
+  2
+  1
+  false
 ]]
 
@@ -618,13 +618,13 @@ You can concatenate array tables or hash tables using spread operator `...` befo ```moonscript parts = - * "shoulders" - * "knees" + * "shoulders" + * "knees" lyrics = - * "head" - * ...parts - * "and" - * "toes" + * "head" + * ...parts + * "and" + * "toes" copy = {...other} @@ -635,13 +635,13 @@ merge = {...a, ...b}
 parts =
-	* "shoulders"
-	* "knees"
+  * "shoulders"
+  * "knees"
 lyrics =
-	* "head"
-	* ...parts
-	* "and"
-	* "toes"
+  * "head"
+  * ...parts
+  * "and"
+  * "toes"
 
 copy = {...other}
 
@@ -3325,19 +3325,19 @@ Match against a list and capture a range of elements.
 ```moonscript
 segments = ["admin", "users", "logs", "view"]
 switch segments
-	when [...groups, resource, action]
-		print "Group:", groups -- prints: {"admin", "users"}
-		print "Resource:", resource -- prints: "logs"
-		print "Action:", action -- prints: "view"
+  when [...groups, resource, action]
+    print "Group:", groups -- prints: {"admin", "users"}
+    print "Resource:", resource -- prints: "logs"
+    print "Action:", action -- prints: "view"
 ```
 
 
 segments = ["admin", "users", "logs", "view"]
 switch segments
-	when [...groups, resource, action]
-		print "Group:", groups -- prints: {"admin", "users"}
-		print "Resource:", resource -- prints: "logs"
-		print "Action:", action -- prints: "view"
+  when [...groups, resource, action]
+    print "Group:", groups -- prints: {"admin", "users"}
+    print "Resource:", resource -- prints: "logs"
+    print "Action:", action -- prints: "view"
 
@@ -4228,9 +4228,9 @@ The YueScript compiling function. It compiles the YueScript code to Lua code. **Signature:** ```lua to_lua: function(code: string, config?: Config): - --[[codes]] string | nil, - --[[error]] string | nil, - --[[globals]] {{string, integer, integer}} | nil + --[[codes]] string | nil, + --[[error]] string | nil, + --[[globals]] {{string, integer, integer}} | nil ``` **Parameters:** @@ -4353,8 +4353,8 @@ Loads YueScript code from a string into a function. **Signature:** ```lua loadstring: function(input: string, chunkname: string, env: table, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil ``` **Parameters:** @@ -4384,8 +4384,8 @@ Loads YueScript code from a string into a function. **Signature:** ```lua loadstring: function(input: string, chunkname: string, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil ``` **Parameters:** @@ -4414,8 +4414,8 @@ Loads YueScript code from a string into a function. **Signature:** ```lua loadstring: function(input: string, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil ``` **Parameters:** @@ -4443,8 +4443,8 @@ Loads YueScript code from a file into a function. **Signature:** ```lua loadfile: function(filename: string, env: table, config?: Config): - nil | function(...: any): (any...), - string | nil + nil | function(...: any): (any...), + string | nil ``` **Parameters:** @@ -4473,8 +4473,8 @@ Loads YueScript code from a file into a function. **Signature:** ```lua loadfile: function(filename: string, config?: Config): - nil | function(...: any): (any...), - string | nil + nil | function(...: any): (any...), + string | nil ``` **Parameters:** @@ -4730,8 +4730,8 @@ Converts the code to the AST. **Signature:** ```lua to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): - --[[AST]] AST | nil, - --[[error]] nil | string + --[[AST]] AST | nil, + --[[error]] nil | string ``` **Parameters:** @@ -4911,11 +4911,11 @@ The target Lua version enumeration. **Signature:** ```lua enum LuaTarget - "5.1" - "5.2" - "5.3" - "5.4" - "5.5" + "5.1" + "5.2" + "5.3" + "5.4" + "5.5" end ``` diff --git a/doc/docs/zh/doc/README.md b/doc/docs/zh/doc/README.md index da69e22..b348e06 100755 --- a/doc/docs/zh/doc/README.md +++ b/doc/docs/zh/doc/README.md @@ -407,16 +407,16 @@ print $LINE -- 获取当前代码行数:2 ```moonscript macro Enum = (...) -> - items = {...} - itemSet = {item, true for item in *items} - (item) -> - error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item] - "\"#{item}\"" + items = {...} + itemSet = {item, true for item in *items} + (item) -> + error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item] + "\"#{item}\"" macro BodyType = $Enum( - Static - Dynamic - Kinematic + Static + Dynamic + Kinematic ) print "有效的枚举类型:", $BodyType Static @@ -425,16 +425,16 @@ print "有效的枚举类型:", $BodyType Static
 macro Enum = (...) ->
-	items = {...}
-	itemSet = {item, true for item in *items}
-	(item) ->
-		error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item]
-		"\"#{item}\""
+  items = {...}
+  itemSet = {item, true for item in *items}
+  (item) ->
+    error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item]
+    "\"#{item}\""
 
 macro BodyType = $Enum(
-	Static
-	Dynamic
-	Kinematic
+  Static
+  Dynamic
+  Kinematic
 )
 
 print "有效的枚举类型:", $BodyType Static
@@ -532,47 +532,47 @@ print 1 <= a <= 10
 
 ```moonscript
 v = (x) ->
-	print x
-	x
+  print x
+  x
 
 print v(1) < v(2) <= v(3)
 --[[
-	输出:
-	2
-	1
-	3
-	true
+  输出:
+  2
+  1
+  3
+  true
 ]]
 
 print v(1) > v(2) <= v(3)
 --[[
-	输出:
-	2
-	1
-	false
+  输出:
+  2
+  1
+  false
 ]]
 ```
 
 
 v = (x) ->
-	print x
-	x
+  print x
+  x
 
 print v(1) < v(2) <= v(3)
 --[[
-	输出:
-	2
-	1
-	3
-	true
+  输出:
+  2
+  1
+  3
+  true
 ]]
 
 print v(1) > v(2) <= v(3)
 --[[
-	输出:
-	2
-	1
-	false
+  输出:
+  2
+  1
+  false
 ]]
 
@@ -617,13 +617,13 @@ tbA[] = ...tbB ```moonscript parts = - * "shoulders" - * "knees" + * "shoulders" + * "knees" lyrics = - * "head" - * ...parts - * "and" - * "toes" + * "head" + * ...parts + * "and" + * "toes" copy = {...other} @@ -634,13 +634,13 @@ merge = {...a, ...b}
 parts =
-	* "shoulders"
-	* "knees"
+  * "shoulders"
+  * "knees"
 lyrics =
-	* "head"
-	* ...parts
-	* "and"
-	* "toes"
+  * "head"
+  * ...parts
+  * "and"
+  * "toes"
 
 copy = {...other}
 
@@ -3285,19 +3285,19 @@ switch tb
 ```moonscript
 segments = ["admin", "users", "logs", "view"]
 switch segments
-	when [...groups, resource, action]
-		print "Group:", groups -- 打印: {"admin", "users"}
-		print "Resource:", resource -- 打印: "logs"
-		print "Action:", action -- 打印: "view"
+  when [...groups, resource, action]
+    print "Group:", groups -- 打印: {"admin", "users"}
+    print "Resource:", resource -- 打印: "logs"
+    print "Action:", action -- 打印: "view"
 ```
 
 
 segments = ["admin", "users", "logs", "view"]
 switch segments
-	when [...groups, resource, action]
-		print "Group:", groups -- 打印: {"admin", "users"}
-		print "Resource:", resource -- 打印: "logs"
-		print "Action:", action -- 打印: "view"
+  when [...groups, resource, action]
+    print "Group:", groups -- 打印: {"admin", "users"}
+    print "Resource:", resource -- 打印: "logs"
+    print "Action:", action -- 打印: "view"
 
@@ -4185,9 +4185,9 @@ yue_compiled: {string: string} **签名:** ```lua to_lua: function(code: string, config?: Config): - --[[codes]] string | nil, - --[[error]] string | nil, - --[[globals]] {{string, integer, integer}} | nil + --[[codes]] string | nil, + --[[error]] string | nil, + --[[globals]] {{string, integer, integer}} | nil ``` **参数:** @@ -4310,8 +4310,8 @@ remove_loader: function(): boolean **签名:** ```lua loadstring: function(input: string, chunkname: string, env: table, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil ``` **参数:** @@ -4341,8 +4341,8 @@ loadstring: function(input: string, chunkname: string, env: table, config?: Conf **签名:** ```lua loadstring: function(input: string, chunkname: string, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil ``` **参数:** @@ -4371,8 +4371,8 @@ loadstring: function(input: string, chunkname: string, config?: Config): **签名:** ```lua loadstring: function(input: string, config?: Config): - --[[loaded function]] nil | function(...: any): (any...), - --[[error]] string | nil + --[[loaded function]] nil | function(...: any): (any...), + --[[error]] string | nil ``` **参数:** @@ -4400,8 +4400,8 @@ loadstring: function(input: string, config?: Config): **签名:** ```lua loadfile: function(filename: string, env: table, config?: Config): - nil | function(...: any): (any...), - string | nil + nil | function(...: any): (any...), + string | nil ``` **参数:** @@ -4430,8 +4430,8 @@ loadfile: function(filename: string, env: table, config?: Config): **签名:** ```lua loadfile: function(filename: string, config?: Config): - nil | function(...: any): (any...), - string | nil + nil | function(...: any): (any...), + string | nil ``` **参数:** @@ -4687,8 +4687,8 @@ type AST = {string, integer, integer, any} **签名:** ```lua to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): - --[[AST]] AST | nil, - --[[error]] nil | string + --[[AST]] AST | nil, + --[[error]] nil | string ``` **参数:** @@ -4868,11 +4868,11 @@ line_offset: integer **签名:** ```lua enum LuaTarget - "5.1" - "5.2" - "5.3" - "5.4" - "5.5" + "5.1" + "5.2" + "5.3" + "5.4" + "5.5" end ``` -- cgit v1.2.3-55-g6feb