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

local export = {}

local function check(arg, what, n, allow_empty)
	arg = mw.text.trim(arg)
	if not allow_empty and arg == "" then
		arg = nil
	end
	if not arg then
		error("Supply a " .. what .. " as argument " .. n)
	end
	return arg
end

local function get_info(namespace_name_or_id, item)
	local namespace = mw.site.namespaces[namespace_name_or_id]
	if namespace == nil then
		error("Invalid namespace name or id " .. namespace_name_or_id)
	end
	local datum = namespace[item]
	if datum == nil then
		error("Invalid data item " .. item)
	end
	return datum
end

function export.info(frame)
	local namespace_name_or_id = check(frame.args[1], "namespace", 1, true)
	if not namespace_name_or_id then
		error("Supply a namespace as argument 1")
	end
	namespace_name_or_id = tonumber(namespace_name_or_id) or namespace_name_or_id
	local item = check(frame.args[2], "item to look up", 1)
	local datum = get_info(namespace_name_or_id, item)
	if type(datum) == "boolean" then
		return datum and "1" or ""
	elseif not (type(datum) == "string" or type(datum) == "number") then
		error("Unimplemented")
	end
end

return export