Module:User:Benwing2/affix doc

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


--[=[
	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
		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