aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2026-02-03 22:42:37 +0800
committerLi Jin <dragon-fly@qq.com>2026-02-03 22:42:37 +0800
commite4f8d1b3b075323968bb6dc334226dff33c0a2b0 (patch)
tree657e1ac82e54b91014dc12d15e90329bf66f9d0f /spec/outputs
parentca1ec12725c32b0173692e01259570966da8a9a6 (diff)
downloadyuescript-e4f8d1b3b075323968bb6dc334226dff33c0a2b0.tar.gz
yuescript-e4f8d1b3b075323968bb6dc334226dff33c0a2b0.tar.bz2
yuescript-e4f8d1b3b075323968bb6dc334226dff33c0a2b0.zip
Updated doc.
Diffstat (limited to 'spec/outputs')
-rw-r--r--spec/outputs/codes_from_doc.lua34
-rw-r--r--spec/outputs/codes_from_doc_zh.lua34
-rw-r--r--spec/outputs/compile_doc.lua10
3 files changed, 69 insertions, 9 deletions
diff --git a/spec/outputs/codes_from_doc.lua b/spec/outputs/codes_from_doc.lua
index 3b0724a..b8985e7 100644
--- a/spec/outputs/codes_from_doc.lua
+++ b/spec/outputs/codes_from_doc.lua
@@ -107,7 +107,7 @@ if cond then
107end 107end
108end 108end
109print("yuescript") 109print("yuescript")
110print(3) 110print(2)
111print("Valid enum type:", "Static") 111print("Valid enum type:", "Static")
112do 112do
113 print(123, "hello") 113 print(123, "hello")
@@ -992,6 +992,36 @@ local arg1 = {
992 a = 0 992 a = 0
993} 993}
994f2(arg1, arg2) 994f2(arg1, arg2)
995local findFirstEven
996findFirstEven = function(list)
997 for _index_0 = 1, #list do
998 local item = list[_index_0]
999 if type(item) == "table" then
1000 for _index_1 = 1, #item do
1001 local sub = item[_index_1]
1002 if sub % 2 == 0 then
1003 return sub
1004 end
1005 end
1006 end
1007 end
1008 return nil
1009end
1010local findFirstEven
1011findFirstEven = function(list)
1012 for _index_0 = 1, #list do
1013 local item = list[_index_0]
1014 if type(item) == "table" then
1015 for _index_1 = 1, #item do
1016 local sub = item[_index_1]
1017 if sub % 2 == 0 then
1018 return sub
1019 end
1020 end
1021 end
1022 end
1023 return nil
1024end
995local f 1025local f
996f = function(...) 1026f = function(...)
997 local t = { 1027 local t = {
@@ -2637,7 +2667,7 @@ if cond then
2637end 2667end
2638end 2668end
2639print("yuescript") 2669print("yuescript")
2640print(3) 2670print(2)
2641print("Valid enum type:", "Static") 2671print("Valid enum type:", "Static")
2642do 2672do
2643 print(123, "hello") 2673 print(123, "hello")
diff --git a/spec/outputs/codes_from_doc_zh.lua b/spec/outputs/codes_from_doc_zh.lua
index 89335c9..2aa354e 100644
--- a/spec/outputs/codes_from_doc_zh.lua
+++ b/spec/outputs/codes_from_doc_zh.lua
@@ -107,7 +107,7 @@ if cond then
107end 107end
108end 108end
109print("yuescript") 109print("yuescript")
110print(3) 110print(2)
111print("有效的枚举类型:", "Static") 111print("有效的枚举类型:", "Static")
112do 112do
113 print(123, "hello") 113 print(123, "hello")
@@ -986,6 +986,36 @@ local arg1 = {
986 a = 0 986 a = 0
987} 987}
988f2(arg1, arg2) 988f2(arg1, arg2)
989local findFirstEven
990findFirstEven = function(list)
991 for _index_0 = 1, #list do
992 local item = list[_index_0]
993 if type(item) == "table" then
994 for _index_1 = 1, #item do
995 local sub = item[_index_1]
996 if sub % 2 == 0 then
997 return sub
998 end
999 end
1000 end
1001 end
1002 return nil
1003end
1004local findFirstEven
1005findFirstEven = function(list)
1006 for _index_0 = 1, #list do
1007 local item = list[_index_0]
1008 if type(item) == "table" then
1009 for _index_1 = 1, #item do
1010 local sub = item[_index_1]
1011 if sub % 2 == 0 then
1012 return sub
1013 end
1014 end
1015 end
1016 end
1017 return nil
1018end
989local f 1019local f
990f = function(...) 1020f = function(...)
991 local t = { 1021 local t = {
@@ -2631,7 +2661,7 @@ if cond then
2631end 2661end
2632end 2662end
2633print("yuescript") 2663print("yuescript")
2634print(3) 2664print(2)
2635print("有效的枚举类型:", "Static") 2665print("有效的枚举类型:", "Static")
2636do 2666do
2637 print(123, "hello") 2667 print(123, "hello")
diff --git a/spec/outputs/compile_doc.lua b/spec/outputs/compile_doc.lua
index 3781fb9..e7d307d 100644
--- a/spec/outputs/compile_doc.lua
+++ b/spec/outputs/compile_doc.lua
@@ -2,11 +2,11 @@ local outputFolder = ...
2local _list_0 = { 2local _list_0 = {
3 { 3 {
4 "codes_from_doc.lua", 4 "codes_from_doc.lua",
5 "doc/docs/doc/README.md" 5 "doc/docs/doc/index.md"
6 }, 6 },
7 { 7 {
8 "codes_from_doc_zh.lua", 8 "codes_from_doc_zh.lua",
9 "doc/docs/zh/doc/README.md" 9 "doc/docs/zh/doc/index.md"
10 } 10 }
11} 11}
12for _index_0 = 1, #_list_0 do 12for _index_0 = 1, #_list_0 do
@@ -18,7 +18,7 @@ for _index_0 = 1, #_list_0 do
18 local to_lua = require("yue").to_lua 18 local to_lua = require("yue").to_lua
19 local text = _with_0:read("*a") 19 local text = _with_0:read("*a")
20 local codes = { } 20 local codes = { }
21 for code in text:gmatch("```moonscript(.-)```") do 21 for code in text:gmatch("```yuescript[\r\n]+(.-)```[^%w]") do
22 local result, err = to_lua(code, { 22 local result, err = to_lua(code, {
23 implicit_return_root = false, 23 implicit_return_root = false,
24 reserve_line_number = false 24 reserve_line_number = false
@@ -30,8 +30,8 @@ for _index_0 = 1, #_list_0 do
30 os.exit(1) 30 os.exit(1)
31 end 31 end
32 end 32 end
33 for code in text:gmatch("<pre>(.-)</pre>") do 33 for code in text:gmatch("```yue[\r\n]+(.-)```[^%w]") do
34 local result, err = to_lua(code:gsub("&lt;", "<"):gsub("&gt;", ">"), { 34 local result, err = to_lua(code, {
35 implicit_return_root = false, 35 implicit_return_root = false,
36 reserve_line_number = false 36 reserve_line_number = false
37 }) 37 })