A modult a Modul:hi-decl/adj/doc lapon tudod dokumentálni

local export = {}
local m_translit = require("Module:hi-translit")
local util = require("Module:hi")

local gsub = mw.ustring.gsub
local sub = mw.ustring.sub
local match = mw.ustring.match
local len = mw.ustring.len

local hi_format = util.hi_format
local wordify = util.wordify

local function decline(word)
	local p, f, note = nil, nil, nil
	if match(word, "या$") then
		p = sub(word, 1, -3) .. "ए"
		f = sub(word, 1, -3) .. "ई"
		note = "Sometimes " .. hi_format(sub(word, 1, -3) .. "ये") .. " and " .. hi_format(sub(word, 1, -3) .. "यी") .. " may be used in place of " .. hi_format(p) .. " and " .. hi_format(f) .. "."
	elseif match(word, "आ$") then
		p = sub(word, 1, -2) .. "ए"
		f = sub(word, 1, -2) .. "ई"
	elseif match(word, "ा$") then
		p = sub(word, 1, -2) .. "े"
		f = sub(word, 1, -2) .. "ी"
	else
		p, f = word, word -- invariable adjectives in adjective compounds
	end
	return p, f, note
end

local function make_row(case, m_s, m_p, f_s, f_p)
	local data = {}
	
	table.insert(data, [=[
		|- class="vsHide"
		| style="background:#eff7ff" | ]=] .. case)
	table.insert(data, '|' .. m_s)
	table.insert(data, '|' .. m_p)
	table.insert(data, '|' .. f_s)
	table.insert(data, '|' .. f_p)
	
	return table.concat(data, "\n")
end

function export.show(frame)
	local args = frame:getParent().args
	local page_title = args[1] or mw.title.getCurrentTitle().text
	local words, plurals, feminines, notes = {}, {}, {}, {}
	
	for word in mw.text.gsplit(page_title, "%-") do
		if word == "hi-adj-auto" then
			word = "अच्छा" -- default
		end
		table.insert(words, word)
	end
	
	for _, word in ipairs(words) do
		local p, f, note = decline(word)
		table.insert(plurals, p)
		table.insert(feminines, f)
		table.insert(notes, note)
	end
	
	local word, p, f, notes = table.concat(words, "-"), table.concat(plurals, "-"), table.concat(feminines, "-"), table.concat(notes, "<br>")

	local raw_word = word
	word, p, f = wordify(word), wordify(p), wordify(f)

	local data = {'{| class="inflection-table vsSwitcher" data-toggle-category="inflection" style="background:#FEFEFE; text-align:center; border: 1px solid #CCC; width: 35em"'}
	table.insert(data, '|- style="background: #d9ebff;"')
	table.insert(data, '! class="vsToggleElement" style="text-align: left;" colspan="6" | Declension of ' .. hi_format(raw_word))
	table.insert(data, [=[
		|- class="vsHide"
		! style="background:#eff7ff" |
		! colspan="2" style="background:#eff7ff" | Masculine
		! rowspan="5" style="background:#eff7ff;width:1em" | 
		! colspan="2" style="background:#eff7ff" | Feminine
		|- class="vsHide"
		! style="background:#eff7ff" | 
		| style="background:#eff7ff" | Singular
		| style="background:#eff7ff" | Plural
		| style="background:#eff7ff" | Singular
		| style="background:#eff7ff" | Plural]=])
	table.insert(data, make_row('Direct', word, p, f, f))
	table.insert(data, make_row('Oblique', p, p, f, f))
	table.insert(data, make_row('Vocative', p, p, f, f))
	
	if notes then
		table.insert(data, [=[
			|- class="vsHide"
			| colspan=6 style="background:white" | <small>]=] .. notes .. [=[</small>
	
			|}]=])
	else
		table.insert(data, '|}')
	end
	
	return table.concat(data, '\n')
end

return export