From 8c30ebae2cb337ebca1505019c66b44cfcd4b9bb Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Mon, 10 Feb 2025 17:11:18 +0100 Subject: [PATCH] moved tools --- .github/workflows/docs.yml | 2 +- .github/workflows/lualsgen.yml | 2 +- LuaLS.lua | 203 ------------------ example.lua | 31 --- minify.yml | 2 +- .../annotationParser.lua | 16 +- markdown.lua => tools/markdown.lua | 0 minify.lua => tools/minify.lua | 0 8 files changed, 9 insertions(+), 247 deletions(-) delete mode 100644 LuaLS.lua delete mode 100644 example.lua rename annotationParser.lua => tools/annotationParser.lua (95%) rename markdown.lua => tools/markdown.lua (100%) rename minify.lua => tools/minify.lua (100%) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 4930836..804a73b 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -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' }} diff --git a/.github/workflows/lualsgen.yml b/.github/workflows/lualsgen.yml index 40421dc..6c573e5 100644 --- a/.github/workflows/lualsgen.yml +++ b/.github/workflows/lualsgen.yml @@ -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' diff --git a/LuaLS.lua b/LuaLS.lua deleted file mode 100644 index b7ddfac..0000000 --- a/LuaLS.lua +++ /dev/null @@ -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 diff --git a/example.lua b/example.lua deleted file mode 100644 index 3d422ed..0000000 --- a/example.lua +++ /dev/null @@ -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) diff --git a/minify.yml b/minify.yml index 6bfe0af..1918cae 100644 --- a/minify.yml +++ b/minify.yml @@ -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 = {} diff --git a/annotationParser.lua b/tools/annotationParser.lua similarity index 95% rename from annotationParser.lua rename to tools/annotationParser.lua index 1ffe6c5..8e8750d 100644 --- a/annotationParser.lua +++ b/tools/annotationParser.lua @@ -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")) diff --git a/markdown.lua b/tools/markdown.lua similarity index 100% rename from markdown.lua rename to tools/markdown.lua diff --git a/minify.lua b/tools/minify.lua similarity index 100% rename from minify.lua rename to tools/minify.lua