From 319f49796439e50640cadff1220681a217be98a3 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Thu, 12 Feb 2026 10:45:06 +0800 Subject: Added the all-in-one doc. --- spec/inputs/compile_doc.yue | 10 +++++++--- spec/outputs/codes_from_doc_de.lua | 24 ++++++++++++++++++++++++ spec/outputs/codes_from_doc_en.lua | 24 ++++++++++++++++++++++++ spec/outputs/codes_from_doc_id-id.lua | 24 ++++++++++++++++++++++++ spec/outputs/codes_from_doc_pt-br.lua | 24 ++++++++++++++++++++++++ spec/outputs/codes_from_doc_zh.lua | 24 ++++++++++++++++++++++++ spec/outputs/compile_doc.lua | 26 +++++++++++++++++++++----- 7 files changed, 148 insertions(+), 8 deletions(-) (limited to 'spec') 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 @@ -outputFolder = ... +[outputFolder, docFolder] = {...} getFiles = (locale) -> locale = if locale == "en" then "" else "#{locale}/" @@ -37,13 +37,15 @@ getFiles = (locale) -> "doc/docs/#{locale}doc/reference/license-mit.md" "doc/docs/#{locale}doc/reference/the-yuescript-library.md" ] -docs = [ ["codes_from_doc_#{locale}.lua", getFiles locale] for locale in *["en", "zh", "pt-br", "de", "id-id"]] -for [compiledFile, docFiles] in *docs +docs = [ ["codes_from_doc_#{locale}.lua", "yue-#{locale}.md", getFiles locale] for locale in *["en", "zh", "pt-br", "de", "id-id"]] +for [compiledFile, docFile, docFiles] in *docs codes = [] + docTexts = [] for docFile in *docFiles close input = with? io.open docFile import "yue" as :to_lua text = \read "*a" + docTexts[] = text for code in text\gmatch "```yuescript[\r\n]+(.-)```[^%w]" if result, err := to_lua code, implicit_return_root: false, reserve_line_number: false codes[] = result @@ -58,4 +60,6 @@ for [compiledFile, docFiles] in *docs os.exit 1 close output = with io.open "#{outputFolder}/#{compiledFile}", "w+" \write table.concat codes + close output2 = with io.open "#{docFolder}/#{docFile}", "w+" + \write table.concat docTexts, "\n" 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 result = _with_0.value break until true +local a +do + local _with_0 = obj + _with_0.x = 1 + a = _with_0 +end +local b +local _with_0 = obj +repeat + b = _with_0.x + break +until true local create_person create_person = function(name, relatives) local _with_0 = Person() @@ -2209,6 +2221,18 @@ repeat result = _with_0.value break until true +local a +do + local _with_0 = obj + _with_0.x = 1 + a = _with_0 +end +local b +local _with_0 = obj +repeat + b = _with_0.x + break +until true local create_person create_person = function(name, relatives) 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 result = _with_0.value break until true +local a +do + local _with_0 = obj + _with_0.x = 1 + a = _with_0 +end +local b +local _with_0 = obj +repeat + b = _with_0.x + break +until true local create_person create_person = function(name, relatives) local _with_0 = Person() @@ -2209,6 +2221,18 @@ repeat result = _with_0.value break until true +local a +do + local _with_0 = obj + _with_0.x = 1 + a = _with_0 +end +local b +local _with_0 = obj +repeat + b = _with_0.x + break +until true local create_person create_person = function(name, relatives) 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 result = _with_0.value break until true +local a +do + local _with_0 = obj + _with_0.x = 1 + a = _with_0 +end +local b +local _with_0 = obj +repeat + b = _with_0.x + break +until true local create_person create_person = function(name, relatives) local _with_0 = Person() @@ -2209,6 +2221,18 @@ repeat result = _with_0.value break until true +local a +do + local _with_0 = obj + _with_0.x = 1 + a = _with_0 +end +local b +local _with_0 = obj +repeat + b = _with_0.x + break +until true local create_person create_person = function(name, relatives) 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 result = _with_0.value break until true +local a +do + local _with_0 = obj + _with_0.x = 1 + a = _with_0 +end +local b +local _with_0 = obj +repeat + b = _with_0.x + break +until true local create_person create_person = function(name, relatives) local _with_0 = Person() @@ -2209,6 +2221,18 @@ repeat result = _with_0.value break until true +local a +do + local _with_0 = obj + _with_0.x = 1 + a = _with_0 +end +local b +local _with_0 = obj +repeat + b = _with_0.x + break +until true local create_person create_person = function(name, relatives) 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 result = _with_0.value break until true +local a +do + local _with_0 = obj + _with_0.x = 1 + a = _with_0 +end +local b +local _with_0 = obj +repeat + b = _with_0.x + break +until true local create_person create_person = function(name, relatives) local _with_0 = Person() @@ -2209,6 +2221,18 @@ repeat result = _with_0.value break until true +local a +do + local _with_0 = obj + _with_0.x = 1 + a = _with_0 +end +local b +local _with_0 = obj +repeat + b = _with_0.x + break +until true local create_person create_person = function(name, relatives) 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 @@ -local outputFolder = ... +local outputFolder, docFolder +do + local _obj_0 = { + ... + } + outputFolder, docFolder = _obj_0[1], _obj_0[2] +end local getFiles getFiles = function(locale) if locale == "en" then @@ -57,6 +63,7 @@ do local locale = _list_0[_index_0] _accum_0[_len_0] = { "codes_from_doc_" .. tostring(locale) .. ".lua", + "yue-" .. tostring(locale) .. ".md", getFiles(locale) } _len_0 = _len_0 + 1 @@ -65,8 +72,9 @@ do end for _index_0 = 1, #docs do local _des_0 = docs[_index_0] - local compiledFile, docFiles = _des_0[1], _des_0[2] + local compiledFile, docFile, docFiles = _des_0[1], _des_0[2], _des_0[3] local codes = { } + local docTexts = { } for _index_1 = 1, #docFiles do local docFile = docFiles[_index_1] local input @@ -74,6 +82,7 @@ for _index_0 = 1, #docs do if _with_0 ~= nil then local to_lua = require("yue").to_lua local text = _with_0:read("*a") + docTexts[#docTexts + 1] = text for code in text:gmatch("```yuescript[\r\n]+(.-)```[^%w]") do local result, err = to_lua(code, { implicit_return_root = false, @@ -103,8 +112,15 @@ for _index_0 = 1, #docs do local _close_0 = input end local output - local _with_0 = io.open(tostring(outputFolder) .. "/" .. tostring(compiledFile), "w+") - _with_0:write(table.concat(codes)) - output = _with_0 + do + local _with_0 = io.open(tostring(outputFolder) .. "/" .. tostring(compiledFile), "w+") + _with_0:write(table.concat(codes)) + output = _with_0 + end local _close_0 = output + local output2 + local _with_0 = io.open(tostring(docFolder) .. "/" .. tostring(docFile), "w+") + _with_0:write(table.concat(docTexts, "\n")) + output2 = _with_0 + local _close_1 = output2 end -- cgit v1.2.3-55-g6feb