Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
No edit summary
No edit summary
(25 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
local m = {}
 
local m = {}
   
function m.main(f)
+
local function GetGithubLink(apiType, search)
  +
if apiType == "widget" and wowprog_data[search] == "abstract" then return end
local widget, method = f.args[1]:match("API (%w+) (%w+)")
 
local info = {}
+
local item = {
local items = {}
 
table.insert(items, "! Links")
 
table.insert(items, {
 
 
icon = "GitHub_Octocat.png",
 
icon = "GitHub_Octocat.png",
 
text = "FrameXML",
 
text = "FrameXML",
url = string.format("https://github.com/Gethe/wow-ui-source/search?q=%s", method),
+
url = string.format("https://github.com/Gethe/wow-ui-source/search?q=%s", search),
})
+
}
  +
return item
if wowprog_data[widget..":"..method] then
 
  +
end
table.insert(items, {
 
  +
icon = "Wowprogramming.png",
 
  +
local function GetWowprogLink(apiType, widget, method)
text = "Wowprogramming",
 
 
local item = {
url = string.format("https://wowprogramming.com/docs/widgets/%s/%s.html", widget, method),
 
 
icon = "Wowprogramming.png",
})
 
 
text = "Wowprogramming",
  +
}
  +
if apiType == "widget" then
 
if wowprog_data[widget] then
  +
item.url = string.format("https://wowprogramming.com/docs/widgets/%s.html", widget)
  +
end
  +
elseif apiType == "widgetmethod" then
  +
local wowprog_widget = wowprog_data[widget..":"..method]
  +
if wowprog_widget then
  +
-- certain Region api are documented as VisibleRegion
  +
if type(wowprog_widget) == "string" then
  +
widget = wowprog_widget
  +
end
 
item.url = string.format("https://wowprogramming.com/docs/widgets/%s/%s.html", widget, method)
  +
end
  +
end
  +
if item.url then
  +
return item
  +
end
  +
end
  +
  +
function m.main(f)
  +
local apiType = f.args.t
  +
local pageName = f.args.name
  +
local github_tbl, wowprog_tbl
  +
if apiType == "widget" then
  +
local widget = pageName:match("UIOBJECT (%w+)")
  +
if widget then
  +
github_tbl = GetGithubLink(apiType, widget)
  +
wowprog_tbl = GetWowprogLink(apiType, widget)
  +
end
  +
elseif apiType == "widgetmethod" then
 
local widget, method = pageName:match("API (%w+) (%w+)")
  +
github_tbl = GetGithubLink(apiType, method)
  +
wowprog_tbl = GetWowprogLink(apiType, widget, method)
  +
end
  +
local source = {
  +
"! Links",
  +
{github_tbl, wowprog_tbl},
  +
}
  +
if next(source[2]) then
 
return infobox_module:main(source)
 
end
 
end
return infobox_module:main(info, items)
 
 
end
 
end
   

Revision as of 19:42, 22 July 2022

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

local infobox_module = require("Module:API_info/util/infobox")
local wowprog_data = mw.loadData("Module:API_info/wowprog/widgets")
local m = {}

local function GetGithubLink(apiType, search)
	if apiType == "widget" and wowprog_data[search] == "abstract" then return end
	local item = {
		icon = "GitHub_Octocat.png",
		text = "FrameXML",
		url = string.format("https://github.com/Gethe/wow-ui-source/search?q=%s", search),
	}
	return item
end

local function GetWowprogLink(apiType, widget, method)
	local item = {
		icon = "Wowprogramming.png",
		text = "Wowprogramming",
	}
	if apiType == "widget" then
		if wowprog_data[widget] then
			item.url = string.format("https://wowprogramming.com/docs/widgets/%s.html", widget)
		end
	elseif apiType == "widgetmethod" then
		local wowprog_widget = wowprog_data[widget..":"..method]
		if wowprog_widget then
			-- certain Region api are documented as VisibleRegion
			if type(wowprog_widget) == "string" then
				widget = wowprog_widget
			end
			item.url = string.format("https://wowprogramming.com/docs/widgets/%s/%s.html", widget, method)
		end
	end
	if item.url then
		return item
	end
end

function m.main(f)
	local apiType = f.args.t
	local pageName = f.args.name
	local github_tbl, wowprog_tbl
	if apiType == "widget" then
		local widget = pageName:match("UIOBJECT (%w+)")
		if widget then
			github_tbl = GetGithubLink(apiType, widget)
			wowprog_tbl = GetWowprogLink(apiType, widget)
		end
	elseif apiType == "widgetmethod" then
		local widget, method = pageName:match("API (%w+) (%w+)")
		github_tbl = GetGithubLink(apiType, method)
		wowprog_tbl = GetWowprogLink(apiType, widget, method)
	end
	local source = {
		"! Links",
		{github_tbl, wowprog_tbl},
	}
	if next(source[2]) then
		return infobox_module:main(source)
	end
end

return m