mNo edit summary |
No edit summary |
||
Line 64: | Line 64: | ||
-- dont show the infobox when multiple apis are documented on the same page |
-- dont show the infobox when multiple apis are documented on the same page |
||
local testVar = f:callParserFunction("#var", "hasMultiApi") |
local testVar = f:callParserFunction("#var", "hasMultiApi") |
||
− | return testVar and " |
+ | return testVar and "hasMultiApi exists: "..#testVar or "unknown" |
--if not multi_api[PAGENAME] then |
--if not multi_api[PAGENAME] then |
||
-- return GetInfobox(name, f.args) |
-- return GetInfobox(name, f.args) |
Revision as of 15:45, 2 July 2021
Documentation for this module may be created at Module:API info/main/api/doc
local flavor_module = require("Module:API_info/flavor")
local elink_module = require("Module:API_info/elink")
local patch_module = require("Module:API_info/patch")
local multi_api = mw.loadData("Module:ElinksApiMulti/data")
local m = {}
local comparison = {
a = "Global_functions/Classic",
e = "Events/Classic",
}
local HTML_LIST_START = '<ul class="plainlinks elinks">\n'
local HTML_LIST_ITEM = '<li style="padding-left: 0px; min-height: %dpx">%s %s</li>\n'
local HTML_LIST_END = '</ul>'
local function GetFlavorText(name, args)
local flavors = flavor_module:GetFlavors(name, args.t)
if flavors then
local s = HTML_LIST_START
for _, info in pairs(flavors) do
s = s..HTML_LIST_ITEM:format(0, info.icon, info.link)
end
s = s..HTML_LIST_END
return s
end
end
local function GetElinksText(name, args)
local elinks = elink_module:GetElinks(name, args.t)
local s = HTML_LIST_START
for _, info in pairs(elinks) do
s = s..HTML_LIST_ITEM:format(25, info.icon, " "..info.link)
end
s = s..HTML_LIST_END
return s
end
local function GetInfobox(name, args)
local flavorText = GetFlavorText(name, args)
local added, removed = patch_module:GetPatches(name)
-- would check for only patchdata but events are not yet added
if flavorText or #added > 0 then
local s = '<div class="nomobile" style="float:right; clear:right">\n{| class="darktable" style="min-width:142px;"'
if flavorText then
s = s..string.format("\n|-\n! Game [[%s|Flavors]]\n|-\n| %s", comparison[args.t], flavorText)
end
-- always returns at least globe wut
s = s.."\n|-\n! Links\n|-\n| "..GetElinksText(name, args)
if #added > 0 then
s = s.."\n|-\n! Patch"
s = s.."\n|-\n| Added in "..added
if #removed > 0 then
s = s.."\n|-\n| Removed in "..removed
end
end
s = s.."\n|}\n</div>"
return s
end
end
function m.main(f)
local PAGENAME = f.args[1]
local name = PAGENAME:gsub("API ", ""):gsub(" ", "_")
-- dont show the infobox when multiple apis are documented on the same page
local testVar = f:callParserFunction("#var", "hasMultiApi")
return testVar and "hasMultiApi exists: "..#testVar or "unknown"
--if not multi_api[PAGENAME] then
-- return GetInfobox(name, f.args)
--end
end
return m