Moduł:Dokumentacja: Różnice pomiędzy wersjami

Z Minecraft Wiki Polska
Przejdź do nawigacji Przejdź do wyszukiwania
[wersja nieprzejrzana][wersja przejrzana]
d fixed broken purge text
d Anulowanie wersji 114087 autorstwa BartoszKonkol (dyskusja)
Znacznik: Anulowanie edycji
 
(Nie pokazano 7 wersji utworzonych przez 5 użytkowników)
Linia 1: Linia 1:
local p = {}
local p = {}
local defaultDocPage = 'opis'
local getType = function( namespace, page )
local pageType = 'template'
if namespace == 'Moduł' or namespace == 'Module' then
pageType = 'module'
elseif namespace == 'Widget' then
pageType = 'widget'
elseif page.fullText:gsub( '/' .. defaultDocPage .. '$', '' ):find( '%.css$' ) then
pageType = 'stylesheet'
elseif page.fullText:gsub( '/' .. defaultDocPage .. '$', '' ):find( '%.js$' ) then
pageType = 'script'
elseif namespace == 'MediaWiki' then
pageType = 'message'
end
return pageType
end
local getTypeForms = function( pageType )
if pageType == 'module' then
return {gen = 'tym module', acc = 'tego modułu', pronoun_gen = "его", nomP = 'Moduły'}
elseif pageType == 'widget' then
return {gen = 'tym widżecie', acc = 'tego widżetu', pronoun_gen = "его", nomP = 'Widżety'}
elseif pageType == 'stylesheet' then
return {gen = 'tym arkuszu stylów', acc = 'tego arkusza stylów', pronoun_gen = "еro", nomP = 'Arkusze stylów'}
elseif pageType == 'script' then
return {gen = 'tym skrypcie', acc = 'tego skryptu', pronoun_gen = "его", nomP = 'Skrypty'}
elseif pageType == 'message' then
return {gen = 'tej wiadomości systemowej', acc = 'tej wiadomości systemowej', pronoun_gen = "его", nomP = 'Wiadomości'}
else -- type == 'template'
return {gen = 'tym szablonie', acc = 'tego szablonu', pronoun_gen = "его", nomP = 'Szablony'}
end
end
-- Creating a documentation page or transclution through {{subst:doc}}
-- Creating a documentation page or transclution through {{subst:doc}}
function p.create( f )
function p.create( f )
local args = require( 'Moduł:ProcessArgs' ).norm()
local args = require( 'Moduł:ProcessArgs' ).norm()
page = mw.title.getCurrentTitle()
local page = mw.title.getCurrentTitle()
namespace = args['typ'] or page.nsText
local docPage = args['strona'] or page.nsText .. ':' .. page.baseText .. '/' .. defaultDocPage
docPage = args['strona'] or namespace .. ':' .. page.baseText .. '/opis'
local out
local out
if page.fullText == docPage then
if not args["treść"] and tostring( page ) == docPage then
out = f:preprocess( '{{subst:Szablon:Dokumentacja/preload}}' )
out = f:preprocess( '{{subst:Szablon:Dokumentacja/preload}}' )
else
else
local templateArgs = {}
local templateArgs = {}
if args['typ'] then
for _, key in ipairs{ 'typ', 'strona', 'treść' } do
table.insert( templateArgs, 'typ=' .. args['typ'] )
local val = args[key]
if val then
if key == 'treść' then val = '\n' .. val .. '\n' end
table.insert( templateArgs, key .. '=' .. val )
end
end
end
if args['strona'] then
table.insert( templateArgs, 'strona=' .. args['strona'] )
out = '{{Dokumentacja|' .. table.concat( templateArgs, '|' ) .. '}}'
out = out:gsub( '|}}', '}}' )
if not args["treść"] then
out = out .. '\n<!-- Kategorie i interwiki umieść na stronie dokumentacji.  -->'
end
end
out = '{{Dokumentacja|' .. table.concat( templateArgs, '|' ) .. '}}\n<!-- Kategorie i interwiki umieść na stronie dokumentacji. -->'
out = out:gsub( '|}}', '}}' )
end
end
if not mw.isSubsting() then
if not mw.isSubsting() then
out = f:preprocess( out )
out = f:preprocess( out )
if args['niekat'] ~= 1 then
if not args['niekat'] then
out = out .. '[[Kategoria:Страницы с требующими подстановки шаблонами]]'
out = out .. '[[Kategoria:Pages with templates requiring substitution]'
end
end
end
end
Linia 33: Linia 73:
end
end


-- Header on the documentation page
-- Header2 on the documentation page
function p.docPage(f)
function p.docPage( f )
local args = require( 'Moduł:ProcessArgs' ).merge( true )
local args = require( 'Moduł:ProcessArgs' ).merge( true )
local badDoc = args['zladok'] or ''
local badDoc = args['zladok']
local noDoc = args['brakdok'] or ''
local forceNoDoc = args['brakdok']
if f:callParserFunction( '#dplvar:noheader' ) == '1' then
if noDoc ~= '' then
local docclass = "documentation-norm"
f:callParserFunction( '#dplvar:set', 'notdoc', '1' )
if badDoc then
elseif badDoc ~= '' then
docclass = "documentation-bad"
f:callParserFunction( '#dplvar:set', 'baddoc', '1' )
elseif forceNoDoc then
docclass = "documentation-no"
end
if forceNoDoc then
f:callParserFunction( '#dplvar:set', '$doc forced_none', '1' )
end
if f:callParserFunction( '#dplvar', '$doc noheader' ) == '1' then
if badDoc then
f:callParserFunction( '#dplvar:set', '$doc bad', '1' )
end
end
return ''
return
end
end
local page = mw.title.getCurrentTitle()
local page = mw.title.getCurrentTitle()
local namespace = args['typ'] or page.nsText
local namespace = page.nsText
local pageType = 'tym szablonie'
local pageType = mw.ustring.lower( args['typ'] or getType( namespace, page ) )
local pageType2 = 'tego szablonu'
local typeForms = getTypeForms( pageType )
local pageType3 = 'Szablony'
 
 
if namespace == 'Moduł' then
pageType = 'tym module'
pageType2 = 'tego modułu'
pageType3 = 'Moduły'
elseif page.fullText:find( '.css$' ) then
pageType = 'tem arkuszu stylów'
pageType2 = 'tego arkusza stylów'
pageType3 = 'Arkusze stylów'
elseif page.fullText:find( '.js$' ) then
pageType = 'tym skrypcie'
pageType2 = 'tego skryptu'
pageType3 = 'Skrypty'
elseif namespace == 'MediaWiki' then
pageType = 'tej wiadomości systemowej'
pageType2 = 'tej wiadomości systemowej'
pageType3 = 'Wiadomości'
end


local colour = 'EAF4F9'
local body = mw.html.create( 'div' ):addClass( 'documentation-header' )
local message = ''
body
local imageType = ''
:css{
if badDoc ~= '' then
['margin-bottom'] = '0.8em',
colour = 'F9F2EA'
padding = '0.8em 1em 0.7em',
imageType = 'bad'
}
message = "'''Dokumentacja " .. pageType .. " została uznana za niepoprawną. Jeżeli chcesz, możesz ją poprawić!'''"
:tag( 'div' )
end
:css( 'float', 'right' )
if noDoc ~= '' then
:wikitext( '[[', page:fullUrl( 'action=purge' ), ' ' .. f:preprocess('{{lc:{{int:purge}}}}') .. ']]' )
imageType = 'no'
:done()
colour = 'F9EAEA'
:wikitext(
message = "'''W " .. pageType .. " nie ma dokumentacji. Jeżeli wiesz jak używać " .. pageType2 .. ", dodaj więcej informacji do dokumentacji.'''"
'To jest strona dokumentacji, ',
pageType == 'module' and 'będzie ona dołączona' or 'powinna ona być dołączona',
' na stronie głównej. ',
'Aby uzyskać więcej informacji sprawdź [[Szablon:Dokumentacja]].'
)
if badDoc then
body:wikitext( "<br>'''Dokumentacja " .. typeForms.gen .. " wymaga uzupełnienia lub ulepszenia.'''" )
elseif forceNoDoc then
body:wikitext( "<br>'''W " .. typeForms.gen .. " nie ma dokumentacji. Jeśli wiesz jak używać " .. typeForms.acc .. ", udokumentuj to.'''" )
end
end


local certainty = 'powinna ona być dołączona'
if not ( args["niekat"] or namespace == 'Użytkownik' or namespace == 'Użytkowniczka' ) then
if pageType2 ~= 'tego szablonu' then
body:wikitext( '[[Kategoria:Szablony dokumentacji]]' )
certainty = 'będzie ona dołączona'
end
local category = ''
if args['niekat'] ~= '1' then
category = '[[Kategoria:Szablony dokumentacji]]'
end
end
local out = table.concat( {
return body
'<div style="margin-bottom: 0.8em; padding: 0.8em 1em 0.7em; background-color: #' .. colour .. '; border: 1px solid #AAA">',
'<div class="doc-image">[[File:Template-' .. imageType .. 'info.png|60px]]</div>',
 
'<div style="float: right">[[' .. page:fullUrl( 'action=purge' ) .. ' ' .. f:preprocess( '{{lc:{{int:page-header-action-button-purge}}}}' ) .. ']]</div>',
'<div style="margin: 0">To jest strona dokumentacji, ' .. certainty .. ' na stronie głównej ' .. pageType .. '. Aby uzyskać więcej informacji sprawdź  [[Szablon:Dokumentacja]].</div>',
message,
'</div>',
category
}, '\n' )
return mw.text.trim( out )
end
end


-- Wrapper around the documentation on the main page
-- Wrapper around the documentation on the main page
function p.page( f )
function p.page( f )
local args = require( 'Moduł:ProcessArgs' ).merge( true )
-- mw.text.trim uses mw.ustring.gsub, which silently fails on large strings
local function trim( s )
return (s:gsub( '^[\t\r\n\f ]+', '' ):gsub( '[\t\r\n\f ]+$', '' ))
end
local args = require( 'Moduł:ProcessArgs' ).merge( true )
local page = mw.title.getCurrentTitle()
local page = mw.title.getCurrentTitle()
local namespace = args['typ'] or page.nsText
local namespace = page.nsText
local docPage = mw.title.new( args['strona'] or namespace .. ':' .. page.text .. '/opis' )
local docText = trim( args["treść"] or '' )
local noDoc = args['brakdok'] or ''
if docText == '' then docText = nil end
if not docPage.exists or noDoc ~= '' then
local noDoc = 1
local docPage
local badDoc = nil
local noDoc
elseif args['zladok'] ~= '' then
local forceNoDoc
local badDoc = 1
if docText then
local noDoc = nil
docPage = page
else
docPage = mw.title.new( args["strona"] or namespace .. ':' .. page.text .. '/' .. defaultDocPage)
noDoc = args["brakdok"] or not docPage.exists
end
end
local pageType = 'tym szablonie'
local badDoc = args["zladok"]
local pageType2 = 'tego szablonu'
local pageType = mw.ustring.lower( args['typ'] or getType( namespace, page ) )
local pageType3 = 'Szablony'
local typeForms = getTypeForms( pageType )
 
if namespace == 'Moduł' then
if not docText and not noDoc then
pageType = 'tym module'
f:callParserFunction( '#dplvar:set', '$doc noheader', '1' )
pageType2 = 'tego modułu'
docText = trim( f:expandTemplate{ title = ':' .. docPage.fullText } )
pageType3 = 'Moduły'
if f:callParserFunction( '#dplvar', '$doc bad' ) == '1' then
elseif page.fullText:find( '.css$' ) then
pageType = 'tem arkuszu stylów'
pageType2 = 'tego arkusza stylów'
pageType3 = 'Arkusze stylów'
elseif page.fullText:find( '.js$' ) then
pageType = 'tym skrypcie'
pageType2 = 'tego skryptu'
pageType3 = 'Skrypty'
elseif namespace == 'MediaWiki' then
pageType = 'tej wiadomości systemowej'
pageType2 = 'tej wiadomości systemowej'
pageType3 = 'Wiadomości'
 
end
 
local docText = ''
 
if docPage.exists then
f:callParserFunction( '#dplvar:set', 'noheader', '1' )
docText = mw.text.trim( f:expandTemplate{ title = ':' .. docPage.fullText } )
if f:callParserFunction( '#dplvar:baddoc' ) == '1' then
badDoc = 1
badDoc = 1
end
end
 
forceNoDoc = f:callParserFunction( '#dplvar', '$doc forced_none' ) == '1'
if docText == '' then
noDoc = 1
if docText == '' and not forceNoDoc then
else
docText = nil
docText = '\n' .. docText .. '\n'
end
 
if f:callParserFunction( '#dplvar:notdoc' ) == '1' then
noDoc = 1
noDoc = 1
end
end
end
if docText then
docText = '\n' .. docText .. '\n'
end
end
local action = f:preprocess( '{{lc:{{int:editlink}}}}' )
local action = f:preprocess('{{lc:{{int:edit}}}}')
local preload = ''
local preload = ''
local colour = 'EAF4F9'
local docclass = "documentation-norm"
local message = ''
local message
local category = ''
local category
local imageType = ''
if noDoc then
if not docPage.exists then
action = f:preprocess('{{lc:{{int:create}}}}')
action = f:preprocess( '{{lc:{{int:create}}}}' )
preload = '&preload=Szablon:Dokumentacja/preload'
preload = '&preload=Szablon:Dokumentacja/preload'
noDoc = 1
docclass = "documentation-no"
end
message = "'''W " .. typeForms.gen .. " nie ma dokumentacji. " ..
if noDoc == 1 then
"Jeśli wiesz jak używać " .. typeForms.acc .. ", proszę, podaj odpowiednie informacje.'''"
imageType = 'no'
if not ( args["niekat"] or namespace == 'Użytkownik' or namespace == 'Użytkowniczka' ) then
colour = 'F9EAEA'
category = typeForms.nomP .. ' bez dokumentacji'
message = "'''W " .. pageType .. " nie ma dokumentacji. Jeśli wiesz jak używać " .. pageType2 .. ", dodaj odpowiednie informacje.'''"
if not mw.title.new( 'Kategoria:' .. category ).exists then
if args['niekat'] ~= '1' then
category = 'Strony bez dokumentacji'
if mw.title.new( 'Kategoria:' .. pageType3 .. ' bez dokumentacji' ).exists then
end
category = '[[Kategoria:' .. pageType3 .. ' bez dokumentacji]]'
end
else
elseif forceNoDoc then
category = '[[Kategoria:Strony bez dokumentacji]]'
docclass = "documentation-no"
message = "'''W " .. typeForms.gen .. " nie ma dokumentacji. " ..
"Jeśli wiesz jak używać  " .. typeForms.acc .. ", proszę, podaj odpowiednie informacje.'''"
if not ( args["niekat"] or namespace == 'Użytkownik' or namespace == 'Użytkowniczka' ) then
category = typeForms.nomP .. ' bez dokumentacji'
if not mw.title.new( 'Kategoria:' .. category ).exists then
category = 'Strony bez dokumentacji'
end
end
end
end
elseif badDoc then
elseif badDoc then
imageType = 'bad'
docclass = "documentation-bad"
colour = 'F9F2EA'
message = "'''Dokumentacja " .. typeForms.gen .. " wymaga uzupełnienia lub ulepszenia.'''\n"
message = "'''Dokumentacja " .. pageType .. " została uznanana za niepoprawną. Jeżeli masz czas, uzupełnij ją!'''\n"
if not ( args["niekat"] or namespace == 'Użytkownik' or namespace == 'Użytkowniczka' ) then
if args['niekat'] ~= '1' then
category = typeForms.nomP .. ' ze złą dokumentacją'
if mw.title.new( 'Kategoria:' .. pageType3 .. ' ze złą dokumentacją' ).exists then
if not mw.title.new( 'Kategoria:' .. category ).exists then
category = '[[Kategoria:' .. pageType3 .. ' ze złą dokumentacją]]'
category = 'Strony ze złą dokumentacją'
else
category = '[[Kategoria:Strony ze złą dokumentacją]]'
end
end
end
end
end
end
local historyLink = f:preprocess('{{lc:{{int:history short}}}}')
local purgeLink = f:preprocess('{{lc:{{int:purge}}}}')
local viewLink = f:preprocess('{{lc:{{int:view}}}}')
local links = {
local links = {
'[' .. docPage:fullUrl( 'action=edit' .. preload ) .. ' ' .. action .. ']',
'[' .. docPage:fullUrl( 'action=edit' .. preload ) .. ' ' .. action .. ']',
'[' .. page:fullUrl( 'action=purge' ) .. ' ' .. f:preprocess( '{{lc:{{int:page-header-action-button-purge}}}}' ) .. ']'
'[' .. docPage:fullUrl( 'action=history' ) .. ' ' .. historyLink .. ']',
'[' .. page:fullUrl( 'action=purge' ) .. ' ' .. purgeLink .. ']'
}
}
local footer = ''
if not noDoc and page ~= docPage then
if docPage.exists then
table.insert( links, 1, '[[' .. docPage.fullText .. '|' .. viewLink .. ']]' )
table.insert( links, 1, '[[' .. docPage.fullText .. '|' .. f:preprocess( '{{lc:{{int:view}}}}' ) .. ']]' )
footer = table.concat( {
'<div class="documentation-header-bottom" style="margin: 0.7em -1em -0.7em; background-color:#EAF4F9; border-top: 1px solid #AAA; padding: 0.8em 1em 0.7em; clear: both">\n',
'<div style="float: right">' .. mw.text.nowiki( '[' ) .. table.concat( links, ' | ' ) .. ']</div>\n',
'<p style="margin: 0">Powyższy opis jest dołączany ze strony [[' .. docPage.fullText .. ']].</p>\n',
'</div>\n'
} )
end
end
links = mw.html.create( 'span' )
:css( 'float', 'right' )
:wikitext( mw.text.nowiki( '[ ' ), table.concat( links, ' | ' ), mw.text.nowiki( ' ]' ) )
local out = {
local body = mw.html.create( 'div' ):addClass( 'documentation ' .. docclass )
'<div class="documentation" style="background-color: #' .. colour .. '; border: 1px solid #AAA; padding: 0.8em 1em 0.7em; clear: both">\n',
body:css{
'<div class="documentation-header-top" style="margin: -0.8em -1em 0.8em; padding: 0.8em 1em 0.7em; background-color:#EAF4F9; border-bottom: 1px solid #AAA">\n',
padding = '0.8em 1em 0.7em',
'<div class="doc-image">[[File:Template-' .. imageType .. 'info.png|60px]]</div>',
['margin-top'] = '1em',
'<div style="float: right">' .. mw.text.nowiki( '[' ) .. table.concat( links, ' | ' ) .. ']</div>\n',
clear = 'both'
'<span style="font-weight: bold; font-size: 130%">Dokumentacja</span>',
'</div>\n',
message,
docText,
footer,
'</div>\n',
category
}
}
return mw.text.trim( table.concat( out ) )
local header = mw.html.create( 'div' )
:addClass( 'documentation-header' )
:css{
margin = '-0.8em -1em 0.8em',
padding = '0.8em 1em 0.7em',
['border-bottom'] = 'inherit'
}
header
:node( links )
:tag( 'span' )
:css{
['font-weight'] = 'bold',
['font-size'] = '130%',
['margin-right'] = '1em',
['line-height'] = '1'
}
:wikitext( 'Dokumentacja' )
if not noDoc and pageType ~= 'template' and pageType ~= 'message' then
header
:tag( 'span' )
:css( 'white-space', 'nowrap' )
:wikitext( '[[#the-code|Przejdź do kodu ↴]]' )
end
body
:node( header ):done()
:wikitext( message )
:wikitext( docText )
if not noDoc and page ~= docPage then
body
:tag( 'div' )
:addClass( 'documentation-footer' )
:css{
margin = '0.7em -1em -0.7em',
['border-top'] = 'inherit',
padding = '0.8em 1em 0.7em',
clear = 'both'
}
:node( links )
:wikitext( 'Powyższy opis jest dołączany ze strony  [[' .. docPage.fullText .. ']].' )
end
if category then
body:wikitext( "[[Kategoria:" .. category .. "]]" )
end
local anchor = ''
if not noDoc and pageType ~= 'template' and pageType ~= 'message' then
anchor = mw.html.create( 'div' ):attr( 'id', 'the-code' )
end
return tostring( body ) .. tostring( anchor )
end
end
return p
return p

Aktualna wersja na dzień 18:08, 8 gru 2024

Używana w {{Dokumentacja}} i {{Dokumentacja/Nagłówek}}

Zależności

local p = {}

local defaultDocPage = 'opis'

local getType = function( namespace, page )
	local pageType = 'template'
	if namespace == 'Moduł' or namespace == 'Module' then
		pageType = 'module'
	elseif namespace == 'Widget' then
		pageType = 'widget'
	elseif page.fullText:gsub( '/' .. defaultDocPage .. '$', '' ):find( '%.css$' ) then
		pageType = 'stylesheet'
	elseif page.fullText:gsub( '/' .. defaultDocPage .. '$', '' ):find( '%.js$' ) then
		pageType = 'script'
	elseif namespace == 'MediaWiki' then
		pageType = 'message'
	end
	
	return pageType
end

local getTypeForms = function( pageType )
	if pageType == 'module' then
		return {gen = 'tym module', acc = 'tego modułu', pronoun_gen = "его", nomP = 'Moduły'}
	elseif pageType == 'widget' then
		return {gen = 'tym widżecie', acc = 'tego widżetu', pronoun_gen = "его", nomP = 'Widżety'}
	elseif pageType == 'stylesheet' then
		return {gen = 'tym arkuszu stylów', acc = 'tego arkusza stylów', pronoun_gen = "еro", nomP = 'Arkusze stylów'}
	elseif pageType == 'script' then
		return {gen = 'tym skrypcie', acc = 'tego skryptu', pronoun_gen = "его", nomP = 'Skrypty'}
	elseif pageType == 'message' then
		return {gen = 'tej wiadomości systemowej', acc = 'tej wiadomości systemowej', pronoun_gen = "его", nomP = 'Wiadomości'}
	else -- type == 'template'
		return {gen = 'tym szablonie', acc = 'tego szablonu', pronoun_gen = "его", nomP = 'Szablony'}
	end
end

-- Creating a documentation page or transclution through {{subst:doc}}
function p.create( f )
	local args = require( 'Moduł:ProcessArgs' ).norm()
	local page = mw.title.getCurrentTitle()
	local docPage = args['strona'] or page.nsText .. ':' .. page.baseText .. '/' .. defaultDocPage
	
	local out
	if not args["treść"] and tostring( page ) == docPage then
		out = f:preprocess( '{{subst:Szablon:Dokumentacja/preload}}' )
	else
		local templateArgs = {}
		for _, key in ipairs{ 'typ', 'strona', 'treść' } do
			local val = args[key]
			if val then
				if key == 'treść' then val = '\n' .. val .. '\n' end
				table.insert( templateArgs, key .. '=' .. val )
			end
		end
	
		out = '{{Dokumentacja|' .. table.concat( templateArgs, '|' ) .. '}}'
		out = out:gsub( '|}}', '}}' )
		
		if not args["treść"] then
			out = out .. '\n<!-- Kategorie i interwiki umieść na stronie dokumentacji.  -->'
		end
	end
	
	if not mw.isSubsting() then
		out = f:preprocess( out )
		if not args['niekat'] then
			out = out .. '[[Kategoria:Pages with templates requiring substitution]'
		end
	end
	
	return out
end

-- Header2 on the documentation page
function p.docPage( f )
	local args = require( 'Moduł:ProcessArgs' ).merge( true )
	local badDoc = args['zladok']
	local forceNoDoc = args['brakdok']
	
	local docclass = "documentation-norm"
	if badDoc then
		docclass = "documentation-bad"
	elseif forceNoDoc then
		docclass = "documentation-no"
	end
	if forceNoDoc then
		f:callParserFunction( '#dplvar:set', '$doc forced_none', '1' )
	end
	
	if f:callParserFunction( '#dplvar', '$doc noheader' ) == '1' then
		if badDoc then
			f:callParserFunction( '#dplvar:set', '$doc bad', '1' )
		end
		return
	end
	
	local page = mw.title.getCurrentTitle()
	local namespace = page.nsText
	local pageType = mw.ustring.lower( args['typ'] or getType( namespace, page ) )
	local typeForms = getTypeForms( pageType )

	local body = mw.html.create( 'div' ):addClass( 'documentation-header' )
	body
		:css{
			['margin-bottom'] = '0.8em',
			padding = '0.8em 1em 0.7em',
		}
		:tag( 'div' )
			:css( 'float', 'right' )
			:wikitext( '[[', page:fullUrl( 'action=purge' ), ' ' .. f:preprocess('{{lc:{{int:purge}}}}') .. ']]' )
		:done()
		:wikitext(
			'To jest strona dokumentacji, ',
			pageType == 'module' and 'będzie ona dołączona' or 'powinna ona być dołączona',
			' na stronie głównej. ',
			'Aby uzyskać więcej informacji sprawdź [[Szablon:Dokumentacja]].'
		)
	if badDoc then
		body:wikitext( "<br>'''Dokumentacja " .. typeForms.gen .. " wymaga uzupełnienia lub ulepszenia.'''" )
	elseif forceNoDoc then
		body:wikitext( "<br>'''W " .. typeForms.gen .. " nie ma dokumentacji. Jeśli wiesz jak używać " .. typeForms.acc .. ", udokumentuj to.'''" )
	end

	if not ( args["niekat"] or namespace == 'Użytkownik' or namespace == 'Użytkowniczka' ) then
		body:wikitext( '[[Kategoria:Szablony dokumentacji]]' )
	end
	
	return body
end

-- Wrapper around the documentation on the main page
function p.page( f )
	-- mw.text.trim uses mw.ustring.gsub, which silently fails on large strings
	local function trim( s )
		return (s:gsub( '^[\t\r\n\f ]+', '' ):gsub( '[\t\r\n\f ]+$', '' ))
	end
	local args = require( 'Moduł:ProcessArgs' ).merge( true )
	local page = mw.title.getCurrentTitle()
	local namespace = page.nsText
	local docText = trim( args["treść"] or '' )
	if docText == '' then docText = nil end
	
	local docPage
	local noDoc
	local forceNoDoc
	if docText then
		docPage = page
	else
		docPage = mw.title.new( args["strona"] or namespace .. ':' .. page.text .. '/' .. defaultDocPage)
		noDoc = args["brakdok"] or not docPage.exists
	end
	local badDoc = args["zladok"]
	local pageType = mw.ustring.lower( args['typ'] or getType( namespace, page ) )
	local typeForms = getTypeForms( pageType )
	
	if not docText and not noDoc then
		f:callParserFunction( '#dplvar:set', '$doc noheader', '1' )
		docText = trim( f:expandTemplate{ title = ':' .. docPage.fullText }  )
		if f:callParserFunction( '#dplvar', '$doc bad' ) == '1' then
			badDoc = 1
		end
		forceNoDoc = f:callParserFunction( '#dplvar', '$doc forced_none' ) == '1'
		
		if docText == '' and not forceNoDoc then
			docText = nil
			noDoc = 1
		end
	end
	if docText then
		docText = '\n' .. docText .. '\n'
	end
	
	local action = f:preprocess('{{lc:{{int:edit}}}}')
	local preload = ''
	local docclass = "documentation-norm"
	local message
	local category
	if noDoc then
		action = f:preprocess('{{lc:{{int:create}}}}')
		preload = '&preload=Szablon:Dokumentacja/preload'
		docclass = "documentation-no"
		message = "'''W " .. typeForms.gen .. " nie ma dokumentacji. " ..
			"Jeśli wiesz jak używać  " .. typeForms.acc .. ", proszę, podaj odpowiednie informacje.'''"
		if not ( args["niekat"] or namespace == 'Użytkownik' or namespace == 'Użytkowniczka' ) then
			category = typeForms.nomP .. ' bez dokumentacji'
			if not mw.title.new( 'Kategoria:' .. category ).exists then
				category = 'Strony bez dokumentacji'
			end
		end
	elseif forceNoDoc then
		docclass = "documentation-no"
		message = "'''W " .. typeForms.gen .. " nie ma dokumentacji. " ..
			"Jeśli wiesz jak używać  " .. typeForms.acc .. ", proszę, podaj odpowiednie informacje.'''"
		if not ( args["niekat"] or namespace == 'Użytkownik' or namespace == 'Użytkowniczka' ) then
			category = typeForms.nomP .. ' bez dokumentacji'
			if not mw.title.new( 'Kategoria:' .. category ).exists then
				category = 'Strony bez dokumentacji'
			end
		end
	elseif badDoc then
		docclass = "documentation-bad"
		message = "'''Dokumentacja " .. typeForms.gen .. " wymaga uzupełnienia lub ulepszenia.'''\n"
		if not ( args["niekat"] or namespace == 'Użytkownik' or namespace == 'Użytkowniczka' ) then
			category = typeForms.nomP .. ' ze złą dokumentacją'
			if not mw.title.new( 'Kategoria:' .. category ).exists then
				category = 'Strony ze złą dokumentacją'
			end
		end
	end
	
	local historyLink =	f:preprocess('{{lc:{{int:history short}}}}')
	local purgeLink =	f:preprocess('{{lc:{{int:purge}}}}')
	local viewLink =	f:preprocess('{{lc:{{int:view}}}}')

	local links = {
		'[' .. docPage:fullUrl( 'action=edit' .. preload ) .. ' ' .. action .. ']',
		'[' .. docPage:fullUrl( 'action=history' ) .. ' ' .. historyLink .. ']',
		'[' .. page:fullUrl( 'action=purge' ) .. ' ' .. purgeLink .. ']'
	}
	if not noDoc and page ~= docPage then
		table.insert( links, 1, '[[' .. docPage.fullText .. '|' .. viewLink .. ']]' )
	end
	links = mw.html.create( 'span' )
		:css( 'float', 'right' )
		:wikitext( mw.text.nowiki( '[ ' ), table.concat( links, ' | ' ), mw.text.nowiki( ' ]' ) )
	
	local body = mw.html.create( 'div' ):addClass( 'documentation ' .. docclass )
	body:css{
		padding = '0.8em 1em 0.7em',
		['margin-top'] = '1em',
		clear = 'both'
	}
	
	local header = mw.html.create( 'div' )
		:addClass( 'documentation-header' )
		:css{
			margin = '-0.8em -1em 0.8em',
			padding = '0.8em 1em 0.7em',
			['border-bottom'] = 'inherit'
		}
	
	header
		:node( links )
		:tag( 'span' )
			:css{
				['font-weight'] = 'bold',
				['font-size'] = '130%',
				['margin-right'] = '1em',
				['line-height'] = '1'
			}
			:wikitext( 'Dokumentacja' )
	
	if not noDoc and pageType ~= 'template' and pageType ~= 'message' then
		header
			:tag( 'span' )
				:css( 'white-space', 'nowrap' )
				:wikitext( '[[#the-code|Przejdź do kodu ↴]]' )
	end
	
	body
		:node( header ):done()
		:wikitext( message )
		:wikitext( docText )
	
	if not noDoc and page ~= docPage then
		body
			:tag( 'div' )
				:addClass( 'documentation-footer' )
				:css{
					margin = '0.7em -1em -0.7em',
					['border-top'] = 'inherit',
					padding = '0.8em 1em 0.7em',
					clear = 'both'
				}
				:node( links )
				:wikitext( 'Powyższy opis jest dołączany ze strony  [[' .. docPage.fullText .. ']].' )
	end
	
	if category then
		body:wikitext( "[[Kategoria:" .. category .. "]]" )
	end
	
	local anchor = ''
	if not noDoc and pageType ~= 'template' and pageType ~= 'message' then
		anchor = mw.html.create( 'div' ):attr( 'id', 'the-code' )
	end
	
	return tostring( body ) .. tostring( anchor )
end

return p