Module:API info/deprecated

From Warcraft Watch Secrets
Revision as of 08:16, 21 July 2025 by imported>Ketho
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:API info/deprecated/doc

-- https://warcraft.wiki.gg/wiki/Template:Deprecatedapi
local m = {}

local template = {
	title = "Ambox",
	args = {
		border = "yellow",
		image = "[[File:Spell_holy_borrowedtime.png|32px|link=]]",
		style = "width: auto; margin-left: 0.8em;",
	}
}

-- to do: refactor this and templates
local function GetAmbox(f)
	if #f.args.note > 0 then
		template.args.type = f.args.note
		return f:expandTemplate(template)
	end

	local link
	if #f.args.link > 0 then
		link = string.format("[%s <font color=#ecbc2a>%s</font>]", f.args.link, f.args.patch)
	else
		link = string.format("[[Patch_%s/API_changes|<font color=#ecbc2a>%s</font>]]", f.args.patch, f.args.patch)
	end
	if #f.args.removed > 0 then
		template.args.type = string.format("''This function was deprecated in patch <font color=#dda0dd>%s</font> and will be removed in patch <font color=#ecbc2a>%s</font>.''", f.args.patch, f.args.removed)
	elseif #f.args.future > 0 then
		template.args.type = string.format("''This function was deprecated in patch %s and will be removed in the future.''", link)
	elseif #f.args.tentative > 0 then
		template.args.type = string.format("''This function was deprecated in patch <font color=#ecbc2a>%s</font> but it is unclear when the deprecation will be removed.''", f.args.patch)
		template.args.image = "[[File:Inv_misc_questionmark.png|32px|link=]]"
	else
		template.args.type = string.format("''This function was deprecated in patch %s and will be removed in the next expansion.''", link)
	end
	return f:expandTemplate(template)
end

function m.main(f)
	return GetAmbox(f)
end

return m