Jump to content

Module:affix doc

Wiktionary වෙතින්

මෙම මොඩියුලය සඳහා උපදෙස් පත්‍රිකාවක් අවශ්‍ය වෙයි.
මෙම මොඩියුලය හා අදාළ අරමුණු සහ භාවිත උපදෙස්, උපදෙස් පිටුව තුළ ලේඛනගත කිරීමට කාරුණික වන්න.

--[=[
	This module contains functions to display user-readable tables of affix-related information.

	Author: Benwing2
]=]

local export = {}

local m_affix = require("Module:affix")

local function make_code(text)
	return "<code>" .. text .. "</code>"
end

function export.etymology_type_table(frame)
	local alldata = {}

	-- Convert table of codes to a list of information.
	for etytype, desc in pairs(m_affix.etymology_types) do
		local alias_of
		if type(desc) == "string" then
			alias_of = make_code(desc)
			desc = m_affix.etymology_types[desc]
		else
			alias_of = "—"
		end
		local cat
		if desc.borrowing_type then
			cat = ("%s from <var>source</var>"):format(desc.borrowing_type)
		else
			cat = desc.cat
		end

		local obj = {
			type = etytype,
			text = desc.text,
			cat = cat,
			alias_of = alias_of,
		}
		table.insert(alldata, obj)
	end

	table.sort(alldata, function(obj1, obj2)
		return obj1.type < obj2.type
	end)

	-- Convert to wikitable.

	local parts = {}
	table.insert(parts, '{|class="wikitable"')
	table.insert(parts, "! Type !! Alias of !! Display <small>(click on link for explanation)</small> !! Category")
	local last_type = nil
	for _, obj in ipairs(alldata) do
		table.insert(parts, "|-")
		local sparts = {}
		table.insert(sparts, make_code(obj.type))
		table.insert(sparts, obj.alias_of)
		table.insert(sparts, obj.text)
		table.insert(sparts, make_code("<var>lang</var> " .. obj.cat))
		table.insert(parts, "| " .. table.concat(sparts, " || "))
	end
	table.insert(parts, "|}")
	return table.concat(parts, "\n")
end

return export
"https://si.wiktionary.org/w/index.php?title=Module:affix_doc&oldid=218100" වෙතින් සම්ප්‍රවේශනය කෙරිණි