moved tools
This commit is contained in:
2
.github/workflows/docs.yml
vendored
2
.github/workflows/docs.yml
vendored
@@ -35,7 +35,7 @@ jobs:
|
||||
run: |
|
||||
find src -type f -name "*.lua" | while read file; do
|
||||
filename=$(basename "$file")
|
||||
lua markdown.lua "$file" "build_docs/docs/references/${filename%.lua}.md"
|
||||
lua tools/markdown.lua "$file" "build_docs/docs/references/${filename%.lua}.md"
|
||||
done
|
||||
- name: Deploy
|
||||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||
|
||||
2
.github/workflows/lualsgen.yml
vendored
2
.github/workflows/lualsgen.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
||||
|
||||
- name: Generate LuaLS definitions
|
||||
run: |
|
||||
lua annotationParser.lua src/elements src/LuaLS.lua
|
||||
lua tools/annotationParser.lua src/elements src/LuaLS.lua
|
||||
|
||||
- name: Commit changes
|
||||
if: github.event_name == 'push'
|
||||
|
||||
203
LuaLS.lua
203
LuaLS.lua
@@ -1,203 +0,0 @@
|
||||
---@class Button
|
||||
local Button = {}
|
||||
|
||||
--- The event that is triggered when the button is clicked
|
||||
---@generic Element: Button
|
||||
---@param self Element
|
||||
---@param callback function
|
||||
---@return Element
|
||||
function Button:onMouseClick(callback)
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
---@class Container
|
||||
local Container = {}
|
||||
|
||||
--- Adds a new Button to the container
|
||||
---@generic Element: Container
|
||||
---@param self Element
|
||||
---@return Button
|
||||
function Container:addButton()
|
||||
return self
|
||||
end
|
||||
|
||||
--- Adds a new Container to the container
|
||||
---@generic Element: Container
|
||||
---@param self Element
|
||||
---@return Container
|
||||
function Container:addContainer()
|
||||
return self
|
||||
end
|
||||
|
||||
--- Adds a new Frame to the container
|
||||
---@generic Element: Container
|
||||
---@param self Element
|
||||
---@return Frame
|
||||
function Container:addFrame()
|
||||
return self
|
||||
end
|
||||
|
||||
--- Adds a new VisualElement to the container
|
||||
---@generic Element: Container
|
||||
---@param self Element
|
||||
---@return VisualElement
|
||||
function Container:addVisualElement()
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
---@class VisualElement
|
||||
---@field x number
|
||||
---@field y number
|
||||
---@field z number
|
||||
---@field width number
|
||||
---@field height number
|
||||
---@field background color
|
||||
---@field foreground color
|
||||
---@field clicked boolean
|
||||
local VisualElement = {}
|
||||
|
||||
--- Gets the x position of the element
|
||||
---@generic Element: VisualElement
|
||||
---@param self Element
|
||||
---@return number
|
||||
function VisualElement:getX()
|
||||
return self.x
|
||||
end
|
||||
|
||||
--- Sets the x position of the element
|
||||
---@generic Element: VisualElement
|
||||
---@param self Element
|
||||
---@param x number
|
||||
---@return Element
|
||||
function VisualElement:setX(x)
|
||||
self.x = x
|
||||
return self
|
||||
end
|
||||
|
||||
--- Gets the y position of the element
|
||||
---@generic Element: VisualElement
|
||||
---@param self Element
|
||||
---@return number
|
||||
function VisualElement:getY()
|
||||
return self.y
|
||||
end
|
||||
|
||||
--- Sets the y position of the element
|
||||
---@generic Element: VisualElement
|
||||
---@param self Element
|
||||
---@param y number
|
||||
---@return Element
|
||||
function VisualElement:setY(y)
|
||||
self.y = y
|
||||
return self
|
||||
end
|
||||
|
||||
--- Gets the z position of the element
|
||||
---@generic Element: VisualElement
|
||||
---@param self Element
|
||||
---@return number
|
||||
function VisualElement:getZ()
|
||||
return self.z
|
||||
end
|
||||
|
||||
--- Sets the z position of the element
|
||||
---@generic Element: VisualElement
|
||||
---@param self Element
|
||||
---@param z number
|
||||
---@return Element
|
||||
function VisualElement:setZ(z)
|
||||
self.z = z
|
||||
return self
|
||||
end
|
||||
|
||||
--- Gets the width of the element
|
||||
---@generic Element: VisualElement
|
||||
---@param self Element
|
||||
---@return number
|
||||
function VisualElement:getWidth()
|
||||
return self.width
|
||||
end
|
||||
|
||||
--- Sets the width of the element
|
||||
---@generic Element: VisualElement
|
||||
---@param self Element
|
||||
---@param width number
|
||||
---@return Element
|
||||
function VisualElement:setWidth(width)
|
||||
self.width = width
|
||||
return self
|
||||
end
|
||||
|
||||
--- Gets the height of the element
|
||||
---@generic Element: VisualElement
|
||||
---@param self Element
|
||||
---@return number
|
||||
function VisualElement:getHeight()
|
||||
return self.height
|
||||
end
|
||||
|
||||
--- Sets the height of the element
|
||||
---@generic Element: VisualElement
|
||||
---@param self Element
|
||||
---@param height number
|
||||
---@return Element
|
||||
function VisualElement:setHeight(height)
|
||||
self.height = height
|
||||
return self
|
||||
end
|
||||
|
||||
--- Gets the background color of the element
|
||||
---@generic Element: VisualElement
|
||||
---@param self Element
|
||||
---@return color
|
||||
function VisualElement:getBackground()
|
||||
return self.background
|
||||
end
|
||||
|
||||
--- Sets the background color of the element
|
||||
---@generic Element: VisualElement
|
||||
---@param self Element
|
||||
---@param background color
|
||||
---@return Element
|
||||
function VisualElement:setBackground(background)
|
||||
self.background = background
|
||||
return self
|
||||
end
|
||||
|
||||
--- Gets the foreground color of the element
|
||||
---@generic Element: VisualElement
|
||||
---@param self Element
|
||||
---@return color
|
||||
function VisualElement:getForeground()
|
||||
return self.foreground
|
||||
end
|
||||
|
||||
--- Sets the foreground color of the element
|
||||
---@generic Element: VisualElement
|
||||
---@param self Element
|
||||
---@param foreground color
|
||||
---@return Element
|
||||
function VisualElement:setForeground(foreground)
|
||||
self.foreground = foreground
|
||||
return self
|
||||
end
|
||||
|
||||
--- Gets the element is currently clicked
|
||||
---@generic Element: VisualElement
|
||||
---@param self Element
|
||||
---@return boolean
|
||||
function VisualElement:getClicked()
|
||||
return self.clicked
|
||||
end
|
||||
|
||||
--- Sets the element is currently clicked
|
||||
---@generic Element: VisualElement
|
||||
---@param self Element
|
||||
---@param clicked boolean
|
||||
---@return Element
|
||||
function VisualElement:setClicked(clicked)
|
||||
self.clicked = clicked
|
||||
return self
|
||||
end
|
||||
31
example.lua
31
example.lua
@@ -1,31 +0,0 @@
|
||||
---@generic Element: Animal
|
||||
---@class Animal
|
||||
---@field setName fun(self: Element, name: string): Element
|
||||
local Animal = {}
|
||||
|
||||
---@class Dog : Animal
|
||||
---@field setSpeed fun(self: Dog, speed: number): Dog
|
||||
local Dog = setmetatable({}, { __index = Animal })
|
||||
|
||||
---@generic Element: Animal
|
||||
---@param self Element
|
||||
---@param length string
|
||||
---@return Element
|
||||
function Animal:setLength(length)
|
||||
self.length = length
|
||||
return self
|
||||
end
|
||||
|
||||
function Dog:setSpeed(speed)
|
||||
self.speed = speed
|
||||
return self
|
||||
end
|
||||
|
||||
---@return Dog
|
||||
function Dog.new()
|
||||
return setmetatable({}, { __index = Dog })
|
||||
end
|
||||
|
||||
local dog = Dog.new()
|
||||
dog:setName("Rex")
|
||||
:setSpeed(10)
|
||||
@@ -31,7 +31,7 @@ jobs:
|
||||
|
||||
echo "Creating minification script..."
|
||||
cat > minify_script.lua << 'EOL'
|
||||
local minify = loadfile("minify.lua")()
|
||||
local minify = loadfile("tools/minify.lua")()
|
||||
local lfs = require("lfs")
|
||||
|
||||
local files = {}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
local function parseProperty(line)
|
||||
-- Matches: ---@property name type default description
|
||||
|
||||
local name, type, default, description = line:match("%-%-%-@property%s+(%w+)%s+(%w+)%s+(.-)%s+(.*)")
|
||||
|
||||
|
||||
if name and type then
|
||||
-- Generate field annotation
|
||||
|
||||
local fieldDef = string.format("---@field %s %s\n", name, type)
|
||||
|
||||
-- Generate getter annotation and function
|
||||
|
||||
local getterDoc = string.format([[
|
||||
--- Gets the %s
|
||||
---@generic T: %s
|
||||
@@ -20,7 +19,6 @@ function VisualElement:get%s()
|
||||
end
|
||||
]], name:sub(1,1):upper() .. name:sub(2), name)
|
||||
|
||||
-- Generate setter annotation and function
|
||||
local setterDoc = string.format([[
|
||||
--- Sets the %s
|
||||
---@generic T: %s
|
||||
@@ -96,7 +94,7 @@ local function collectAllClassNames(folder)
|
||||
if f then
|
||||
local content = f:read("*a")
|
||||
f:close()
|
||||
|
||||
|
||||
local className = findClassName(content)
|
||||
if className and className ~= "BaseFrame" then
|
||||
table.insert(classes, className)
|
||||
@@ -184,8 +182,7 @@ end
|
||||
local function parseFolder(folder, destinationFile)
|
||||
local allClasses = collectAllClassNames(folder)
|
||||
local allContent = {}
|
||||
|
||||
-- Get list of files
|
||||
|
||||
for file in io.popen('ls "' .. folder .. '"'):lines() do
|
||||
if file:match("%.lua$") then
|
||||
local f = io.open(folder .. "/" .. file, "r")
|
||||
@@ -206,7 +203,6 @@ local function parseFolder(folder, destinationFile)
|
||||
end
|
||||
end
|
||||
|
||||
-- Write output file
|
||||
local f = io.open(destinationFile, "w")
|
||||
if f then
|
||||
f:write(table.concat(allContent, "\n\n"))
|
||||
Reference in New Issue
Block a user