Module:Data

local p = {}

function p.Page(frame) local utilsArg = require("Module:UtilsArg") local utilsMarkup = require("Module:UtilsMarkup") local utilsTable = require("Module:UtilsTable")

local args, err = utilsArg.parse(frame:getParent.args, p.Templates["Data/Page"]) if err then return err.categoryText end local templateLinks = utilsTable.map(args.templates, utilsMarkup.link) local templateList = utilsMarkup.bulletList(templateLinks) local msg = string.format("The following data page stores data in the %s table. The data is intended for use by the following templates: %s", args.table, args.table, templateList) if args.supportsSectionPreviews then msg = msg.. "\nBecause there is too much data to display all at once, you can only see a preview of the data is being stored by editing an individual section." end return msg end

function p.PropCheck(frame) local missingData = false for i, arg in ipairs(frame:getParent.args) do		if arg == "" then missingData = true break end end if missingData then return ' Missing data: One or more fields in this section have yet to be filled in. Please fill in this field with the appropriate data or mark it with  if the field is not applicable in this case. '	end end

p.Templates = { ["Data/Page"] = { format = "block", paramOrder = {"table", "templates", "supportsSectionPreviews"}, params = { table = { required = true, type = "string", trim = true, nilIfEmpty = true, desc = "The name of the Cargo table that the Data page stores into.", },			templates = { required = true, type = "string", trim = true, nilIfEmpty = true, split = true, desc = "A comma-separated list of all the templates that are inteded to query the data." },			supportsSectionPreviews = { type = "boolean", default = "true", trim = true, nilIfEmpty = true, desc = "Indicates whether the page uses Template:Data/isSectionPreview.", },		},		examples = { {				desc = "Data:Items/TotK/Armor", args = { table = "Armor", templates = "Template:Items/Armor, Templates:Items/Armor Upgrades" },			},		},	} }

return p