Modul:family tree/documentation functions

A modult a Modul:family tree/documentation functions/doc lapon tudod dokumentálni

local export = {}

function export.etymology_language_data(frame)
	local Array = require "Module:array"
	local output = Array()
	local etymology_languages = require "Module:family tree/etymology languages"
	
	local function sort_etymology_language_codes(code1, code2)
		return etymology_languages[code1].canonicalName < etymology_languages[code2].canonicalName
	end
	
	for code, data in require "Module:table".sortedPairs(etymology_languages, sort_etymology_language_codes) do
		local code_list = data.codes
		if code_list[2] then
			table.sort(code_list)
			output:insert("* " .. data.canonicalName .. " (<code>" .. code .. "</code>): "
				.. Array(code_list)
					:filter(function(alt_code)
							return alt_code ~= code
						end)
					:map(function(alt_code)
							return "<code>" .. alt_code .. "</code>"
						end)
					:concat(", "))
		end
	end
	
	return output:concat("\n")
end

return export