Docs
This commit is contained in:
58
.github/workflows/release.yml
vendored
Normal file
58
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
name: Create Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_run:
|
||||||
|
workflows: ["Minify Lua Code"]
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
if: |
|
||||||
|
github.event.workflow_run.conclusion == 'success' &&
|
||||||
|
contains(github.event.workflow_run.head_commit.modified, 'version')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Get Version
|
||||||
|
id: version
|
||||||
|
run: echo "version=$(cat version)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Check if version file changed
|
||||||
|
run: |
|
||||||
|
git fetch origin ${{ github.event.workflow_run.head_branch }}
|
||||||
|
if ! git diff --quiet origin/${{ github.event.workflow_run.head_branch }}^1 origin/${{ github.event.workflow_run.head_branch }} -- version; then
|
||||||
|
echo "Version file was changed"
|
||||||
|
else
|
||||||
|
echo "Version file was not changed"
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
# Add version check
|
||||||
|
- name: Check if version exists
|
||||||
|
run: |
|
||||||
|
if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
|
||||||
|
echo "::error::Version v${{ steps.version.outputs.version }} already exists"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Generate changelog
|
||||||
|
id: changelog
|
||||||
|
uses: heinrichreimer/github-changelog-generator-action@v2.3
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
tag_name: v${{ steps.version.outputs.version }}
|
||||||
|
body_path: CHANGELOG.md
|
||||||
|
files: |
|
||||||
|
CHANGELOG.md
|
||||||
|
release/basalt.lua
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -28,7 +28,7 @@ VisualElement.defineProperty(VisualElement, "height", {default = 1, type = "numb
|
|||||||
VisualElement.defineProperty(VisualElement, "background", {default = colors.black, type = "number", canTriggerRender = true})
|
VisualElement.defineProperty(VisualElement, "background", {default = colors.black, type = "number", canTriggerRender = true})
|
||||||
---@property foreground color white foreground color of the element
|
---@property foreground color white foreground color of the element
|
||||||
VisualElement.defineProperty(VisualElement, "foreground", {default = colors.white, type = "number", canTriggerRender = true})
|
VisualElement.defineProperty(VisualElement, "foreground", {default = colors.white, type = "number", canTriggerRender = true})
|
||||||
---@property clicked boole an false element is currently clicked
|
---@property clicked boolean an false element is currently clicked
|
||||||
VisualElement.defineProperty(VisualElement, "clicked", {default = false, type = "boolean"})
|
VisualElement.defineProperty(VisualElement, "clicked", {default = false, type = "boolean"})
|
||||||
---@property backgroundEnabled boolean true whether the background is enabled
|
---@property backgroundEnabled boolean true whether the background is enabled
|
||||||
VisualElement.defineProperty(VisualElement, "backgroundEnabled", {default = true, type = "boolean", canTriggerRender = true})
|
VisualElement.defineProperty(VisualElement, "backgroundEnabled", {default = true, type = "boolean", canTriggerRender = true})
|
||||||
@@ -53,6 +53,7 @@ VisualElement.defineProperty(VisualElement, "focused", {default = false, type =
|
|||||||
return value
|
return value
|
||||||
end})
|
end})
|
||||||
|
|
||||||
|
---@property visible boolean true whether the element is visible
|
||||||
VisualElement.defineProperty(VisualElement, "visible", {default = true, type = "boolean", canTriggerRender = true, setter=function(self, value)
|
VisualElement.defineProperty(VisualElement, "visible", {default = true, type = "boolean", canTriggerRender = true, setter=function(self, value)
|
||||||
if(self.parent~=nil)then
|
if(self.parent~=nil)then
|
||||||
self.parent.set("childrenSorted", false)
|
self.parent.set("childrenSorted", false)
|
||||||
@@ -61,8 +62,11 @@ VisualElement.defineProperty(VisualElement, "visible", {default = true, type = "
|
|||||||
return value
|
return value
|
||||||
end})
|
end})
|
||||||
|
|
||||||
|
---@combinedProperty position x y
|
||||||
VisualElement.combineProperties(VisualElement, "position", "x", "y")
|
VisualElement.combineProperties(VisualElement, "position", "x", "y")
|
||||||
|
---@combinedProperty size width height
|
||||||
VisualElement.combineProperties(VisualElement, "size", "width", "height")
|
VisualElement.combineProperties(VisualElement, "size", "width", "height")
|
||||||
|
---@combinedProperty color foreground background
|
||||||
VisualElement.combineProperties(VisualElement, "color", "foreground", "background")
|
VisualElement.combineProperties(VisualElement, "color", "foreground", "background")
|
||||||
|
|
||||||
VisualElement.listenTo(VisualElement, "focus")
|
VisualElement.listenTo(VisualElement, "focus")
|
||||||
@@ -80,6 +84,7 @@ function VisualElement.new()
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Initializes the VisualElement instance
|
||||||
function VisualElement:init(props, basalt)
|
function VisualElement:init(props, basalt)
|
||||||
BaseElement.init(self, props, basalt)
|
BaseElement.init(self, props, basalt)
|
||||||
self.set("type", "VisualElement")
|
self.set("type", "VisualElement")
|
||||||
@@ -110,12 +115,23 @@ function VisualElement:textFg(x, y, text, fg)
|
|||||||
self.parent:textFg(x, y, text, fg)
|
self.parent:textFg(x, y, text, fg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Draws a text character with a background at the specified position, used in the rendering system
|
||||||
|
--- @param x number The x position to draw
|
||||||
|
--- @param y number The y position to draw
|
||||||
|
--- @param text string The text char to draw
|
||||||
|
--- @param bg color The background color
|
||||||
function VisualElement:textBg(x, y, text, bg)
|
function VisualElement:textBg(x, y, text, bg)
|
||||||
x = x + self.get("x") - 1
|
x = x + self.get("x") - 1
|
||||||
y = y + self.get("y") - 1
|
y = y + self.get("y") - 1
|
||||||
self.parent:textBg(x, y, text, bg)
|
self.parent:textBg(x, y, text, bg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Draws a text character with a foreground and background at the specified position, used in the rendering system
|
||||||
|
--- @param x number The x position to draw
|
||||||
|
--- @param y number The y position to draw
|
||||||
|
--- @param text string The text char to draw
|
||||||
|
--- @param fg string The foreground color
|
||||||
|
--- @param bg string The background color
|
||||||
function VisualElement:blit(x, y, text, fg, bg)
|
function VisualElement:blit(x, y, text, fg, bg)
|
||||||
x = x + self.get("x") - 1
|
x = x + self.get("x") - 1
|
||||||
y = y + self.get("y") - 1
|
y = y + self.get("y") - 1
|
||||||
@@ -148,6 +164,11 @@ function VisualElement:mouse_click(button, x, y)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Handles a mouse up event
|
||||||
|
--- @param button number The button that was released
|
||||||
|
--- @param x number The x position of the release
|
||||||
|
--- @param y number The y position of the release
|
||||||
|
--- @return boolean release Whether the element was released on the element
|
||||||
function VisualElement:mouse_up(button, x, y)
|
function VisualElement:mouse_up(button, x, y)
|
||||||
self.set("clicked", false)
|
self.set("clicked", false)
|
||||||
if self:isInBounds(x, y) then
|
if self:isInBounds(x, y) then
|
||||||
@@ -157,14 +178,26 @@ function VisualElement:mouse_up(button, x, y)
|
|||||||
self:fireEvent("mouse_release", button, self:getRelativePosition(x, y))
|
self:fireEvent("mouse_release", button, self:getRelativePosition(x, y))
|
||||||
end
|
end
|
||||||
|
|
||||||
function VisualElement:mouse_release()
|
--- Handles a mouse release event
|
||||||
self.set("clicked", false)
|
--- @param button number The button that was released
|
||||||
|
--- @param x number The x position of the release
|
||||||
|
--- @param y number The y position of the release
|
||||||
|
--- @return boolean release Whether the element was released on the element
|
||||||
|
function VisualElement:mouse_release(button, x, y)
|
||||||
|
if self.get("clicked") then
|
||||||
|
self:fireEvent("mouse_release", button, self:getRelativePosition(x, y))
|
||||||
|
self.set("clicked", false)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Handles a focus event
|
||||||
function VisualElement:focus()
|
function VisualElement:focus()
|
||||||
self:fireEvent("focus")
|
self:fireEvent("focus")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Handles a blur event
|
||||||
function VisualElement:blur()
|
function VisualElement:blur()
|
||||||
self:fireEvent("blur")
|
self:fireEvent("blur")
|
||||||
self:setCursor(1,1, false)
|
self:setCursor(1,1, false)
|
||||||
@@ -214,6 +247,10 @@ function VisualElement:getRelativePosition(x, y)
|
|||||||
y - (elementY - 1) - (parentY - 1)
|
y - (elementY - 1) - (parentY - 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Sets the cursor position
|
||||||
|
--- @param x number The x position of the cursor
|
||||||
|
--- @param y number The y position of the cursor
|
||||||
|
--- @param blink boolean Whether the cursor should blink
|
||||||
function VisualElement:setCursor(x, y, blink)
|
function VisualElement:setCursor(x, y, blink)
|
||||||
if self.parent then
|
if self.parent then
|
||||||
local absX, absY = self:getAbsolutePosition(x, y)
|
local absX, absY = self:getAbsolutePosition(x, y)
|
||||||
|
|||||||
@@ -5,23 +5,28 @@ local function ensureDirectory(path)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function processFile(inputFile, outputFile)
|
local function processFile(inputFile)
|
||||||
local f = io.open(inputFile, "r")
|
local f = io.open(inputFile, "r")
|
||||||
local content = f:read("*all")
|
local content = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
|
local outputFile
|
||||||
|
if inputFile:match("^src/[^/]+%.lua$") then
|
||||||
|
outputFile = "build_docs/docs/references/" .. inputFile:match("^src/(.+)"):gsub("%.lua$", ".md")
|
||||||
|
else
|
||||||
|
outputFile = "build_docs/docs/references/" .. inputFile:match("^src/(.+)"):gsub("%.lua$", ".md")
|
||||||
|
end
|
||||||
|
|
||||||
ensureDirectory(outputFile)
|
ensureDirectory(outputFile)
|
||||||
|
print(string.format("Processing: %s -> %s", inputFile, outputFile))
|
||||||
|
|
||||||
local out = io.open(outputFile, "w")
|
local out = io.open(outputFile, "w")
|
||||||
out:write(content)
|
out:write(content)
|
||||||
out:close()
|
out:close()
|
||||||
|
|
||||||
print("Generated docs for: " .. inputFile)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for file in io.popen('find "src" -type f -name "*.lua"'):lines() do
|
for file in io.popen('find "src" -type f -name "*.lua"'):lines() do
|
||||||
if not file:match("LuaLS.lua$") then
|
if not file:match("LuaLS.lua$") then
|
||||||
local outputFile = "build_docs/docs/references/" .. file:gsub("^src/", ""):gsub("%.lua$", ".md")
|
processFile(file)
|
||||||
processFile(file, outputFile)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user