Skip to content

Commit a1c0917

Browse files
committed
Another try
1 parent b68a8c1 commit a1c0917

File tree

3 files changed

+59
-22
lines changed

3 files changed

+59
-22
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ jobs:
3939
run: |
4040
mkdir -p release
4141
lua tools/bundler.lua
42-
# Step 4: Install LuaFileSystem
43-
- name: Install LuaFileSystem
44-
run: luarocks install luafilesystem
45-
# Step 5: Prepare and Generate Documentation
42+
# Step 4: Prepare and Generate Documentation
4643
- name: Prepare docs directory
4744
run: |
4845
# Checkout gh-pages branch in a separate directory
@@ -57,7 +54,7 @@ jobs:
5754
lua tools/generate-docs.lua
5855
5956
cp -r build_docs/docs/references/* gh-pages/docs/references/
60-
# Step 6: Deploy Documentation
57+
# Step 5: Deploy Documentation
6158
- name: Deploy Documentation
6259
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
6360
uses: peaceiris/actions-gh-pages@v3

src/elements/Tree.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ local VisualElement = require("elements/VisualElement")
22
local sub = string.sub
33
---@cofnigDescription The tree element provides a hierarchical view of nodes that can be expanded and collapsed, with support for selection and scrolling.
44

5-
65
--- This is the tree class. It provides a hierarchical view of nodes that can be expanded and collapsed,
76
--- with support for selection and scrolling.
87
---@class Tree : VisualElement

tools/generate-docs.lua

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ local OUT_DIR = arg[2] or 'docs'
66
local BasaltDoc = require('tools/BasaltDoc')
77

88
local fileSystem
9+
910
if fs then
1011
fileSystem = {
1112
list = fs.list,
@@ -20,23 +21,63 @@ if fs then
2021
close = function(file) file.close() end
2122
}
2223
else
23-
local lfs = require("lfs")
24-
fileSystem = {
25-
list = function(dir)
26-
local items = {}
27-
for item in lfs.dir(dir) do
28-
if item ~= "." and item ~= ".." then
29-
table.insert(items, item)
30-
end
24+
local function executeCommand(cmd)
25+
local handle = io.popen(cmd)
26+
local result = handle:read("*a")
27+
local success, _, code = handle:close()
28+
return result, success, code
29+
end
30+
31+
local function pathExists(path)
32+
local result, success = executeCommand("test -e '" .. path .. "' && echo 'exists' || echo 'not_exists'")
33+
return success and result:match("exists")
34+
end
35+
36+
local function isDirectory(path)
37+
local result, success = executeCommand("test -d '" .. path .. "' && echo 'dir' || echo 'not_dir'")
38+
return success and result:match("dir")
39+
end
40+
41+
local function makeDirectory(path)
42+
local _, success = executeCommand("mkdir -p '" .. path .. "'")
43+
return success
44+
end
45+
46+
local function listDirectory(dir)
47+
local result, success = executeCommand("ls -1 '" .. dir .. "' 2>/dev/null || true")
48+
if not success then
49+
return {}
50+
end
51+
52+
local items = {}
53+
for item in result:gmatch("[^\r\n]+") do
54+
if item ~= "" then
55+
table.insert(items, item)
3156
end
32-
return items
33-
end,
34-
combine = function(a, b) return a .. "/" .. b end,
35-
isDir = function(path) return lfs.attributes(path).mode == "directory" end,
36-
exists = function(path) return lfs.attributes(path) ~= nil end,
37-
makeDir = lfs.mkdir,
57+
end
58+
return items
59+
end
60+
61+
local function combinePath(a, b)
62+
if a:sub(-1) == "/" then
63+
return a .. b
64+
else
65+
return a .. "/" .. b
66+
end
67+
end
68+
69+
local function getDirectory(path)
70+
return path:match("(.+)/[^/]*$") or ""
71+
end
72+
73+
fileSystem = {
74+
list = listDirectory,
75+
combine = combinePath,
76+
isDir = isDirectory,
77+
exists = pathExists,
78+
makeDir = makeDirectory,
3879
open = io.open,
39-
getDir = function(path) return path:match("(.+)/") end,
80+
getDir = getDirectory,
4081
readAll = function(file) return file:read("*all") end,
4182
write = function(file, data) file:write(data) end,
4283
close = function(file) file:close() end
@@ -79,7 +120,7 @@ for _, filePath in ipairs(luaFiles) do
79120
local outPath = fileSystem.combine(OUT_DIR, relativePath)
80121

81122
local outDir = fileSystem.getDir(outPath)
82-
if outDir and not fileSystem.exists(outDir) then
123+
if outDir and outDir ~= "" and not fileSystem.exists(outDir) then
83124
fileSystem.makeDir(outDir)
84125
end
85126

0 commit comments

Comments
 (0)