Files
Basalt2/generate-docs.lua
Robert Jelic 8b6eaccd18 Docs Update
2025-02-18 09:46:32 +01:00

40 lines
1.0 KiB
Lua

local markdown = require("tools/markdown")
local log = require("src/log")
if not fs.exists("docs/references") then
fs.makeDir("docs/references")
end
local function processFile(inputFile)
local parsed = markdown.parseFile(inputFile)
local md = markdown.makeMarkdown(parsed)
local relativePath = inputFile:match("Basalt2/src/(.+)")
if not relativePath then return end
local outputFile = "docs/references/" .. relativePath:gsub("%.lua$", "")
local dir = fs.getDir(outputFile)
if not fs.exists(dir) then
fs.makeDir(dir)
end
--print(string.format("Processing: %s -> %s", inputFile, outputFile))
markdown.saveToFile(outputFile, md)
end
local function processDirectory(path)
for _, file in ipairs(fs.list(path)) do
local fullPath = fs.combine(path, file)
if fs.isDir(fullPath) then
processDirectory(fullPath)
elseif file:match("%.lua$") and not file:match("LuaLS%.lua$") then
processFile(fullPath)
end
end
end
processDirectory("Basalt2/src")