Module:fo-noun

From Wiktionary, the free dictionary
Jump to navigation Jump to search
This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}

local m_table = require("Module:fo-noun/table")

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)

	local parent_args = frame:getParent().args
	local decl_type = (frame.args["decl"] or parent_args["decl"]) or "f1"

	local m_decl = require("Module:fo-noun/data-" .. decl_type:sub(1, 1))
	if not m_decl[decl_type] then
		error("Unknown declension type '" .. decl_type .. "'")
	end
	
	local data = {forms = {}, categories = {}}
	data.defective = "no"
	data.info = ""
	
	data.head = parent_args["head"] or nil

	local args = require("Module:parameters").process(parent_args, m_decl[decl_type].params, true)
	
	if not args[1] then
		setmetatable(args, {__index = function(self, key)
			return "{{{" .. key .. "}}}"
		end
		})
	end
	
	-- Generate the forms
	m_decl[decl_type](args, data)
	data["decl"] = decl_type
	
	-- Make the table
	return m_table.make_table(data)
end

return export