1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
local outputFolder = ...
local getFiles
getFiles = function(locale)
if locale == "en" then
locale = ""
else
locale = tostring(locale) .. "/"
end
return {
"doc/docs/" .. tostring(locale) .. "doc/index.md",
"doc/docs/" .. tostring(locale) .. "doc/advanced/do.md",
"doc/docs/" .. tostring(locale) .. "doc/advanced/line-decorators.md",
"doc/docs/" .. tostring(locale) .. "doc/advanced/macro.md",
"doc/docs/" .. tostring(locale) .. "doc/advanced/module.md",
"doc/docs/" .. tostring(locale) .. "doc/advanced/try.md",
"doc/docs/" .. tostring(locale) .. "doc/data-structures/table-literals.md",
"doc/docs/" .. tostring(locale) .. "doc/data-structures/comprehensions.md",
"doc/docs/" .. tostring(locale) .. "doc/objects/object-oriented-programming.md",
"doc/docs/" .. tostring(locale) .. "doc/objects/with-statement.md",
"doc/docs/" .. tostring(locale) .. "doc/assignment/assignment.md",
"doc/docs/" .. tostring(locale) .. "doc/assignment/varargs-assignment.md",
"doc/docs/" .. tostring(locale) .. "doc/assignment/if-assignment.md",
"doc/docs/" .. tostring(locale) .. "doc/assignment/destructuring-assignment.md",
"doc/docs/" .. tostring(locale) .. "doc/assignment/the-using-clause-controlling-destructive-assignment.md",
"doc/docs/" .. tostring(locale) .. "doc/getting-started/usage.md",
"doc/docs/" .. tostring(locale) .. "doc/getting-started/introduction.md",
"doc/docs/" .. tostring(locale) .. "doc/getting-started/installation.md",
"doc/docs/" .. tostring(locale) .. "doc/control-flow/conditionals.md",
"doc/docs/" .. tostring(locale) .. "doc/control-flow/for-loop.md",
"doc/docs/" .. tostring(locale) .. "doc/control-flow/continue.md",
"doc/docs/" .. tostring(locale) .. "doc/control-flow/switch.md",
"doc/docs/" .. tostring(locale) .. "doc/control-flow/while-loop.md",
"doc/docs/" .. tostring(locale) .. "doc/functions/function-stubs.md",
"doc/docs/" .. tostring(locale) .. "doc/functions/backcalls.md",
"doc/docs/" .. tostring(locale) .. "doc/functions/function-literals.md",
"doc/docs/" .. tostring(locale) .. "doc/language-basics/whitespace.md",
"doc/docs/" .. tostring(locale) .. "doc/language-basics/comment.md",
"doc/docs/" .. tostring(locale) .. "doc/language-basics/attributes.md",
"doc/docs/" .. tostring(locale) .. "doc/language-basics/operator.md",
"doc/docs/" .. tostring(locale) .. "doc/language-basics/literals.md",
"doc/docs/" .. tostring(locale) .. "doc/reference/license-mit.md",
"doc/docs/" .. tostring(locale) .. "doc/reference/the-yuescript-library.md"
}
end
local docs
do
local _accum_0 = { }
local _len_0 = 1
local _list_0 = {
"en",
"zh",
"pt-br",
"de",
"id-id"
}
for _index_0 = 1, #_list_0 do
local locale = _list_0[_index_0]
_accum_0[_len_0] = {
"codes_from_doc_" .. tostring(locale) .. ".lua",
getFiles(locale)
}
_len_0 = _len_0 + 1
end
docs = _accum_0
end
for _index_0 = 1, #docs do
local _des_0 = docs[_index_0]
local compiledFile, docFiles = _des_0[1], _des_0[2]
local codes = { }
for _index_1 = 1, #docFiles do
local docFile = docFiles[_index_1]
local input
local _with_0 = io.open(docFile)
if _with_0 ~= nil then
local to_lua = require("yue").to_lua
local text = _with_0:read("*a")
for code in text:gmatch("```yuescript[\r\n]+(.-)```[^%w]") do
local result, err = to_lua(code, {
implicit_return_root = false,
reserve_line_number = false
})
if result then
codes[#codes + 1] = result
elseif not err:match("macro exporting module only accepts macro definition") then
print(err)
os.exit(1)
end
end
for code in text:gmatch("```yue[\r\n]+(.-)```[^%w]") do
local result, err = to_lua(code, {
implicit_return_root = false,
reserve_line_number = false
})
if result then
codes[#codes + 1] = result
else
print(err)
os.exit(1)
end
end
end
input = _with_0
local _close_0 <close> = input
end
local output
local _with_0 = io.open(tostring(outputFolder) .. "/" .. tostring(compiledFile), "w+")
_with_0:write(table.concat(codes))
output = _with_0
local _close_0 <close> = output
end
|