Module:Apisig

From Warcraft Wiki
Jump to navigation Jump to search

Documentation for this module may be created at Module:Apisig/doc

-- https://wowpedia.fandom.com/wiki/Template:Apisig
-- it might be overkill and more annoying to use this template
-- but I really wanted to hyperlink the widget and color the "?"
-- and possibly anything else easily in the future
local m = {}

local widget_fs = "[[UIOBJECT %s|%s]]"

function m.main(f)
	local args = f.args
	local t = {}
	if #args.ret > 0 then
		table.insert(t, string.format("%s = ", args.ret))
	end
	table.insert(t, widget_fs:format(args.widget, args.widget))
	table.insert(t, string.format(":%s", args.method))
	local arguments = args.arg:gsub("%?", '<span title="optional"; style="color:#ecbc2a";>?</span>')
	table.insert(t, string.format("(%s)", arguments))
	return " "..table.concat(t)
end

return m