Module:Method

local member = require('Module:Member') local utils = require('Module:Utils') local links = require('Module:Links')

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 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+(.+)')

-- If there exists a page with the same name as the parameter type, link to it. local type_title = mw.title.new(parameter_type) if type_title.exists then parameter_list = parameter_list .. links.wikilink(type_title, parameter_type) .. " " .. parameter_name else parameter_list = parameter_list .. parameter_type .. " " .. parameter_name end -- Otherwise, it's a return value's type. else -- 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 .. value else prefix = prefix .. " " .. value end end end

return member._create { name = args.name; prefix = prefix; tags = utils.array_to_set(utils.trim_positional_arguments(args)); ["parameter list"] = parameter_list; } end

p.create = utils.make_wrapper_function(p._create)

return p