Module:labels doc
Appearance
- පහත දැක්වෙන උපදෙස්, Module:labels doc/documentation හි පිහිටා ඇත. Module:labels doc/documentation]]. [සංස්කරණය] Categories were auto-generated by Module:documentation. [edit]
- ප්රයෝජනවත් සබැඳි: උප පිටු ලැයිස්තුව • සබැඳි • transclusions • testcases • sandbox
This full table of labels of Module:labels is shown at Template:label#Defined_labels.
--[=[
This module contains functions to implement {{label/doc}}.
Author: Benwing2
]=]
local export = {}
local labels_module = "Module:labels"
local m_labels = require(labels_module)
local m_table = require("Module:table")
local m_languages = require("Module:languages")
local function sort_by_label(labinfo1, labinfo2)
return labinfo1.raw_label < labinfo2.raw_label
end
local function create_label_table(label_infos)
table.sort(label_infos, sort_by_label)
local parts = {}
local function ins(text)
table.insert(parts, text)
end
ins('{|class="wikitable sortable"')
ins("! Label !! Canonical equivalent !! Display form !! Categories !! Defined in !! Deprecated")
for _, info in ipairs(label_infos) do
ins("|-")
ins("| <code>" .. info.raw_label .. "</code>")
if info.canonical then
ins("| <code>" .. info.canonical .. "</code>")
else
ins("|")
end
ins("| " .. info.label)
ins("| " .. table.concat(info.categories, "<br />"))
ins(("| [[%s]]"):format(info.module))
if info.deprecated then
ins("| '''Yes'''")
else
ins("|")
end
end
ins("|}")
return table.concat(parts, "\n")
end
function export.show()
local submodules = m_labels.get_submodules(nil)
local label_infos = {}
local labels_seen = {}
local function process_module(module, lang, label_infos, labels_seen)
local module_data = mw.loadData(module)
for label, _ in pairs(module_data) do
if labels_seen[label] then
table.insert(labels_seen[label], module)
else
local labinfo = m_labels.get_label_info {
label = label,
lang = lang,
for_doc = true,
already_seen = {},
}
labinfo.raw_label = label
labinfo.module = module
table.insert(label_infos, labinfo)
end
end
end
for _, module in ipairs(submodules) do
process_module(module, nil, label_infos, labels_seen)
end
local unrecognized_langcodes = {}
local lang_specific_data_list_module = mw.loadData(m_labels.lang_specific_data_list_module)
local lang_specific_data_langs = {}
for langcode, _ in pairs(lang_specific_data_list_module.langs_with_lang_specific_modules) do
local lang = m_languages.getByCode(langcode)
if not lang then
table.insert(unrecognized_langcodes, langcode)
else
table.insert(lang_specific_data_langs,
{ lang = lang, langcode = langcode, langname = lang:getFullName() })
end
end
table.sort(lang_specific_data_langs, function(a, b) return a.langname < b.langname end)
local parts = {}
local function ins(text)
table.insert(parts, text)
end
ins("===Language-independent===")
ins(create_label_table(label_infos))
for _, langobj in ipairs(lang_specific_data_langs) do
local per_language_label_infos = {}
local per_language_labels_seen = {}
process_module(m_labels.lang_specific_data_modules_prefix .. langobj.langcode, langobj.lang,
per_language_label_infos, per_language_labels_seen)
ins(("===%s==="):format(langobj.langname))
ins(create_label_table(per_language_label_infos))
end
return table.concat(parts, "\n")
end
return export