Skip to content

Commit 10fe8d9

Browse files
committed
docs: improve type annotations
1 parent 5a5189a commit 10fe8d9

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

unicorn/core.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ end
6262
--- Checks if a conflicting version of a package is installed.
6363
-- This checks if there is an equivalent or higher version of a package is installed.
6464
-- If one is not detected, installation continues.
65-
---@param package_table A valid package table
65+
---@param package_table table A valid package table
6666
local function check_installable(package_table)
6767
local existing_package = getPackageData(package_table.name)
6868
if existing_package then
@@ -101,8 +101,8 @@ local function action_modular_providers(package_table)
101101
end
102102

103103
--- Gets "package_script_name" from "package_table.script" and runs it.
104-
---@param package_table A valid package table
105-
---@param package_script_name A value that is either "preinstall", "postinstall", "preremove", or "postremove".
104+
---@param package_table table A valid package table
105+
---@param package_script_name string A value that is either "preinstall", "postinstall", "preremove", or "postremove".
106106
local function action_script(package_table, package_script_name)
107107
if package_table.script and package_table.script[package_script_name] then
108108
local output, scriptError = load(package_table.script[package_script_name])()
@@ -117,13 +117,13 @@ end
117117
local function action_check_hashes(package_table)
118118
if package_table.security and package_table.security.sha256 then
119119
for k, v in pairs(package_table.security.sha256) do
120-
local digest = sha256.digest(fs.open(k, "r"):readAll())
120+
local digest = sha256.digest(fs.open(k, "r"):readAll()):toHex()
121121
assert(digest, v)
122122
end
123123
end
124124
end
125125
--- Creates folders from package_table.dirs
126-
---@param package_table A valid package table
126+
---@param package_table table A valid package table
127127
local function action_make_folders(package_table)
128128
if package_table.dirs then
129129
for _, v in pairs(package_table.dirs) do

unicorn/remote.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ unicorn.remote = {}
2222
--- Installs MCJack123's AUKit, assuming a remote hosting it is configured.
2323
--- >>> local unicorn = require("unicorn")
2424
--- >>> unicorn.remote.install("aukit")
25+
---@param package_name string The name of the package
26+
---@return nil
2527
function unicorn.remote.install(package_name)
2628
local downloaded = false
2729
while not downloaded do

unicorn/util.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ unicorn.util = {}
77

88
---@description Returns contents of HTTP(S) request
99
---@param url string A valid HTTP or HTTPS URL.
10+
---@return string The content from the request
1011
function unicorn.util.smartHttp(url)
1112
unicorn.util.logging.debug("Connecting to " .. url .. "... ")
1213

@@ -39,6 +40,7 @@ end
3940
---@type table
4041
--- @doctype const
4142
unicorn.util.sandbox_env = {
43+
---@diagnostic disable: deprecated
4244
-- Source: https://stackoverflow.com/a/6982080 (with gentle modifications)
4345
ipairs = ipairs,
4446
next = next,
@@ -93,6 +95,7 @@ unicorn.util.sandbox_env = {
9395
tan = math.tan,
9496
tanh = math.tanh,
9597
},
98+
---@diagnostic enable: deprecated
9699
}
97100

98101
--- Load some Lua code in a sandboxed environment.

0 commit comments

Comments
 (0)