FANDOM


-- See the talk page for documentation.
local api_data = mw.loadData('Module:APIDump')
local removed_api_data = mw.loadData('Module:RemovedAPI')
 
local p = {}
 
--% This function returns information about a class.
--@ class_name (string) the name of the class, for example "BasePart"
--@ exclude_removed_classes (boolean) whether to exclude removed classes
--: (table) a table with information about the class, or nil if no class with the given name was found
--: (boolean) true if the class is a removed class, false if it is still in the API, nil if no class with the given name was found
function p.get_class_data(class_name, exclude_removed_classes)
    local classes = api_data.Classes
    for _, class in pairs(classes) do
        if class.Name == class_name then
            return class, false
        end
    end
    if not exclude_removed_classes then
        classes = removed_api_data.Classes
        for _, class in pairs(classes) do
            if class.Name == class_name then
                return class, true
            end
        end
    end
end
 
--% This function returns information about an enum.
--% The information is in the following format.
--% <pre>
--% {
--%     Items = {
--%         {
--%             Name = "Smooth",
--%             Value = 0
--%         },
--%         {
--%             Name = "Glue",
--%             Value = 1,
--%             Tags = {
--%                 "NotBrowsable",
--%                 "Deprecated"
--%             }
--%         }
--%     },
--%     Name = "SurfaceType"
--% }
--% </pre>
--@ enum_name (string) the name of the enum, for example "SurfaceType"
--@ exclude_removed_enums (boolean) whether to exclude removed enums
--: (table) a table with information about the enum, or nil if no enum with the given name was found
--: (boolean) true if the enum is a removed enum, false if it is still in the API, nil if no enum with the given name was found
function p.get_enum_data(enum_name, exclude_removed_enums)
    local enums = api_data.Enums
    for _, enum in pairs(enums) do
        if enum.Name == enum_name then
            return enum, false
        end
    end
    if not exclude_removed_enums then
        enums = removed_api_data.Enums
        for _, enum in pairs(enums) do
            if enum.Name == enum_name then
                return enum, true
            end
        end
    end
end
 
return p
Community content is available under CC-BY-SA unless otherwise noted.