Module:ClassInfobox

local api = require('Module:API') local categorization = require('Module:Categorization') local superclass = require('Module:Superclass') local utils = require('Module:Utils') local class_link = require('Module:Class link') local class_tags = require('Module:Class tags') local class_icon = require('Module:Class icon') local reflectionmetadata = require('Module:ReflectionMetadataHelpers')

local categorize = categorization.categorize_in_namespaces('Class')

local p = {}

function p._format_tags(args) local class_tag_list = class_tags.get_tags(args.name) if #class_tag_list == 0 then return '' end local tag_list = mw.html.create("ul") :addClass("class-tags") :css("color", "gray") for _, tag in pairs(class_tag_list) do       local tag_data = class_tags.tag_data[tag] if tag_data then local list_item = tag_list:tag("li") list_item:wikitext(tag) if tag_data.category then list_item:wikitext(categorize(tag_data.category)) end if tag_data.description then list_item:attr("title", tag_data.description) end else return error("Unknown class tag: " .. tag) end end return tag_list end

p.format_tags = utils.make_wrapper_function(p._format_tags)

-- Keys are class categories from the ReflectionMetadata.xml file. -- Values are wiki category names. local class_category_to_wiki_category_mapping = { ["Values"] = "Value classes", ["Avatar"] = "Avatar classes", ["Animations"] = "Animation classes", ["Post Processing Effects"] = "Post-processing effect classes", ["Interaction"] = "Interaction classes", ["Constraints"] = "Constraint classes", ["3D Interfaces"] = "3D interface classes", ["Scripting"] = "Scripting classes", ["Legacy Body Movers"] = "Legacy body mover classes", ["Parts"] = "Part classes", ["Lights"] = "Light classes", ["Meshes"] = "Mesh classes", ["Physics"] = "Physics classes", ["Effects"] = "Effect classes", ["GUI"] = "GUI classes", ["Environment"] = "Environment classes", ["Localization"] = "Localization classes", ["World"] = "World classes", ["Adornments"] = "Adornment classes", ["Sounds"] = "Sound classes" }

function p._format_class_category(args) local class_category = reflectionmetadata.get_class_category(args.name) if class_category then local category = class_category_to_wiki_category_mapping[class_category] if category then return class_category .. categorize(category) else return class_category .. categorize("Other classes") end end end

p.format_class_category = utils.make_wrapper_function(p._format_class_category)

function p._format_memory_category(args) local class = api.get_class_data(args.name) if class then return class.MemoryCategory end end

p.format_memory_category = utils.make_wrapper_function(p._format_memory_category)

-- This is only for the icon field in the class infobox. -- For other uses look at Module:Class icon. function p._class_icon(args) return class_icon.get_class_icon(args.class, false) end

p.class_icon = utils.make_wrapper_function(p._class_icon)

function p._format_explorer_order(args) local explorer_order = reflectionmetadata.get_explorer_order(args.name) if explorer_order then return explorer_order end end

p.format_explorer_order = utils.make_wrapper_function(p._format_explorer_order)

function p._format_preferred_parent(args) local preferred_parent = reflectionmetadata.get_preferred_parent(args.name) if preferred_parent then return class_link._class_link{class = preferred_parent} end end

p.format_preferred_parent = utils.make_wrapper_function(p._format_preferred_parent)

function p._inheritance_list(args) if args.class == 'Instance' then return '' end local superclass_ = superclass._superclass({class = args.class}) if superclass_ then return (superclass._superclass_list({class = args.class}) or "") .. categorize("Subclasses of " .. superclass_) else return error("superclass of " .. args.class .. " unknown") end end

p.inheritance_list = utils.make_wrapper_function(p._inheritance_list)

return p