diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-02-04 16:18:19 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-02-04 16:18:19 +0800 |
| commit | ffa06586ba5b04bf9c223b41fe66cdb813ba1b34 (patch) | |
| tree | 600114d784edb8509fed20f70319ccbb778ba682 /spec/outputs/compile_doc.lua | |
| parent | 8d2a049286131ad6920262a96d365813eca8b780 (diff) | |
| download | yuescript-ffa06586ba5b04bf9c223b41fe66cdb813ba1b34.tar.gz yuescript-ffa06586ba5b04bf9c223b41fe66cdb813ba1b34.tar.bz2 yuescript-ffa06586ba5b04bf9c223b41fe66cdb813ba1b34.zip | |
Splited docs.
Diffstat (limited to 'spec/outputs/compile_doc.lua')
| -rw-r--r-- | spec/outputs/compile_doc.lua | 135 |
1 files changed, 98 insertions, 37 deletions
diff --git a/spec/outputs/compile_doc.lua b/spec/outputs/compile_doc.lua index e7d307d..cb359a1 100644 --- a/spec/outputs/compile_doc.lua +++ b/spec/outputs/compile_doc.lua | |||
| @@ -2,52 +2,113 @@ local outputFolder = ... | |||
| 2 | local _list_0 = { | 2 | local _list_0 = { |
| 3 | { | 3 | { |
| 4 | "codes_from_doc.lua", | 4 | "codes_from_doc.lua", |
| 5 | "doc/docs/doc/index.md" | 5 | { |
| 6 | "doc/docs/doc/introduction.md", | ||
| 7 | "doc/docs/doc/macro.md", | ||
| 8 | "doc/docs/doc/operator.md", | ||
| 9 | "doc/docs/doc/module.md", | ||
| 10 | "doc/docs/doc/assignment.md", | ||
| 11 | "doc/docs/doc/destructuring-assignment.md", | ||
| 12 | "doc/docs/doc/if-assignment.md", | ||
| 13 | "doc/docs/doc/varargs-assignment.md", | ||
| 14 | "doc/docs/doc/whitespace.md", | ||
| 15 | "doc/docs/doc/comment.md", | ||
| 16 | "doc/docs/doc/try.md", | ||
| 17 | "doc/docs/doc/attributes.md", | ||
| 18 | "doc/docs/doc/literals.md", | ||
| 19 | "doc/docs/doc/function-literals.md", | ||
| 20 | "doc/docs/doc/backcalls.md", | ||
| 21 | "doc/docs/doc/table-literals.md", | ||
| 22 | "doc/docs/doc/comprehensions.md", | ||
| 23 | "doc/docs/doc/for-loop.md", | ||
| 24 | "doc/docs/doc/while-loop.md", | ||
| 25 | "doc/docs/doc/continue.md", | ||
| 26 | "doc/docs/doc/conditionals.md", | ||
| 27 | "doc/docs/doc/line-decorators.md", | ||
| 28 | "doc/docs/doc/switch.md", | ||
| 29 | "doc/docs/doc/object-oriented-programming.md", | ||
| 30 | "doc/docs/doc/with-statement.md", | ||
| 31 | "doc/docs/doc/do.md", | ||
| 32 | "doc/docs/doc/function-stubs.md", | ||
| 33 | "doc/docs/doc/the-using-clause-controlling-destructive-assignment.md" | ||
| 34 | } | ||
| 6 | }, | 35 | }, |
| 7 | { | 36 | { |
| 8 | "codes_from_doc_zh.lua", | 37 | "codes_from_doc_zh.lua", |
| 9 | "doc/docs/zh/doc/index.md" | 38 | { |
| 39 | "doc/docs/zh/doc/introduction.md", | ||
| 40 | "doc/docs/zh/doc/macro.md", | ||
| 41 | "doc/docs/zh/doc/operator.md", | ||
| 42 | "doc/docs/zh/doc/module.md", | ||
| 43 | "doc/docs/zh/doc/assignment.md", | ||
| 44 | "doc/docs/zh/doc/destructuring-assignment.md", | ||
| 45 | "doc/docs/zh/doc/if-assignment.md", | ||
| 46 | "doc/docs/zh/doc/varargs-assignment.md", | ||
| 47 | "doc/docs/zh/doc/whitespace.md", | ||
| 48 | "doc/docs/zh/doc/comment.md", | ||
| 49 | "doc/docs/zh/doc/try.md", | ||
| 50 | "doc/docs/zh/doc/attributes.md", | ||
| 51 | "doc/docs/zh/doc/literals.md", | ||
| 52 | "doc/docs/zh/doc/function-literals.md", | ||
| 53 | "doc/docs/zh/doc/backcalls.md", | ||
| 54 | "doc/docs/zh/doc/table-literals.md", | ||
| 55 | "doc/docs/zh/doc/comprehensions.md", | ||
| 56 | "doc/docs/zh/doc/for-loop.md", | ||
| 57 | "doc/docs/zh/doc/while-loop.md", | ||
| 58 | "doc/docs/zh/doc/continue.md", | ||
| 59 | "doc/docs/zh/doc/conditionals.md", | ||
| 60 | "doc/docs/zh/doc/line-decorators.md", | ||
| 61 | "doc/docs/zh/doc/switch.md", | ||
| 62 | "doc/docs/zh/doc/object-oriented-programming.md", | ||
| 63 | "doc/docs/zh/doc/with-statement.md", | ||
| 64 | "doc/docs/zh/doc/do.md", | ||
| 65 | "doc/docs/zh/doc/function-stubs.md", | ||
| 66 | "doc/docs/zh/doc/the-using-clause-controlling-destructive-assignment.md" | ||
| 67 | } | ||
| 10 | } | 68 | } |
| 11 | } | 69 | } |
| 12 | for _index_0 = 1, #_list_0 do | 70 | for _index_0 = 1, #_list_0 do |
| 13 | local _des_0 = _list_0[_index_0] | 71 | local _des_0 = _list_0[_index_0] |
| 14 | local compiledFile, docFile = _des_0[1], _des_0[2] | 72 | local compiledFile, docFiles = _des_0[1], _des_0[2] |
| 15 | local input | 73 | local codes = { } |
| 16 | local _with_0 = io.open(docFile) | 74 | for _index_1 = 1, #docFiles do |
| 17 | if _with_0 ~= nil then | 75 | local docFile = docFiles[_index_1] |
| 18 | local to_lua = require("yue").to_lua | 76 | local input |
| 19 | local text = _with_0:read("*a") | 77 | local _with_0 = io.open(docFile) |
| 20 | local codes = { } | 78 | if _with_0 ~= nil then |
| 21 | for code in text:gmatch("```yuescript[\r\n]+(.-)```[^%w]") do | 79 | local to_lua = require("yue").to_lua |
| 22 | local result, err = to_lua(code, { | 80 | local text = _with_0:read("*a") |
| 23 | implicit_return_root = false, | 81 | for code in text:gmatch("```yuescript[\r\n]+(.-)```[^%w]") do |
| 24 | reserve_line_number = false | 82 | local result, err = to_lua(code, { |
| 25 | }) | 83 | implicit_return_root = false, |
| 26 | if result then | 84 | reserve_line_number = false |
| 27 | codes[#codes + 1] = result | 85 | }) |
| 28 | elseif not err:match("macro exporting module only accepts macro definition") then | 86 | if result then |
| 29 | print(err) | 87 | codes[#codes + 1] = result |
| 30 | os.exit(1) | 88 | elseif not err:match("macro exporting module only accepts macro definition") then |
| 89 | print(err) | ||
| 90 | os.exit(1) | ||
| 91 | end | ||
| 31 | end | 92 | end |
| 32 | end | 93 | for code in text:gmatch("```yue[\r\n]+(.-)```[^%w]") do |
| 33 | for code in text:gmatch("```yue[\r\n]+(.-)```[^%w]") do | 94 | local result, err = to_lua(code, { |
| 34 | local result, err = to_lua(code, { | 95 | implicit_return_root = false, |
| 35 | implicit_return_root = false, | 96 | reserve_line_number = false |
| 36 | reserve_line_number = false | 97 | }) |
| 37 | }) | 98 | if result then |
| 38 | if result then | 99 | codes[#codes + 1] = result |
| 39 | codes[#codes + 1] = result | 100 | else |
| 40 | else | 101 | print(err) |
| 41 | print(err) | 102 | os.exit(1) |
| 42 | os.exit(1) | 103 | end |
| 43 | end | 104 | end |
| 44 | end | 105 | end |
| 45 | local output | 106 | input = _with_0 |
| 46 | local _with_1 = io.open(tostring(outputFolder) .. "/" .. tostring(compiledFile), "w+") | 107 | local _close_0 <close> = input |
| 47 | _with_1:write(table.concat(codes)) | ||
| 48 | output = _with_1 | ||
| 49 | local _close_0 <close> = output | ||
| 50 | end | 108 | end |
| 51 | input = _with_0 | 109 | local output |
| 52 | local _close_0 <close> = input | 110 | local _with_0 = io.open(tostring(outputFolder) .. "/" .. tostring(compiledFile), "w+") |
| 111 | _with_0:write(table.concat(codes)) | ||
| 112 | output = _with_0 | ||
| 113 | local _close_0 <close> = output | ||
| 53 | end | 114 | end |
