A modult a Modul:epto/doc lapon tudod dokumentálni

local export = {}

local function codeWrap(s1, s2)
	return
		'<div class="NavFrame" style="border:0px;">' ..
			'<div class="NavHead" style="font-size:105%; border:1px solid #aaaaaa; margin-left:-1px; background-color:#CCCCFF; " cellpadding="3">' ..
				'Plain text output of ' .. s1 ..
			'</div>' .. -- style="border: 1px solid; background-color: #f8f8f8; padding: 0.5em; "
			'<div class="NavContent" align="left" style="border: 1px solid; padding: 0em 1em; ">' ..
				mw.getCurrentFrame():extensionTag({name = 'source', content = s2}) ..
			'</div>' ..
		'</div>'
end

local function getArgsMod(frame)
	local args_s, frame_copy = {}, {}
	for i,v in pairs(frame) do
		if i ~= 'args' and i~= 'getParent' then
			frame_copy[i] = v
		end
	end
	frame_copy.args = {}
	for i,v in pairs(frame.args) do
		if type(i) == 'number' then
			if i >= 3 then
				table.insert(args_s, '|' .. i - 2 .. '=' .. v)
				frame_copy.args[i - 2] = v
			end
		else
			table.insert(args_s, '|' .. i .. '=' .. v)
			frame_copy.args[i] = v
		end
	end
	frame_copy.getParent = function(this_frame)
		return frame:getParent()
	end
	return table.concat(args_s), frame_copy
end

local function getArgsT(args)
	local args_s = {}
	for i,v in pairs(args) do
		if type(i) == 'number' then
			if i >= 2 then
				table.insert(args_s, '|' .. i - 1 .. '=' .. v)
			end
		else
			table.insert(args_s, '|' .. i .. '=' .. v)
		end
	end
	return table.concat(args_s)
end

local function t_preprocess(s, frame)
	local n, args_copy
	s = frame:preprocess(s)
	s, n = string.gsub(s, '{{subst:', '{{')
	if n ~= 0 then
		args_copy = {}
		for i,v in pairs(frame.args) do
			if type(i) == 'number' then
				if i >= 2 then
					args_copy[i - 1] = v
				end
			else
				args_copy[i] = v
			end
		end
		s = frame:getParent():newChild{ args = args_copy }:preprocess(s)
	end
	return s
end

function export.mod(frame)
	local args_s, frame_copy = getArgsMod(frame)
	return codeWrap(
		'{{#invoke:' .. frame.args[1] .. '|' .. frame.args[2] .. args_s .. '}}',
		require('Module:' .. frame.args[1])[frame.args[2]](frame_copy)
	)
end

function export.t(frame)
	local s = '{{' .. frame.args[1] .. getArgsT(frame.args) .. '}}'
	return codeWrap(s, t_preprocess(s, frame))
end

return export