From e65e6510e028759430bd0c6fd6e1771a7a56bbb4 Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Mon, 24 Feb 2025 23:13:28 +0100 Subject: [PATCH] Separated protected functions from public functions --- src/plugins/pluginTemplate.lua | 23 ----------------- src/plugins/reactive.lua | 1 - tools/generate-docs.lua | 1 - tools/markdown.lua | 45 +++++++++++++++++++++++++++++++--- 4 files changed, 42 insertions(+), 28 deletions(-) delete mode 100644 src/plugins/pluginTemplate.lua diff --git a/src/plugins/pluginTemplate.lua b/src/plugins/pluginTemplate.lua deleted file mode 100644 index bc56f00..0000000 --- a/src/plugins/pluginTemplate.lua +++ /dev/null @@ -1,23 +0,0 @@ --- Will temporary exist so that we don't lose track of how the plugin system works - -local VisualElement = {hooks={init={}}} - --- Called on Class level to define properties and setup before instance is created -function VisualElement.setup(element) - element.defineProperty(element, "testProp", {default = 5, type = "number"}) -end - --- Hooks into existing methods (you can also use init.pre or init.post) -function VisualElement.hooks.init(self) - --self.basalt.LOGGER.debug("VisualElement initialized") -end - --- Adds a new method to the class -function VisualElement:testFunc() - --self.basalt.LOGGER.debug("Hello World", self.get("testProp")) -end - -return { - VisualElement = VisualElement -} - diff --git a/src/plugins/reactive.lua b/src/plugins/reactive.lua index b2ed866..c6710bd 100644 --- a/src/plugins/reactive.lua +++ b/src/plugins/reactive.lua @@ -1,6 +1,5 @@ local errorManager = require("errorManager") local PropertySystem = require("propertySystem") -local log = require("log") local protectedNames = { colors = true, diff --git a/tools/generate-docs.lua b/tools/generate-docs.lua index 10068f6..a25d36b 100644 --- a/tools/generate-docs.lua +++ b/tools/generate-docs.lua @@ -14,7 +14,6 @@ local function processFile(inputFile) local outputFile = "build_docs/docs/references/" .. inputFile:match("^src/(.+)"):gsub("%.lua$", "") ensureDirectory(outputFile) - --print(string.format("Processing: %s -> %s", inputFile, outputFile)) markdown.saveToFile(outputFile, md) end diff --git a/tools/markdown.lua b/tools/markdown.lua index 60d9e67..594d539 100644 --- a/tools/markdown.lua +++ b/tools/markdown.lua @@ -88,10 +88,12 @@ function markdown.parse(content) if(commentType == "desc") then currentBlock.usageIsActive = false table.insert(currentBlock.desc, value) - elseif(commentType == "private")or(commentType == "protected")then + elseif(commentType == "private")then skipNextFunction = true elseif(commentType == "splitClass")then splitNextClass = true + elseif(commentType == "protected")then + currentBlock.protected = true else if(commentType == "module")then currentBlock.usageIsActive = false @@ -318,7 +320,7 @@ local function markdownClassFunctionList(className) end local fList = {} for _, v in pairs(markdown.blocks) do - if(v.type=="function")then + if(v.type=="function")and(v.protected~=true)then if(v.className==className)then table.insert(fList, v) end @@ -345,6 +347,42 @@ local function markdownClassFunctionList(className) return output end +local function markdownProtectedFunctions(className) + if(#markdown.blocks<=0)then + return "" + end + local fList = {} + for _, v in pairs(markdown.blocks) do + if(v.type=="function")and(v.protected==true)then + if(v.className==className)then + table.insert(fList, v) + end + end + end + if(#fList<=0)then + return "" + end + local output = "Protected functions can be overwritten." + output = "\n## Protected Functions\n\n|Method|Returns|Description|\n|---|---|---|\n" + for _, block in pairs(fList) do + if block.type == "function" then + output = output .. "|[" .. block.func .. "](#" .. block.func .. ")|" + if(block["return"]~=nil)then + local returnType = block["return"][1]:match("^(%S+)") + output = output .. returnType.."|" + else + output = output .. "-|" + end + if(block.shortDescription~=nil)then + output = output .. block.shortDescription.."\n" + else + output = output .. "\n" + end + end + end + return output +end + local function markdownClass(block) local output = "# ".. block.className.."\n" if(block.usage~=nil)then @@ -368,9 +406,10 @@ local function markdownClass(block) output = output .. markdownCombinedProperties(block.className) output = output .. markdownEvents(block.className) output = output .. markdownClassFunctionList(block.className) .. "\n" + output = output .. markdownProtectedFunctions(block.className) .. "\n" for k,v in pairs(markdown.blocks) do if(v.type=="function")then - if(v.className==block.className)then + if(v.className==block.className)and(v.protected~=true)then output = output .. markdownFunction(v) end end