模組:Category tree/topic cat/data
- 下列說明文檔位於Module:Category tree/topic cat/data/doc。[編輯]
- 相關連結:根頁面 • 根頁面的子頁面 • 本頁面的子頁面 • 链入 • 嵌入包含 • 測試用例 • 沙盒 (差異)
此模塊的主題為Module:category tree/topic cat;它本身不包含數據,而是從其子模塊導入數據,並進行一些後處理。
要添加新的數據子模塊,請將其名稱添加到模塊頂部的subpages
列表中。
local labels = {}
local handlers = {}
local top_level_data_module = "Module:category tree/topic cat/data"
local data_module_prefix = top_level_data_module .. "/"
local subpages = {
"Body",
"Buildings and structures",
"Communication",
"Culture",
"Religion",
"Earth",
"Food and drink",
"Games",
"History",
"Human",
"People",
"Lifeforms",
"Animals",
"Plants",
"Miscellaneous",
"Names",
"Places",
"Nature",
"Numbers",
"Philosophy",
"Sciences",
"Mathematics",
"Sex",
"Social acts",
"Society",
"Sports",
"Technology",
"Thesaurus",
"Time",
"Transport",
"Physical actions",
}
labels["主題"] = {
type = "toplevel",
description = "依主題分門別類的{{{langname}}}詞語,如「家庭」、「化學」、「植物」、「犬科」或「法國城市」。 ",
parents = {{module = "poscatboiler", args = {label = "{{{langcat}}}", raw = true, called_from_inside = true}}},
}
for _, typ in ipairs { "相關", "集合", "類型", "名稱", "分組" } do
labels[typ .. "分類列表"] = {
type = "toplevel",
description = "{{{langname}}}中所有的" .. typ .. "分類。",
parents = {{name = "主題", sort = " *"}},
}
end
labels["混合分類列表"] = {
type = "toplevel",
description = "{{{langname}}}中屬於多個類型的所有分類。",
parents = {{name = "主題", sort = " *"}},
}
for label, data in pairs(labels) do
data.module = top_level_data_module
end
-- Import subpages
for _, subpage in ipairs(subpages) do
local datamodule = data_module_prefix .. subpage
local retval = require(datamodule)
if not retval["LABELS"] then
retval = {LABELS = retval}
end
for label, data in pairs(retval["LABELS"]) do
if labels[label] and not retval["IGNOREDUP"] then
error("標籤「" .. label .. "」同時被定義於[["
.. datamodule .. "]]和[[" .. labels[label].module .. "]]。")
end
data.module = datamodule
labels[label] = data
end
if retval["HANDLERS"] then
for _, handler in ipairs(retval["HANDLERS"]) do
table.insert(handlers, { module = datamodule, handler = handler })
end
end
end
return {LABELS = labels, HANDLERS = handlers}