Module:Guide

local p = {}

local Franchise = require("Module:Franchise") local utilsTable = require("Module:UtilsTable")

local Data = mw.loadData("Module:Guide/Data")

function p.Data(frame) local utilsLayout = require("Module:UtilsLayout") local template = frame:getParent:getTitle if template == "Template:Guide/Documentation" then return p.guideTable("Guide", "guides") elseif template == "Template:EGuide/Documentation" then return p.guideTable("eGuide", "eGuides") else return utilsLayout.tabs({			{				label = "Guides",				content = p.guideTable("Guide", "guides"),			},			{				label = "eGuides",				content = p.guideTable("eGuide", "eGuides")			}		}) end end function p.guideTable(template, guideType) local utilsLayout = require("Module:UtilsLayout") local games = Franchise.enum({ includeGroups = true }) local rows = {} for i, game in ipairs(games) do		local gameGuides = Data[guideType][game] or {} gameGuides = utilsTable.keys(gameGuides) table.sort(gameGuides) local gameRows = utilsTable.map(gameGuides, function(guide)			local input = string.format(" ", template, game, guide)			local output = mw.getCurrentFrame:expandTemplate({ title = template, args = {game, guide} })			return {input, output}		end) rows = utilsTable.concat(rows, gameRows) end local wikitable = utilsLayout.table({		headers = {"Input", "Output"},		rows = rows,	}) return wikitable end

local params = { [1] = {		name = "game", type = "string", required = true, desc = "A game abbreviation.", trim = true, nilIfEmpty = true, },	[2] = {		name = "publisher", type = "string", required = true, desc = "A publisher abbreviation.", trim = true, nilIfEmpty = true, },	[3] = {		name = "omitPublisher", type = "boolean", desc = "If present, the publisher link is omitted.", canOmit = true, }, } p.Templates = { ["Guide"] = { purpose = "Formatting links to guides.", params = params, examples = { {"ALttP", "Nintendo"}, {"ALttP&FS", "Nintendo"}, {"BotW", "Piggyback", "-"}, {				desc = "Error handling", args = {"invalid game", "invalid publisher"}, },			{"", ""},		}	},	["eGuide"] = { purpose = "Formatting links to eGuides.", params = params, examples = { {"ST", "Prima"}, {"BotW", "Piggyback", "-"}, {				desc = "Error handling", args = {"invalid game", "invalid publisher"}, },			{"", ""},		},	}, }

p.Schemas = { Data = { type = "record", required = true, properties = { {				_id = "#guides", name = "eGuides", required = true, type = "map", keyPlaceholder = "game", keys = { type = "string" }, values = { type = "map", keyPlaceholder = "guideInput", keys = { type = "string" }, values = { type = "record", properties = { {								name = "guide", type = "string", required = true, desc = "The wiki page for the guide.", },							{								name = "by", type = "string", required = true, desc = "The wiki page for the company or team that authored the guide.", },						},					},				},			},			{				name = "guides", _ref = "#guides", },		},	}, }

return p