diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-02-12 10:45:06 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-02-12 10:45:06 +0800 |
| commit | 319f49796439e50640cadff1220681a217be98a3 (patch) | |
| tree | d65021d61b64373d5fb3763ba6375faaebaa1e53 /spec/outputs | |
| parent | d63779ec0a6f00854f53b48b0f6a67707879b6d1 (diff) | |
| download | yuescript-319f49796439e50640cadff1220681a217be98a3.tar.gz yuescript-319f49796439e50640cadff1220681a217be98a3.tar.bz2 yuescript-319f49796439e50640cadff1220681a217be98a3.zip | |
Added the all-in-one doc.
Diffstat (limited to 'spec/outputs')
| -rw-r--r-- | spec/outputs/codes_from_doc_de.lua | 24 | ||||
| -rw-r--r-- | spec/outputs/codes_from_doc_en.lua | 24 | ||||
| -rw-r--r-- | spec/outputs/codes_from_doc_id-id.lua | 24 | ||||
| -rw-r--r-- | spec/outputs/codes_from_doc_pt-br.lua | 24 | ||||
| -rw-r--r-- | spec/outputs/codes_from_doc_zh.lua | 24 | ||||
| -rw-r--r-- | spec/outputs/compile_doc.lua | 26 |
6 files changed, 141 insertions, 5 deletions
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 |
| 2165 | until true | 2165 | until true |
| 2166 | local a | ||
| 2167 | do | ||
| 2168 | local _with_0 = obj | ||
| 2169 | _with_0.x = 1 | ||
| 2170 | a = _with_0 | ||
| 2171 | end | ||
| 2172 | local b | ||
| 2173 | local _with_0 = obj | ||
| 2174 | repeat | ||
| 2175 | b = _with_0.x | ||
| 2176 | break | ||
| 2177 | until true | ||
| 2166 | local create_person | 2178 | local create_person |
| 2167 | create_person = function(name, relatives) | 2179 | create_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 |
| 2211 | until true | 2223 | until true |
| 2224 | local a | ||
| 2225 | do | ||
| 2226 | local _with_0 = obj | ||
| 2227 | _with_0.x = 1 | ||
| 2228 | a = _with_0 | ||
| 2229 | end | ||
| 2230 | local b | ||
| 2231 | local _with_0 = obj | ||
| 2232 | repeat | ||
| 2233 | b = _with_0.x | ||
| 2234 | break | ||
| 2235 | until true | ||
| 2212 | local create_person | 2236 | local create_person |
| 2213 | create_person = function(name, relatives) | 2237 | create_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 |
| 2165 | until true | 2165 | until true |
| 2166 | local a | ||
| 2167 | do | ||
| 2168 | local _with_0 = obj | ||
| 2169 | _with_0.x = 1 | ||
| 2170 | a = _with_0 | ||
| 2171 | end | ||
| 2172 | local b | ||
| 2173 | local _with_0 = obj | ||
| 2174 | repeat | ||
| 2175 | b = _with_0.x | ||
| 2176 | break | ||
| 2177 | until true | ||
| 2166 | local create_person | 2178 | local create_person |
| 2167 | create_person = function(name, relatives) | 2179 | create_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 |
| 2211 | until true | 2223 | until true |
| 2224 | local a | ||
| 2225 | do | ||
| 2226 | local _with_0 = obj | ||
| 2227 | _with_0.x = 1 | ||
| 2228 | a = _with_0 | ||
| 2229 | end | ||
| 2230 | local b | ||
| 2231 | local _with_0 = obj | ||
| 2232 | repeat | ||
| 2233 | b = _with_0.x | ||
| 2234 | break | ||
| 2235 | until true | ||
| 2212 | local create_person | 2236 | local create_person |
| 2213 | create_person = function(name, relatives) | 2237 | create_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 |
| 2165 | until true | 2165 | until true |
| 2166 | local a | ||
| 2167 | do | ||
| 2168 | local _with_0 = obj | ||
| 2169 | _with_0.x = 1 | ||
| 2170 | a = _with_0 | ||
| 2171 | end | ||
| 2172 | local b | ||
| 2173 | local _with_0 = obj | ||
| 2174 | repeat | ||
| 2175 | b = _with_0.x | ||
| 2176 | break | ||
| 2177 | until true | ||
| 2166 | local create_person | 2178 | local create_person |
| 2167 | create_person = function(name, relatives) | 2179 | create_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 |
| 2211 | until true | 2223 | until true |
| 2224 | local a | ||
| 2225 | do | ||
| 2226 | local _with_0 = obj | ||
| 2227 | _with_0.x = 1 | ||
| 2228 | a = _with_0 | ||
| 2229 | end | ||
| 2230 | local b | ||
| 2231 | local _with_0 = obj | ||
| 2232 | repeat | ||
| 2233 | b = _with_0.x | ||
| 2234 | break | ||
| 2235 | until true | ||
| 2212 | local create_person | 2236 | local create_person |
| 2213 | create_person = function(name, relatives) | 2237 | create_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 |
| 2165 | until true | 2165 | until true |
| 2166 | local a | ||
| 2167 | do | ||
| 2168 | local _with_0 = obj | ||
| 2169 | _with_0.x = 1 | ||
| 2170 | a = _with_0 | ||
| 2171 | end | ||
| 2172 | local b | ||
| 2173 | local _with_0 = obj | ||
| 2174 | repeat | ||
| 2175 | b = _with_0.x | ||
| 2176 | break | ||
| 2177 | until true | ||
| 2166 | local create_person | 2178 | local create_person |
| 2167 | create_person = function(name, relatives) | 2179 | create_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 |
| 2211 | until true | 2223 | until true |
| 2224 | local a | ||
| 2225 | do | ||
| 2226 | local _with_0 = obj | ||
| 2227 | _with_0.x = 1 | ||
| 2228 | a = _with_0 | ||
| 2229 | end | ||
| 2230 | local b | ||
| 2231 | local _with_0 = obj | ||
| 2232 | repeat | ||
| 2233 | b = _with_0.x | ||
| 2234 | break | ||
| 2235 | until true | ||
| 2212 | local create_person | 2236 | local create_person |
| 2213 | create_person = function(name, relatives) | 2237 | create_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 |
| 2165 | until true | 2165 | until true |
| 2166 | local a | ||
| 2167 | do | ||
| 2168 | local _with_0 = obj | ||
| 2169 | _with_0.x = 1 | ||
| 2170 | a = _with_0 | ||
| 2171 | end | ||
| 2172 | local b | ||
| 2173 | local _with_0 = obj | ||
| 2174 | repeat | ||
| 2175 | b = _with_0.x | ||
| 2176 | break | ||
| 2177 | until true | ||
| 2166 | local create_person | 2178 | local create_person |
| 2167 | create_person = function(name, relatives) | 2179 | create_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 |
| 2211 | until true | 2223 | until true |
| 2224 | local a | ||
| 2225 | do | ||
| 2226 | local _with_0 = obj | ||
| 2227 | _with_0.x = 1 | ||
| 2228 | a = _with_0 | ||
| 2229 | end | ||
| 2230 | local b | ||
| 2231 | local _with_0 = obj | ||
| 2232 | repeat | ||
| 2233 | b = _with_0.x | ||
| 2234 | break | ||
| 2235 | until true | ||
| 2212 | local create_person | 2236 | local create_person |
| 2213 | create_person = function(name, relatives) | 2237 | create_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 @@ | |||
| 1 | local outputFolder = ... | 1 | local outputFolder, docFolder |
| 2 | do | ||
| 3 | local _obj_0 = { | ||
| 4 | ... | ||
| 5 | } | ||
| 6 | outputFolder, docFolder = _obj_0[1], _obj_0[2] | ||
| 7 | end | ||
| 2 | local getFiles | 8 | local getFiles |
| 3 | getFiles = function(locale) | 9 | getFiles = 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 | |||
| 65 | end | 72 | end |
| 66 | for _index_0 = 1, #docs do | 73 | for _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 | ||
| 110 | end | 126 | end |
