Документацију овог модула можете да направите на страници Модул:fo-noun/table/док

local m_links = require("Module:links")
local m_utils = require("Module:utilities")

local lang = require("Module:languages").getByCode("fo")

local export = {}

function make_headers(data, wikicode)
	if data.defective ~= "p" then
		table.insert(wikicode, "! width=80px colspan=")
		table.insert(wikicode, data.defective:find("def") and "1" or "2")
		table.insert(wikicode, " | singular\n")
	end
	if not data.defective:find("s") then
		table.insert(wikicode, "! width=80px colspan=2 | plural\n")
	end
	table.insert(wikicode, '|- class="vsHide" style="text-align:center"\n')
	--Singular
	if data.defective ~= "s_def" and data.defective ~= "p" then
		table.insert(wikicode, '! bgcolor="#ffffff"| indefinite\n')
	end
	if data.defective ~= "s_indef" and data.defective ~= "p" then
		table.insert(wikicode, '! bgcolor="#efefef"| definite\n')
	end
	--Plural
	if not data.defective:find("s") then
		table.insert(wikicode, '! bgcolor="#ffffff"| indefinite\n! bgcolor="#efefef"| definite\n')
	end
end

function make_case(data, wikicode, case)
	local case_short = case:sub(1, 3)
	table.insert(wikicode, '|- class="vsHide" style="text-align:center"\n')
	table.insert(wikicode, [=[! bgcolor="#ccccff" | [[]=] .. case .. [=[ case|]=] .. case .. "]]\n")
	if data.defective ~= "s_def" and data.defective ~= "p" then
		table.insert(wikicode, [[| bgcolor="#ffffff" | <span class="form-of ]] .. case .. '-sg-indef-form-of lang-fo">' .. show_form(data.forms[case_short .. "_sg"]) .. "</span>\n")
	end
	if data.defective ~= "s_indef" and data.defective ~= "p" then
		table.insert(wikicode, [[| bgcolor="#efefef" | <span class="form-of ]] .. case .. '-sg-def-form-of lang-fo">' .. show_form(data.forms[case_short .. "_sg_def"]) .. "</span>\n")
	end
	if not data.defective:find("s") then
		table.insert(wikicode, [[| bgcolor="#ffffff" | <span class="form-of ]] .. case .. '-pl-indef-form-of lang-fo">' .. show_form(data.forms[case_short .. "_pl"]) .. "</span>\n")
		table.insert(wikicode, [[| bgcolor="#efefef" | <span class="form-of ]] .. case .. '-pl-def-form-of lang-fo">' .. show_form(data.forms[case_short .. "_pl_def"]) .. "</span>\n")
	end
end

function show_form(form)
	if not form then
		return "&mdash;"
	end
	
	local ret = {}
	
	for key, subform in ipairs(form) do
		table.insert(ret, m_links.full_link({lang = lang, term = subform}))
	end
	
	return table.concat(ret, ", ")
end

function export.make_table(data)
	
	local colspan = {s_indef = "2", s_def = "2", s = "3", p = "3", no = "5"}
	
	local wikicode = {[=[
{| style="border:1px solid #CCCCFF; text-align:center; line-height:125%" class="inflection-table vsSwitcher vsToggleCategory-inflection" cellspacing="1" cellpadding="2"
|- style="background:#ccccff"
! colspan=]=] .. colspan[data.defective] .. [=[ class="vsToggleElement" style="text-align:left;min-width: 20em" bgcolor="#ccccff"| Declension of ]=]}
	table.insert(wikicode, m_links.full_link({lang = lang, alt = data["head"] or mw.title.getCurrentTitle().text}, "term") .. data.info .. "\n")
	table.insert(wikicode, [=[
|- class="vsHide" style="text-align:center;background:#ccccff"
| rowspan=2 width=30px | ]=] .. data.decl_type .. "\n")
	
	make_headers(data, wikicode)
	make_case(data, wikicode, "nominative")
	make_case(data, wikicode, "accusative")
	make_case(data, wikicode, "dative")
	make_case(data, wikicode, "genitive") 
	table.insert(wikicode, "|}")
	
	return table.concat(wikicode)
end

return export