Module:Callback

local member = require('Module:Member') local utils = require('Module:Utils') local link_type = require('Module:Type').link local member_tag_descriptions = require('Module:Member tags').member_tag_descriptions local p = {} function p._create(args) local prefix = '' local parameter_list = '' for argn, value in ipairs(utils.trim_positional_arguments(args)) do       -- If the value contains whitespace, we assume it describes a parameter with the parameter type and name separated by whitespace. if mw.ustring.find(value, '%s') then -- If the parameter list already contains parameters, add a space and a comma before inserting another. if parameter_list ~= '' then parameter_list = parameter_list .. ", "           end -- Get the parameter type and name from the value. local parameter_type, parameter_name = mw.ustring.match(value, '(.+)%s+(.+)') parameter_type, parameter_name = mw.ustring.match(value, '(.+)%s+(.+)') parameter_list = parameter_list .. link_type(parameter_type) .. " " .. mw.text.tag('var', {class="parameter-name"}, parameter_name) -- Otherwise, it's a return value's type. elseif not member_tag_descriptions[value] then -- Add the return type to the prefix, adding a space before the type if there are already return types in the prefix. if prefix == '' then prefix = prefix .. link_type(value) else prefix = prefix .. " " .. link_type(value) end end end -- Filter out return types and parameter types and names from tags. local tags = {} for tag in next, utils.array_to_set(utils.trim_positional_arguments(args)) do       if member_tag_descriptions[tag] then tags[tag] = true end end

return member._create { name = args.name; prefix = prefix; tags = tags; icon = "Callback icon.png"; ["parameter list"] = parameter_list; } end p.create = utils.make_wrapper_function(p._create) return p