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/inputs/compile_doc.yue | |
| parent | 8d2a049286131ad6920262a96d365813eca8b780 (diff) | |
| download | yuescript-ffa06586ba5b04bf9c223b41fe66cdb813ba1b34.tar.gz yuescript-ffa06586ba5b04bf9c223b41fe66cdb813ba1b34.tar.bz2 yuescript-ffa06586ba5b04bf9c223b41fe66cdb813ba1b34.zip | |
Splited docs.
Diffstat (limited to 'spec/inputs/compile_doc.yue')
| -rw-r--r-- | spec/inputs/compile_doc.yue | 101 |
1 files changed, 80 insertions, 21 deletions
diff --git a/spec/inputs/compile_doc.yue b/spec/inputs/compile_doc.yue index db0464b..45a0b16 100644 --- a/spec/inputs/compile_doc.yue +++ b/spec/inputs/compile_doc.yue | |||
| @@ -1,24 +1,83 @@ | |||
| 1 | outputFolder = ... | 1 | outputFolder = ... |
| 2 | for [compiledFile, docFile] in *[ | 2 | for [compiledFile, docFiles] in *[ |
| 3 | ["codes_from_doc.lua", "doc/docs/doc/index.md"] | 3 | ["codes_from_doc.lua", [ |
| 4 | ["codes_from_doc_zh.lua", "doc/docs/zh/doc/index.md"] | 4 | "doc/docs/doc/introduction.md" |
| 5 | "doc/docs/doc/macro.md" | ||
| 6 | "doc/docs/doc/operator.md" | ||
| 7 | "doc/docs/doc/module.md" | ||
| 8 | "doc/docs/doc/assignment.md" | ||
| 9 | "doc/docs/doc/destructuring-assignment.md" | ||
| 10 | "doc/docs/doc/if-assignment.md" | ||
| 11 | "doc/docs/doc/varargs-assignment.md" | ||
| 12 | "doc/docs/doc/whitespace.md" | ||
| 13 | "doc/docs/doc/comment.md" | ||
| 14 | "doc/docs/doc/try.md" | ||
| 15 | "doc/docs/doc/attributes.md" | ||
| 16 | "doc/docs/doc/literals.md" | ||
| 17 | "doc/docs/doc/function-literals.md" | ||
| 18 | "doc/docs/doc/backcalls.md" | ||
| 19 | "doc/docs/doc/table-literals.md" | ||
| 20 | "doc/docs/doc/comprehensions.md" | ||
| 21 | "doc/docs/doc/for-loop.md" | ||
| 22 | "doc/docs/doc/while-loop.md" | ||
| 23 | "doc/docs/doc/continue.md" | ||
| 24 | "doc/docs/doc/conditionals.md" | ||
| 25 | "doc/docs/doc/line-decorators.md" | ||
| 26 | "doc/docs/doc/switch.md" | ||
| 27 | "doc/docs/doc/object-oriented-programming.md" | ||
| 28 | "doc/docs/doc/with-statement.md" | ||
| 29 | "doc/docs/doc/do.md" | ||
| 30 | "doc/docs/doc/function-stubs.md" | ||
| 31 | "doc/docs/doc/the-using-clause-controlling-destructive-assignment.md" | ||
| 32 | ]] | ||
| 33 | ["codes_from_doc_zh.lua", [ | ||
| 34 | "doc/docs/zh/doc/introduction.md" | ||
| 35 | "doc/docs/zh/doc/macro.md" | ||
| 36 | "doc/docs/zh/doc/operator.md" | ||
| 37 | "doc/docs/zh/doc/module.md" | ||
| 38 | "doc/docs/zh/doc/assignment.md" | ||
| 39 | "doc/docs/zh/doc/destructuring-assignment.md" | ||
| 40 | "doc/docs/zh/doc/if-assignment.md" | ||
| 41 | "doc/docs/zh/doc/varargs-assignment.md" | ||
| 42 | "doc/docs/zh/doc/whitespace.md" | ||
| 43 | "doc/docs/zh/doc/comment.md" | ||
| 44 | "doc/docs/zh/doc/try.md" | ||
| 45 | "doc/docs/zh/doc/attributes.md" | ||
| 46 | "doc/docs/zh/doc/literals.md" | ||
| 47 | "doc/docs/zh/doc/function-literals.md" | ||
| 48 | "doc/docs/zh/doc/backcalls.md" | ||
| 49 | "doc/docs/zh/doc/table-literals.md" | ||
| 50 | "doc/docs/zh/doc/comprehensions.md" | ||
| 51 | "doc/docs/zh/doc/for-loop.md" | ||
| 52 | "doc/docs/zh/doc/while-loop.md" | ||
| 53 | "doc/docs/zh/doc/continue.md" | ||
| 54 | "doc/docs/zh/doc/conditionals.md" | ||
| 55 | "doc/docs/zh/doc/line-decorators.md" | ||
| 56 | "doc/docs/zh/doc/switch.md" | ||
| 57 | "doc/docs/zh/doc/object-oriented-programming.md" | ||
| 58 | "doc/docs/zh/doc/with-statement.md" | ||
| 59 | "doc/docs/zh/doc/do.md" | ||
| 60 | "doc/docs/zh/doc/function-stubs.md" | ||
| 61 | "doc/docs/zh/doc/the-using-clause-controlling-destructive-assignment.md" | ||
| 62 | ]] | ||
| 5 | ] | 63 | ] |
| 6 | close input = with? io.open docFile | 64 | codes = [] |
| 7 | import "yue" as :to_lua | 65 | for docFile in *docFiles |
| 8 | text = \read "*a" | 66 | close input = with? io.open docFile |
| 9 | codes = [] | 67 | import "yue" as :to_lua |
| 10 | for code in text\gmatch "```yuescript[\r\n]+(.-)```[^%w]" | 68 | text = \read "*a" |
| 11 | if result, err := to_lua code, implicit_return_root: false, reserve_line_number: false | 69 | for code in text\gmatch "```yuescript[\r\n]+(.-)```[^%w]" |
| 12 | codes[] = result | 70 | if result, err := to_lua code, implicit_return_root: false, reserve_line_number: false |
| 13 | elseif not err\match "macro exporting module only accepts macro definition" | 71 | codes[] = result |
| 14 | print err | 72 | elseif not err\match "macro exporting module only accepts macro definition" |
| 15 | os.exit 1 | 73 | print err |
| 16 | for code in text\gmatch "```yue[\r\n]+(.-)```[^%w]" | 74 | os.exit 1 |
| 17 | if result, err := to_lua code, implicit_return_root: false, reserve_line_number: false | 75 | for code in text\gmatch "```yue[\r\n]+(.-)```[^%w]" |
| 18 | codes[] = result | 76 | if result, err := to_lua code, implicit_return_root: false, reserve_line_number: false |
| 19 | else | 77 | codes[] = result |
| 20 | print err | 78 | else |
| 21 | os.exit 1 | 79 | print err |
| 22 | close output = with io.open "#{outputFolder}/#{compiledFile}", "w+" | 80 | os.exit 1 |
| 23 | \write table.concat codes | 81 | close output = with io.open "#{outputFolder}/#{compiledFile}", "w+" |
| 82 | \write table.concat codes | ||
| 24 | 83 | ||
