This commit is contained in:
Robert Jelic
2025-09-13 12:42:28 +02:00
parent ce213cc5d0
commit 487409b31a
2 changed files with 43 additions and 18 deletions

View File

@@ -2,7 +2,6 @@ local VisualElement = require("elements/VisualElement")
local sub = string.sub local sub = string.sub
---@cofnigDescription The tree element provides a hierarchical view of nodes that can be expanded and collapsed, with support for selection and scrolling. ---@cofnigDescription The tree element provides a hierarchical view of nodes that can be expanded and collapsed, with support for selection and scrolling.
--- This is the tree class. It provides a hierarchical view of nodes that can be expanded and collapsed, --- This is the tree class. It provides a hierarchical view of nodes that can be expanded and collapsed,
--- with support for selection and scrolling. --- with support for selection and scrolling.
---@class Tree : VisualElement ---@class Tree : VisualElement

View File

@@ -1,9 +1,17 @@
-- generate-docs.lua
-- Argumente
local arg = arg or {...} local arg = arg or {...}
local SRC_DIR = arg[1] or "src"
local OUT_DIR = arg[2] or "build_docs/docs/references"
local SRC_DIR = arg[1] or 'src' package.path = package.path .. ";./tools/?.lua"
local OUT_DIR = arg[2] or 'build_docs/docs/references'
local BasaltDoc = require('tools/BasaltDoc') local BasaltDoc = require("tools/BasaltDoc")
--------------------------------------------------------
-- Filesystem Abstraction
--------------------------------------------------------
local fileSystem local fileSystem
@@ -23,32 +31,30 @@ if fs then
else else
local function executeCommand(cmd) local function executeCommand(cmd)
local handle = io.popen(cmd) local handle = io.popen(cmd)
if not handle then return "", false, 1 end
local result = handle:read("*a") local result = handle:read("*a")
local success, _, code = handle:close() local ok, _, code = handle:close()
return result, success, code return result, ok, code
end end
local function pathExists(path) local function pathExists(path)
local result, success = executeCommand("test -e '" .. path .. "' && echo 'exists' || echo 'not_exists'") local _, _, code = executeCommand("[ -e '" .. path .. "' ]")
return success and result:match("exists") return code == 0
end end
local function isDirectory(path) local function isDirectory(path)
local result, success = executeCommand("test -d '" .. path .. "' && echo 'dir' || echo 'not_dir'") local _, _, code = executeCommand("[ -d '" .. path .. "' ]")
return success and result:match("dir") return code == 0
end end
local function makeDirectory(path) local function makeDirectory(path)
local _, success = executeCommand("mkdir -p '" .. path .. "'") local _, ok = executeCommand("mkdir -p '" .. path .. "'")
return success return ok
end end
local function listDirectory(dir) local function listDirectory(dir)
local result, success = executeCommand("ls -1 '" .. dir .. "' 2>/dev/null || true") local result, ok = executeCommand("ls -1 '" .. dir .. "' 2>/dev/null")
if not success then if not ok then return {} end
return {}
end
local items = {} local items = {}
for item in result:gmatch("[^\r\n]+") do for item in result:gmatch("[^\r\n]+") do
if item ~= "" then if item ~= "" then
@@ -84,6 +90,14 @@ else
} }
end end
--------------------------------------------------------
-- Main
--------------------------------------------------------
print("Starting documentation generation...")
print("Source directory: " .. SRC_DIR)
print("Output directory: " .. OUT_DIR)
if not fileSystem.exists(OUT_DIR) then if not fileSystem.exists(OUT_DIR) then
print("Output directory does not exist, creating it...") print("Output directory does not exist, creating it...")
fileSystem.makeDir(OUT_DIR) fileSystem.makeDir(OUT_DIR)
@@ -92,17 +106,29 @@ else
end end
local function getLuaFiles(dir) local function getLuaFiles(dir)
print("Scanning directory: " .. dir)
if not fileSystem.exists(dir) then
print("Directory does not exist: " .. dir)
return {}
end
local files = {} local files = {}
local list = fileSystem.list(dir) local list = fileSystem.list(dir)
print("Found " .. #list .. " items in " .. dir)
for _, item in ipairs(list) do for _, item in ipairs(list) do
local path = fileSystem.combine(dir, item) local path = fileSystem.combine(dir, item)
if fileSystem.isDir(path) then if fileSystem.isDir(path) then
print(" -> Directory, scanning recursively: " .. path)
local subFiles = getLuaFiles(path) local subFiles = getLuaFiles(path)
for _, subFile in ipairs(subFiles) do for _, subFile in ipairs(subFiles) do
table.insert(files, subFile) table.insert(files, subFile)
end end
elseif item:match("%.lua$") then elseif item:match("%.lua$") then
print(" -> Lua file found: " .. path)
table.insert(files, path) table.insert(files, path)
else
print(" -> Skipping: " .. item)
end end
end end
return files return files
@@ -141,4 +167,4 @@ for _, filePath in ipairs(luaFiles) do
end end
end end
print("Documentation generation complete.") print("Documentation generation complete.")