Another try

This commit is contained in:
Robert Jelic
2025-09-13 10:13:47 +02:00
parent b68a8c14f0
commit a1c0917908
3 changed files with 59 additions and 22 deletions

View File

@@ -39,10 +39,7 @@ jobs:
run: |
mkdir -p release
lua tools/bundler.lua
# Step 4: Install LuaFileSystem
- name: Install LuaFileSystem
run: luarocks install luafilesystem
# Step 5: Prepare and Generate Documentation
# Step 4: Prepare and Generate Documentation
- name: Prepare docs directory
run: |
# Checkout gh-pages branch in a separate directory
@@ -57,7 +54,7 @@ jobs:
lua tools/generate-docs.lua
cp -r build_docs/docs/references/* gh-pages/docs/references/
# Step 6: Deploy Documentation
# Step 5: Deploy Documentation
- name: Deploy Documentation
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v3

View File

@@ -2,7 +2,6 @@ local VisualElement = require("elements/VisualElement")
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.
--- This is the tree class. It provides a hierarchical view of nodes that can be expanded and collapsed,
--- with support for selection and scrolling.
---@class Tree : VisualElement

View File

@@ -6,6 +6,7 @@ local OUT_DIR = arg[2] or 'docs'
local BasaltDoc = require('tools/BasaltDoc')
local fileSystem
if fs then
fileSystem = {
list = fs.list,
@@ -20,23 +21,63 @@ if fs then
close = function(file) file.close() end
}
else
local lfs = require("lfs")
fileSystem = {
list = function(dir)
local items = {}
for item in lfs.dir(dir) do
if item ~= "." and item ~= ".." then
table.insert(items, item)
end
local function executeCommand(cmd)
local handle = io.popen(cmd)
local result = handle:read("*a")
local success, _, code = handle:close()
return result, success, code
end
local function pathExists(path)
local result, success = executeCommand("test -e '" .. path .. "' && echo 'exists' || echo 'not_exists'")
return success and result:match("exists")
end
local function isDirectory(path)
local result, success = executeCommand("test -d '" .. path .. "' && echo 'dir' || echo 'not_dir'")
return success and result:match("dir")
end
local function makeDirectory(path)
local _, success = executeCommand("mkdir -p '" .. path .. "'")
return success
end
local function listDirectory(dir)
local result, success = executeCommand("ls -1 '" .. dir .. "' 2>/dev/null || true")
if not success then
return {}
end
local items = {}
for item in result:gmatch("[^\r\n]+") do
if item ~= "" then
table.insert(items, item)
end
return items
end,
combine = function(a, b) return a .. "/" .. b end,
isDir = function(path) return lfs.attributes(path).mode == "directory" end,
exists = function(path) return lfs.attributes(path) ~= nil end,
makeDir = lfs.mkdir,
end
return items
end
local function combinePath(a, b)
if a:sub(-1) == "/" then
return a .. b
else
return a .. "/" .. b
end
end
local function getDirectory(path)
return path:match("(.+)/[^/]*$") or ""
end
fileSystem = {
list = listDirectory,
combine = combinePath,
isDir = isDirectory,
exists = pathExists,
makeDir = makeDirectory,
open = io.open,
getDir = function(path) return path:match("(.+)/") end,
getDir = getDirectory,
readAll = function(file) return file:read("*all") end,
write = function(file, data) file:write(data) end,
close = function(file) file:close() end
@@ -79,7 +120,7 @@ for _, filePath in ipairs(luaFiles) do
local outPath = fileSystem.combine(OUT_DIR, relativePath)
local outDir = fileSystem.getDir(outPath)
if outDir and not fileSystem.exists(outDir) then
if outDir and outDir ~= "" and not fileSystem.exists(outDir) then
fileSystem.makeDir(outDir)
end