-- Writes the Forge vocabulary -- every layer, look, behaviour, event, condition, and action the -- manifest in assets/Forge/Author.singe declares -- as AsciiDoc, for docs/Forge.adoc to include. -- The manifest is the one source of truth; this keeps the manual from drifting from it. -- -- lua5.4 util/forgeVocabulary.lua > docs/ForgeVocabulary.adoc -- -- Author.singe touches nothing of the engine when it is loaded, only when a game begins, so plain -- Lua can read it. local function keysOf(t) local keys = {} for key in pairs(t or {}) do keys[#keys + 1] = key end table.sort(keys) return keys end -- A parameter and its type, or the words it takes when the manifest lists them. local function paramsText(params, choices) local parts = {} for _, key in ipairs(keysOf(params)) do local words = (choices or {})[key] parts[#parts + 1] = "`" .. key .. "` (" .. (words and table.concat(words, ", ") or params[key]) .. ")" end if #parts == 0 then return "--" end return table.concat(parts, ", ") end local function section(title, set, extra) print("=== " .. title) print("") print('[cols="1,3,2' .. (extra and ',1' or '') .. '"]') print("|===") print("| Name | What it does | Parameters" .. (extra and (" | " .. extra) or "")) print("") for _, name in ipairs(keysOf(set)) do local entry = set[name] print("| `" .. name .. "`") print("| " .. (entry.help or "")) print("| " .. paramsText(entry.params or entry.filter, entry.choices)) if extra then print("| " .. (entry.waits and "yes" or "")) end print("") end print("|===") print("") end dofile("assets/Forge/Author.singe") print("// Generated by util/forgeVocabulary.lua from assets/Forge/Author.singe. Do not edit.") print("") section("Layers", AUTHOR.layers) section("Looks", AUTHOR.looks) section("Behaviours", AUTHOR.behaviours) section("Events", AUTHOR.events) section("Conditions", AUTHOR.conditions) section("Actions", AUTHOR.actions, "Waits")