aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2026-02-12 10:45:06 +0800
committerLi Jin <dragon-fly@qq.com>2026-02-12 10:45:06 +0800
commit319f49796439e50640cadff1220681a217be98a3 (patch)
treed65021d61b64373d5fb3763ba6375faaebaa1e53 /spec
parentd63779ec0a6f00854f53b48b0f6a67707879b6d1 (diff)
downloadyuescript-319f49796439e50640cadff1220681a217be98a3.tar.gz
yuescript-319f49796439e50640cadff1220681a217be98a3.tar.bz2
yuescript-319f49796439e50640cadff1220681a217be98a3.zip
Added the all-in-one doc.
Diffstat (limited to 'spec')
-rw-r--r--spec/inputs/compile_doc.yue10
-rw-r--r--spec/outputs/codes_from_doc_de.lua24
-rw-r--r--spec/outputs/codes_from_doc_en.lua24
-rw-r--r--spec/outputs/codes_from_doc_id-id.lua24
-rw-r--r--spec/outputs/codes_from_doc_pt-br.lua24
-rw-r--r--spec/outputs/codes_from_doc_zh.lua24
-rw-r--r--spec/outputs/compile_doc.lua26
7 files changed, 148 insertions, 8 deletions
diff --git a/spec/inputs/compile_doc.yue b/spec/inputs/compile_doc.yue
index ab621f8..f6a8d49 100644
--- a/spec/inputs/compile_doc.yue
+++ b/spec/inputs/compile_doc.yue
@@ -1,4 +1,4 @@
1outputFolder = ... 1[outputFolder, docFolder] = {...}
2 2
3getFiles = (locale) -> 3getFiles = (locale) ->
4 locale = if locale == "en" then "" else "#{locale}/" 4 locale = if locale == "en" then "" else "#{locale}/"
@@ -37,13 +37,15 @@ getFiles = (locale) ->
37 "doc/docs/#{locale}doc/reference/license-mit.md" 37 "doc/docs/#{locale}doc/reference/license-mit.md"
38 "doc/docs/#{locale}doc/reference/the-yuescript-library.md" 38 "doc/docs/#{locale}doc/reference/the-yuescript-library.md"
39 ] 39 ]
40docs = [ ["codes_from_doc_#{locale}.lua", getFiles locale] for locale in *["en", "zh", "pt-br", "de", "id-id"]] 40docs = [ ["codes_from_doc_#{locale}.lua", "yue-#{locale}.md", getFiles locale] for locale in *["en", "zh", "pt-br", "de", "id-id"]]
41for [compiledFile, docFiles] in *docs 41for [compiledFile, docFile, docFiles] in *docs
42 codes = [] 42 codes = []
43 docTexts = []
43 for docFile in *docFiles 44 for docFile in *docFiles
44 close input = with? io.open docFile 45 close input = with? io.open docFile
45 import "yue" as :to_lua 46 import "yue" as :to_lua
46 text = \read "*a" 47 text = \read "*a"
48 docTexts[] = text
47 for code in text\gmatch "```yuescript[\r\n]+(.-)```[^%w]" 49 for code in text\gmatch "```yuescript[\r\n]+(.-)```[^%w]"
48 if result, err := to_lua code, implicit_return_root: false, reserve_line_number: false 50 if result, err := to_lua code, implicit_return_root: false, reserve_line_number: false
49 codes[] = result 51 codes[] = result
@@ -58,4 +60,6 @@ for [compiledFile, docFiles] in *docs
58 os.exit 1 60 os.exit 1
59 close output = with io.open "#{outputFolder}/#{compiledFile}", "w+" 61 close output = with io.open "#{outputFolder}/#{compiledFile}", "w+"
60 \write table.concat codes 62 \write table.concat codes
63 close output2 = with io.open "#{docFolder}/#{docFile}", "w+"
64 \write table.concat docTexts, "\n"
61 65
diff --git a/spec/outputs/codes_from_doc_de.lua b/spec/outputs/codes_from_doc_de.lua
index 428f788..4c9ba1d 100644
--- a/spec/outputs/codes_from_doc_de.lua
+++ b/spec/outputs/codes_from_doc_de.lua
@@ -2163,6 +2163,18 @@ repeat
2163 result = _with_0.value 2163 result = _with_0.value
2164 break 2164 break
2165until true 2165until true
2166local a
2167do
2168 local _with_0 = obj
2169 _with_0.x = 1
2170 a = _with_0
2171end
2172local b
2173local _with_0 = obj
2174repeat
2175 b = _with_0.x
2176 break
2177until true
2166local create_person 2178local create_person
2167create_person = function(name, relatives) 2179create_person = function(name, relatives)
2168 local _with_0 = Person() 2180 local _with_0 = Person()
@@ -2209,6 +2221,18 @@ repeat
2209 result = _with_0.value 2221 result = _with_0.value
2210 break 2222 break
2211until true 2223until true
2224local a
2225do
2226 local _with_0 = obj
2227 _with_0.x = 1
2228 a = _with_0
2229end
2230local b
2231local _with_0 = obj
2232repeat
2233 b = _with_0.x
2234 break
2235until true
2212local create_person 2236local create_person
2213create_person = function(name, relatives) 2237create_person = function(name, relatives)
2214 local _with_0 = Person() 2238 local _with_0 = Person()
diff --git a/spec/outputs/codes_from_doc_en.lua b/spec/outputs/codes_from_doc_en.lua
index 4006605..6d822e1 100644
--- a/spec/outputs/codes_from_doc_en.lua
+++ b/spec/outputs/codes_from_doc_en.lua
@@ -2163,6 +2163,18 @@ repeat
2163 result = _with_0.value 2163 result = _with_0.value
2164 break 2164 break
2165until true 2165until true
2166local a
2167do
2168 local _with_0 = obj
2169 _with_0.x = 1
2170 a = _with_0
2171end
2172local b
2173local _with_0 = obj
2174repeat
2175 b = _with_0.x
2176 break
2177until true
2166local create_person 2178local create_person
2167create_person = function(name, relatives) 2179create_person = function(name, relatives)
2168 local _with_0 = Person() 2180 local _with_0 = Person()
@@ -2209,6 +2221,18 @@ repeat
2209 result = _with_0.value 2221 result = _with_0.value
2210 break 2222 break
2211until true 2223until true
2224local a
2225do
2226 local _with_0 = obj
2227 _with_0.x = 1
2228 a = _with_0
2229end
2230local b
2231local _with_0 = obj
2232repeat
2233 b = _with_0.x
2234 break
2235until true
2212local create_person 2236local create_person
2213create_person = function(name, relatives) 2237create_person = function(name, relatives)
2214 local _with_0 = Person() 2238 local _with_0 = Person()
diff --git a/spec/outputs/codes_from_doc_id-id.lua b/spec/outputs/codes_from_doc_id-id.lua
index 7d95eaa..4026240 100644
--- a/spec/outputs/codes_from_doc_id-id.lua
+++ b/spec/outputs/codes_from_doc_id-id.lua
@@ -2163,6 +2163,18 @@ repeat
2163 result = _with_0.value 2163 result = _with_0.value
2164 break 2164 break
2165until true 2165until true
2166local a
2167do
2168 local _with_0 = obj
2169 _with_0.x = 1
2170 a = _with_0
2171end
2172local b
2173local _with_0 = obj
2174repeat
2175 b = _with_0.x
2176 break
2177until true
2166local create_person 2178local create_person
2167create_person = function(name, relatives) 2179create_person = function(name, relatives)
2168 local _with_0 = Person() 2180 local _with_0 = Person()
@@ -2209,6 +2221,18 @@ repeat
2209 result = _with_0.value 2221 result = _with_0.value
2210 break 2222 break
2211until true 2223until true
2224local a
2225do
2226 local _with_0 = obj
2227 _with_0.x = 1
2228 a = _with_0
2229end
2230local b
2231local _with_0 = obj
2232repeat
2233 b = _with_0.x
2234 break
2235until true
2212local create_person 2236local create_person
2213create_person = function(name, relatives) 2237create_person = function(name, relatives)
2214 local _with_0 = Person() 2238 local _with_0 = Person()
diff --git a/spec/outputs/codes_from_doc_pt-br.lua b/spec/outputs/codes_from_doc_pt-br.lua
index caa15d6..0d0c76f 100644
--- a/spec/outputs/codes_from_doc_pt-br.lua
+++ b/spec/outputs/codes_from_doc_pt-br.lua
@@ -2163,6 +2163,18 @@ repeat
2163 result = _with_0.value 2163 result = _with_0.value
2164 break 2164 break
2165until true 2165until true
2166local a
2167do
2168 local _with_0 = obj
2169 _with_0.x = 1
2170 a = _with_0
2171end
2172local b
2173local _with_0 = obj
2174repeat
2175 b = _with_0.x
2176 break
2177until true
2166local create_person 2178local create_person
2167create_person = function(name, relatives) 2179create_person = function(name, relatives)
2168 local _with_0 = Person() 2180 local _with_0 = Person()
@@ -2209,6 +2221,18 @@ repeat
2209 result = _with_0.value 2221 result = _with_0.value
2210 break 2222 break
2211until true 2223until true
2224local a
2225do
2226 local _with_0 = obj
2227 _with_0.x = 1
2228 a = _with_0
2229end
2230local b
2231local _with_0 = obj
2232repeat
2233 b = _with_0.x
2234 break
2235until true
2212local create_person 2236local create_person
2213create_person = function(name, relatives) 2237create_person = function(name, relatives)
2214 local _with_0 = Person() 2238 local _with_0 = Person()
diff --git a/spec/outputs/codes_from_doc_zh.lua b/spec/outputs/codes_from_doc_zh.lua
index 4ff3866..c847841 100644
--- a/spec/outputs/codes_from_doc_zh.lua
+++ b/spec/outputs/codes_from_doc_zh.lua
@@ -2163,6 +2163,18 @@ repeat
2163 result = _with_0.value 2163 result = _with_0.value
2164 break 2164 break
2165until true 2165until true
2166local a
2167do
2168 local _with_0 = obj
2169 _with_0.x = 1
2170 a = _with_0
2171end
2172local b
2173local _with_0 = obj
2174repeat
2175 b = _with_0.x
2176 break
2177until true
2166local create_person 2178local create_person
2167create_person = function(name, relatives) 2179create_person = function(name, relatives)
2168 local _with_0 = Person() 2180 local _with_0 = Person()
@@ -2209,6 +2221,18 @@ repeat
2209 result = _with_0.value 2221 result = _with_0.value
2210 break 2222 break
2211until true 2223until true
2224local a
2225do
2226 local _with_0 = obj
2227 _with_0.x = 1
2228 a = _with_0
2229end
2230local b
2231local _with_0 = obj
2232repeat
2233 b = _with_0.x
2234 break
2235until true
2212local create_person 2236local create_person
2213create_person = function(name, relatives) 2237create_person = function(name, relatives)
2214 local _with_0 = Person() 2238 local _with_0 = Person()
diff --git a/spec/outputs/compile_doc.lua b/spec/outputs/compile_doc.lua
index 8d5c11a..f661bbd 100644
--- a/spec/outputs/compile_doc.lua
+++ b/spec/outputs/compile_doc.lua
@@ -1,4 +1,10 @@
1local outputFolder = ... 1local outputFolder, docFolder
2do
3 local _obj_0 = {
4 ...
5 }
6 outputFolder, docFolder = _obj_0[1], _obj_0[2]
7end
2local getFiles 8local getFiles
3getFiles = function(locale) 9getFiles = function(locale)
4 if locale == "en" then 10 if locale == "en" then
@@ -57,6 +63,7 @@ do
57 local locale = _list_0[_index_0] 63 local locale = _list_0[_index_0]
58 _accum_0[_len_0] = { 64 _accum_0[_len_0] = {
59 "codes_from_doc_" .. tostring(locale) .. ".lua", 65 "codes_from_doc_" .. tostring(locale) .. ".lua",
66 "yue-" .. tostring(locale) .. ".md",
60 getFiles(locale) 67 getFiles(locale)
61 } 68 }
62 _len_0 = _len_0 + 1 69 _len_0 = _len_0 + 1
@@ -65,8 +72,9 @@ do
65end 72end
66for _index_0 = 1, #docs do 73for _index_0 = 1, #docs do
67 local _des_0 = docs[_index_0] 74 local _des_0 = docs[_index_0]
68 local compiledFile, docFiles = _des_0[1], _des_0[2] 75 local compiledFile, docFile, docFiles = _des_0[1], _des_0[2], _des_0[3]
69 local codes = { } 76 local codes = { }
77 local docTexts = { }
70 for _index_1 = 1, #docFiles do 78 for _index_1 = 1, #docFiles do
71 local docFile = docFiles[_index_1] 79 local docFile = docFiles[_index_1]
72 local input 80 local input
@@ -74,6 +82,7 @@ for _index_0 = 1, #docs do
74 if _with_0 ~= nil then 82 if _with_0 ~= nil then
75 local to_lua = require("yue").to_lua 83 local to_lua = require("yue").to_lua
76 local text = _with_0:read("*a") 84 local text = _with_0:read("*a")
85 docTexts[#docTexts + 1] = text
77 for code in text:gmatch("```yuescript[\r\n]+(.-)```[^%w]") do 86 for code in text:gmatch("```yuescript[\r\n]+(.-)```[^%w]") do
78 local result, err = to_lua(code, { 87 local result, err = to_lua(code, {
79 implicit_return_root = false, 88 implicit_return_root = false,
@@ -103,8 +112,15 @@ for _index_0 = 1, #docs do
103 local _close_0 <close> = input 112 local _close_0 <close> = input
104 end 113 end
105 local output 114 local output
106 local _with_0 = io.open(tostring(outputFolder) .. "/" .. tostring(compiledFile), "w+") 115 do
107 _with_0:write(table.concat(codes)) 116 local _with_0 = io.open(tostring(outputFolder) .. "/" .. tostring(compiledFile), "w+")
108 output = _with_0 117 _with_0:write(table.concat(codes))
118 output = _with_0
119 end
109 local _close_0 <close> = output 120 local _close_0 <close> = output
121 local output2
122 local _with_0 = io.open(tostring(docFolder) .. "/" .. tostring(docFile), "w+")
123 _with_0:write(table.concat(docTexts, "\n"))
124 output2 = _with_0
125 local _close_1 <close> = output2
110end 126end