Documentation for this module may be created at Module:CatType/doc
local p = {}
function p.generateCategories(frame)
local baseCategory = frame.args[1] or ""
if baseCategory == "" then
return "Error: No base category provided."
end
-- Determine type (either "spells" or "skills")
local type = baseCategory:match("spells") or baseCategory:match("skills")
if not type then
return "Error: Unable to determine type ('spells' or 'skills') from category name."
end
-- Replace "spells" or "skills" with "abilities" to determine the immediate parent category
local abilitiesCategory = baseCategory:gsub(type, "abilities")
-- Define the parent categories manually or infer based on naming patterns
local parentCategories = {
"Parent abilities",
"Grandparent abilities"
}
-- Generate the category tree, replacing "abilities" with the detected type
local result = {}
table.insert(result, "[[Category:" .. abilitiesCategory .. "]]")
for _, parent in ipairs(parentCategories) do
local categoryWithReplacement = parent:gsub("abilities", type)
table.insert(result, "[[Category:" .. categoryWithReplacement .. "]]")
end
return table.concat(result, "\n")
end
return p