Module:TypeList

local utils = require("Module:Utils")

local p = {}

--% This function generates a list of types used in the API with a certain category. --@ category (string) the category name --: (string) the list of types function p.make_list_of_types_with_category(category) local types = {} for _, class in pairs(mw.loadData("Module:APIDump").data.Classes) do       for _, member in pairs(class.Members) do            if member.ValueType and member.ValueType.Category == category then types[member.ValueType.Name] = true end if member.ReturnType and member.ReturnType.Category == category then types[member.ReturnType.Name] = true end if member.Parameters then for _, parameter in pairs(member.Parameters) do                   if parameter.Type and parameter.Type.Category == category then types[parameter.Type.Name] = true end end end end end types = utils.set_to_array(types) table.sort(types) local output = "" for _, api_type in pairs(types) do       output = output .. "* " .. api_type .. "\n" end return output end

function p._list_types_with_category(args) return p.make_list_of_types_with_category(args.category) end p.list_types_with_category = utils.make_wrapper_function(p._list_types_with_category)

return p