diff --git a/src/elements/BaseElement.lua b/src/elements/BaseElement.lua index 6cc4270..09a0802 100644 --- a/src/elements/BaseElement.lua +++ b/src/elements/BaseElement.lua @@ -81,6 +81,10 @@ end --- @return table self The initialized instance --- @protected function BaseElement:init(props, basalt) + if self._initialized then + return self + end + self._initialized = true self._props = props self._values.id = uuid() self.basalt = basalt @@ -122,6 +126,10 @@ end --- @return table self The BaseElement instance --- @protected function BaseElement:postInit() + if self._postInitialized then + return self + end + self._postInitialized = true if(self._props)then for k,v in pairs(self._props)do self.set(k, v) diff --git a/src/elements/Container.lua b/src/elements/Container.lua index b92d52b..d30c4ca 100644 --- a/src/elements/Container.lua +++ b/src/elements/Container.lua @@ -142,6 +142,7 @@ function Container:addChild(child) table.insert(self._values.children, child) child.parent = self + child:postInit() self.set("childrenSorted", false) self:registerChildrenEvents(child) return self diff --git a/src/plugins/animation.lua b/src/plugins/animation.lua index 040d3cb..fdc60c6 100644 --- a/src/plugins/animation.lua +++ b/src/plugins/animation.lua @@ -411,8 +411,6 @@ Animation.registerAnimation("scrollText", { end }) ----@splitClass - --- Adds additional methods for VisualElement when adding animation plugin --- @class VisualElement local VisualElement = {hooks={}} diff --git a/src/plugins/theme.lua b/src/plugins/theme.lua index a5f11bd..660a3f5 100644 --- a/src/plugins/theme.lua +++ b/src/plugins/theme.lua @@ -39,6 +39,8 @@ local themes = { default = defaultTheme } +---@title title + local currentTheme = "default" --- This is the theme plugin. It provides a theming system that allows for consistent styling across elements diff --git a/tools/markdown.lua b/tools/markdown.lua index 59151a8..beb74b2 100644 --- a/tools/markdown.lua +++ b/tools/markdown.lua @@ -18,7 +18,8 @@ local commentTypes = { "protected", "field", "vararg", - "splitClass" + "splitClass", + "title" } local function extractComment(line) @@ -64,13 +65,13 @@ local function getFunctionName(line) return line:match(pattern) end -function markdown.parse(content) +function markdown.parse(content, file) local blocks = {} local properties = {} local combinedProperties = {} local events = {} local fields = {} - local currentBlock = {type = "comment", desc = {}} + local currentBlock = {type = "comment", desc = {}, file = file} local skipNextFunction = false local currentClass = "None" local splitNextClass = false @@ -79,7 +80,7 @@ function markdown.parse(content) if line:match("^%s*$") or line == "" then if hasBlockContent(currentBlock) then table.insert(blocks, currentBlock) - currentBlock = {type = "comment", desc = {}} + currentBlock = {type = "comment", desc = {}, file = file} end else local comment, isDoc = extractComment(line) @@ -94,6 +95,9 @@ function markdown.parse(content) splitNextClass = true elseif(commentType == "protected")then currentBlock.protected = true + elseif(commentType == "title")then + currentBlock.title = value + currentBlock.type = "title" else if(commentType == "module")then currentBlock.usageIsActive = false @@ -435,6 +439,13 @@ local function markdownClass(block) return output end +local function markdownClassGroup(blocks) + +end + +local log = require("Basalt2/src/log") +log._enabled = true +log._logToFile = true function markdown.makeMarkdown() local classes = {} local output = "" @@ -447,6 +458,7 @@ function markdown.makeMarkdown() output = output .. markdownModule(block)]] elseif block.type == "class" then classes[block.className] = {content=markdownClass(block), data=block} + log.debug("Class found: " .. block.className) end end @@ -462,7 +474,7 @@ function markdown.parseFile(source) local input = file:read("*a") file:close() - return markdown.parse(input) + return markdown.parse(input, source) end function markdown.saveToFile(source, output)