Module:Class tags

local api = require('Module:API') local utils = require('Module:Utils')

local p = {}

p.tag_data = { Deprecated = { category = "Deprecated classes"; description = "This class will be phased out and should be avoided while it is still available."; };   NotBrowsable = { description = "This class is not visible in documentation for end-users."; };   NotCreatable = { category = "Unconstructable classes"; description = "This class cannot be instantiated."; };   NotReplicated = { category = "Unreplicated classes"; description = "This class is not replicated."; };   PlayerReplicated = { category = "Player-replicated classes"; description = "The data of this class' objects is replicated only for the player who owns them."; };   Service = { category = "Services"; description = "This class is a service."; };   Settings = { category = "Settings classes"; description = "This class contains settings."; };   UserSettings = { category = "Settings classes"; description = "This class contains user settings."; }; }

-- These tags are in addition to tags from the API dump. -- Keys are tags, values are arrays of class names. p.extra_tags = { }

-- Returns whether a class has a tag function p.has_tag(class_name, tag) local extra_class_list = p.extra_tags[tag] if extra_class_list then if utils.in_array(extra_class_list, class_name) then return true end end local class_data = api.get_class_data(class_name) if class_data then local class_tags = class_data.Tags if class_tags then for _, class_tag in pairs(class_tags) do               if class_tag == tag then return true end end end end return false end

-- Return an array of a class' tags function p.get_tags(class_name) local tags = {} local class_data = api.get_class_data(class_name) if class_data then local class_tags = class_data.Tags if class_tags then for _, tag in pairs(class_tags) do               tags[tag] = true end end end for tag, array in pairs(p.extra_tags) do       if utils.in_array(array, class_name) then tags[tag] = true end end return utils.set_to_array(tags) end

return p