Ketho / vscode-wow-api

VS Code extension for World of Warcraft AddOns
https://marketplace.visualstudio.com/items?itemName=ketho.wow-api
MIT License
151 stars 33 forks source link

Updated annotations of some Ace3 libraries. #145

Closed CruelDrool closed 5 months ago

CruelDrool commented 5 months ago

Hello!

Thanks for the great work. Just want to add to it.

AceAddon

Found some missing functions. I've added annotations.

---@param addon string|AceAddon Name of addon or addon object.
--
--- ---
function lib:DisableAddon(addon) end

---@param addon AceAddon Addon object.
---@param ... string List of libraries to embed into the addon.
--
--- ---
function lib:EmbedLibraries(addon, ...) end

---@param addon AceAddon Addon object.
---@param libname string Name of library to embed.
---@param silent? boolean Marks an embed to fail silently if the library doesn't exist (optional)
---@param offset? number Will push the error messages back to said offset, defaults to 2 (optional)
--
--- ---
function lib:EmbedLibrary(addon, libname, silent, offset) end

---@param addon string|AceAddon Name of addon or addon object.
--
--- ---
function lib:EnableAddon(addon) end

---@param addon AceAddon Addon object.
--
--- ---
function lib:InitializeAddon(addon) end

-- Deprecated, use addon:IterateEmbeds() instead.
-- Return an iterator of all embeds associated with the addon.
---@see AceAddon.IterateEmbeds()
---@param addon AceAddon Addon object.
---@return function iter
---@return table invariant
---@return number init
---@deprecated
-- 
--- ---
function lib:IterateEmbedsOnAddon(addon) end

-- Deprecated, use addon:IterateModules() instead.
-- Return an iterator of all modules associated with the addon.
---@see AceAddon.IterateModules
---@param addon AceAddon Addon object.
---@return function iter
---@return table invariant
---@return number init
---@deprecated
--
--- ---
function lib:IterateModulesOfAddon(addon) end

-- Return an iterator of all embeds associated with the addon.
---@return function iter
---@return table invariant
---@return number init
--
--- ---
function addon:IterateEmbeds() end

AceLocale

Wrong return values from 2 methods. Gave me a lot of yellow squiggly lines under my code.

From a comment in the AceLocale code:

:NewLocale will return a table you can fill your locale into, or nil if the locale isn't needed for the players game locale

Return value from AceLocale:NewLocale() should either be table|nil or { [string]: string|true }|nil to be more descriptive.

From a comment in the AceLocale code:

[:GetLocale] Returns localizations for the current locale (or default locale if translations are missing)."

Return value from AceLocale:GetLocale() should be: { [string]: string }. The values in the returned table are never true

AceTimer

First input parameter for :ScheduleTimer can be a string, a "funcref": func function|string

AceEvent

Missing functions. Not entirely sure how to annotate these, they seem rather self-explanatory.

function AceEvent:UnregisterAllEvents() end

function AceEvent:UnregisterAllMessages() end

AceConfigDialog

Missing fields. .OpenFrames stands out. Only way to know if the addon's options UI is open

---@class AceConfigDialog-3.0
---@field OpenFrames { [string]: table }|table
---@field Status { [string]: table }
---@field tooltip GameTooltip
local AceConfigDialog = {}

---@class AceConfigDialog-3.0.frame: Frame
AceConfigDialog.frame = AceConfigDialog.frame or CreateFrame("Frame")
---@type { [string]: true|nil }
AceConfigDialog.frame.apps = AceConfigDialog.frame.apps or {}
---@type { [string]: true|nil }
AceConfigDialog.frame.closing = AceConfigDialog.frame.closing or {}
---@type { [string]: true }
AceConfigDialog.frame.closeAllOverride = AceConfigDialog.frame.closeAllOverride or {}
Ketho commented 5 months ago

AceAddon

Those seem to be from internal API (paging @Torhal) https://www.wowace.com/projects/ace3/pages/api/ace-addon-3-0

I'm not averse but not sure whether those should be added.