Added init fix and small markdown changes

This commit is contained in:
Robert Jelic
2025-04-08 01:30:18 +02:00
parent ff9ffb76aa
commit 4b4b2e3ca7
5 changed files with 28 additions and 7 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -411,8 +411,6 @@ Animation.registerAnimation("scrollText", {
end
})
---@splitClass
--- Adds additional methods for VisualElement when adding animation plugin
--- @class VisualElement
local VisualElement = {hooks={}}

View File

@@ -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

View File

@@ -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)