Module:MemberLink

local member_icon = require('Module:MemberIcon') local utils = require('Module:Utils')

local p = {}

--% This function creates a link to a class member. --@ class_name (string) the name of the member's class --@ member (table) information about the member, in API dump format --: (string) a link to the class member function p.make_member_link(class_name, member) local output = "" .. class_name   if member.MemberType == "Property" then        output = output .. "."    elseif member.MemberType == "Function"        or member.MemberType == "Event"        or member.MemberType == "Callback"    then        output = output .. ":"    else        return error("Unknown member type: " .. member.MemberType)    end    output = output .. member.Name .. "" return output end

--% This function creates a link to a class member, with an icon. --@ class_name (string) the name of the member's class --@ member (table) information about the member, in API dump format --: (string) a link to the class member, with an icon function p.make_member_link_with_icon(class_name, member) local output = p.make_member_link(class_name, member) output = member_icon.make_member_icon(member) .. " " .. output return output end

function p._member_link(args) local class_name = args.class local member_name = args.member local class_data = require('Module:API').get_class_data(class_name) if not class_data then return error("class " .. class_name .. " not known") end for _, member in pairs(class_data.Members) do       if member.Name == member_name then return p.make_member_link(class_name, member) end end return error ("member " .. member_name .. " of class " .. class_name .. " not known") end p.member_link = utils.make_wrapper_function(p._member_link)

return p