Module:User:Benwing2/category tree/topic/data

Hello, you have come here looking for the meaning of the word Module:User:Benwing2/category tree/topic/data. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:User:Benwing2/category tree/topic/data, but we will also tell you about its etymology, its characteristics and you will know how to say Module:User:Benwing2/category tree/topic/data in singular and plural. Everything you need to know about the word Module:User:Benwing2/category tree/topic/data you have here. The definition of the word Module:User:Benwing2/category tree/topic/data will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:User:Benwing2/category tree/topic/data, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local labels = {}
local handlers = {}

local top_level_data_module = "Module:category tree/topic/data"
local data_module_prefix = "Module:category tree/topic/"
local sandbox_top_level_data_module = "Module:User:Benwing2/category tree/topic/data"
local sandbox_data_module_prefix = "Module:User:Benwing2/category tree/topic/"

local subpages = {
	"Body",
	"Buildings and structures",
	"Communication",
	"Culture",
		"Religion",
	"Food and drink",
	"Games",
	"History",
	"Human",
		"People",
	"Lifeforms",
		"Animals",
		"Plants",
	"Miscellaneous",
	"Music",
	"Names",
		"Places",
	"Nature",
	"Numbers",
	"Philosophy",
	"Sciences",
		"Mathematics",
	"Sex",
	"Society",
	"Sports",
	"Technology",
	"Thesaurus",
	"Time",
	"Transport",
	"Physical actions",
}

labels = {
	type = "toplevel",
	description = "{{{langname}}} terms organized by topic, such as \"Family\", \"Chemistry\", \"Planets\", \"Canids\" or \"Cities in France\".",
	parents = {{name = "{{{langcat}}}", nontopic = true}},
}

for _, typ in ipairs { "related-to", "set", "type", "name", "grouping" } do
	labels = {
		type = "toplevel",
		description = "All " .. typ .. " categories currently available in {{{langname}}}.",
		parents = {{name = "all topics", sort = " *"}},
	}
end

labels = {
	type = "toplevel",
	description = "All categories currently available in {{{langname}}} that belong to more than one type.",
	parents = {{name = "all topics", sort = " *"}},
}

for label, data in pairs(labels) do
	data.module = top_level_data_module
end

-- Don't throw error on every single category, but on a subset of them, especially the top-level ones.
local function should_throw_error()
	local title = mw.title.getCurrentTitle().text
	return title:find("List of") or title:find("All ") or title:find(" lemmas")
end

-- Import subpages
for _, subpage in ipairs(subpages) do
	local datamodule = (subpage == "Communication" or subpage == "Culture" or subpage == "History" or
		subpage == "Names" or subpage == "Nature" or subpage == "Numbers" or subpage == "Places" or subpage == "Society") and
		sandbox_data_module_prefix .. subpage or data_module_prefix .. subpage
	local retval = require(datamodule)
	if not retval then
		retval = {LABELS = retval}
	end
	for label, data in pairs(retval) do
		if labels and not retval then
			-- Avoid throwing an error on every single topic category and any other invoking category that calls the
			-- topic code.
			if should_throw_error() then
				error("Label " .. label .. " defined in both [["
					.. datamodule .. "]] and .module .. "]].")
			end
		end
		data.module = datamodule
		labels = data
	end
	if retval then
		for _, handler in ipairs(retval) do
			table.insert(handlers, { module = datamodule, handler = handler })
		end
	end
end

return {LABELS = labels, HANDLERS = handlers}