Dokumentácia pre tento modul môže byť vytvorená na Modul:Numberofpages/Dokumentácia

-- Number of pages in all namespaces
-- [[user:Leh Palych]]

local p = {}

-- 
function p.out(frame)
--	local str = frame.args[1]
	local str
	local ns, num_ns, cont, subj, num_p, q_page, name_ns
	local t_cont = 0
	local t_page = 0
	local t_talk = 0

	ns = mw.site.namespaces
	
	local num = {}
	for k, v in pairs(ns) do
		table.insert(num, v.id)
	end
	table.sort(num)
	str='{| class="wikitable" style="text-align:right"\n'
	str = str .. "!Id!!Namespace!!Number of<br/>pages!!Content!!Subject!!Talk id!!Number of<br/>pages\n"

	for k, v in pairs(num) do
		num_ns = ns[v].id
		num_p = mw.site.stats.pagesInNamespace(num_ns)
		q_page = tonumber(num_p)
		name_ns = ns[v].name
		if name_ns == '' then
			name_ns = '(Main)'
		end
		
		if ns[v].isContent then
			cont = '+'
			t_cont = t_cont + q_page
		else
			cont = ''
		end
		if ns[v].isSubject then
			subj = '+'
		else
			subj = ''
		end

		if ns[v].isTalk then
		   	str = str .. '|| ' .. num_ns .. '||'..num_p .. '\n'
	    	t_talk = t_talk + q_page
		else
			str = str .. "|-\n" .. '| ' .. num_ns .. '||style="text-align:left"|'.. name_ns .. '&nbsp;||' .. num_p .. '||' .. cont .. '||' .. subj
			if num_ns < 0 then
				str = str .. '||&nbsp;||&nbsp;\n'
			end
	    	t_page = t_page + q_page
		end
	end
	str = str .. '|-\n' .. '!style="text-align:right;" colspan=2 rawspan=2|Total:||style="text-align:right;"|'.. t_page ..'||style="text-align:right;"|' .. t_cont .. '||colspan=2|&nbsp;||style="text-align:right;"|'.. t_talk .. '\n'
	str = str .. '|-\n' .. '!colspan=2| ||style="text-align:right;"|'.. t_page+t_talk ..'||colspan=4|&nbsp;\n'
	str = str .. "|}\n"

	return str
end 	
--
return p