Moduł:Dokumentacja
Używana w {{Dokumentacja}} i {{Dokumentacja/Nagłówek}}
Zależności
Powyższy opis jest dołączany ze strony Moduł:Dokumentacja/opis.
local p = {}
-- Creating a documentation page or transclution through {{subst:doc}}
function p.create( f )
local args = require( 'Moduł:ProcessArgs' ).norm()
page = mw.title.getCurrentTitle()
namespace = args['тип'] or page.nsText
docPage = args['strona'] or namespace .. ':' .. page.baseText .. '/opis'
local out
if page.fullText == docPage then
out = f:preprocess( '{{subst:Szablon:Dokumentacja/Предзагрузка}}' )
else
local templateArgs = {}
if args['тип'] then
table.insert( templateArgs, 'тип=' .. args['тип'] )
end
if args['страница'] then
table.insert( templateArgs, 'strona=' .. args['strona'] )
end
out = '{{Dokumentacja|' .. table.concat( templateArgs, '|' ) .. '}}\n<!-- Kategorie i interwiki umieść na stronie dokumentacji. -->'
out = out:gsub( '|}}', '}}' )
end
if not mw.isSubsting() then
out = f:preprocess( out )
if not args['niekat'] then
out = out .. '[[Kategoria:Страницы с требующими подстановки шаблонами]]'
end
end
return out
end
-- Header on the documentation page
function p.docPage(f)
local args = require( 'Moduł:ProcessArgs' ).merge( true )
local badDoc = args['zladok']
if f:callParserFunction( '#dplvar:noheader' ) == '1' then
if badDoc then
f:callParserFunction( '#dplvar:set', 'baddoc', '1' )
end
return ''
end
local page = mw.title.getCurrentTitle()
local namespace = args['тип'] or page.nsText
local pageType = 'tym szablonie'
local pageType2 = 'tego szablonu'
local pageType3 = 'Szablony'
if namespace == 'Moduł' then
pageType = 'этого модуля'
pageType2 = 'этот модуль'
pageType3 = 'Moduły'
elseif page.fullText:find( '.css$' ) then
pageType = 'этой таблицы стилей'
pageType2 = 'эту таблицу стилей'
pageType3 = 'Arkusze stylów'
elseif page.fullText:find( '.js$' ) then
pageType = 'этого скрипта'
pageType2 = 'этот скрипт'
pageType3 = 'Skrypty'
elseif namespace == 'MediaWiki' then
pageType = 'этого сообщения'
pageType2 = 'это сообщение'
pageType3 = 'Wiadomości'
end
local colour = 'EAF4F9'
local message = ''
if badDoc then
colour = 'F9F2EA'
message = "'''Dokumentacja " .. pageType .. " была отмечена как плохая. Пожалуйста, дополните или улучшите её.'''"
end
local certainty = 'её следует включить'
if pageType2 == 'этот модуль' then
certainty = 'она будет включена'
end
local category = ''
if not args['niekat'] then
category = '[[Kategoria:Szablony dokumentacji]]'
end
local out = table.concat( {
'<div style="margin-bottom: 0.8em; padding: 0.8em 1em 0.7em; background-color: #' .. colour .. '; border: 1px solid #AAA">',
'<div style="float: right">[[' .. page:fullUrl( 'action=purge' ) .. ' odśwież]]</div>',
'<p style="margin: 0">To jest strona dokumentacji, ' .. certainty .. ' в основную страницу ' .. pageType .. '. Для дополнительной информации см. [[Szablon:Dokumentacja]].</p>',
message,
'</div>',
category
}, '\n' )
return mw.text.trim( out )
end
-- Wrapper around the documentation on the main page
function p.page( f )
local args = require( 'Moduł:ProcessArgs' ).merge( true )
local page = mw.title.getCurrentTitle()
local namespace = args['тип'] or page.nsText
local docPage = mw.title.new( args['strona'] or namespace .. ':' .. page.text .. '/opis' )
local noDoc = args['brakdok'] or not docPage.exists
local badDoc = args['zladok']
local pageType = 'этого шаблона'
local pageType2 = 'этот шаблон'
local pageType3 = 'Szablony'
if namespace == 'Moduł' then
pageType = 'этого модуля'
pageType2 = 'этот модуль'
pageType3 = 'Moduły'
elseif page.fullText:find( '.css$' ) then
pageType = 'этой таблицы стилей'
pageType2 = 'эту таблицу стилей'
pageType3 = 'Arkusze stylów'
elseif page.fullText:find( '.js$' ) then
pageType = 'этого скрипта'
pageType2 = 'этот скрипт'
pageType3 = 'Skrypty'
elseif namespace == 'MediaWiki' then
pageType = 'этого сообщения'
pageType2 = 'это сообщение'
pageType3 = 'Wiadomości'
end
local docText = ''
if not noDoc 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
end
if docText == '' then
noDoc = 1
else
docText = '\n' .. docText .. '\n'
end
end
local action = 'edytuj'
local preload = ''
local colour = 'EAF4F9'
local message = ''
local category = ''
if noDoc then
action = 'utwórz'
preload = '&preload=Szablon:Dokumentacja/Предзагрузка'
colour = 'F9EAEA'
message = "'''W " .. pageType .. " nie ma dokumentacji. Jeśli wiesz jak używać " .. pageType2 .. ", dodaj odpowiednie informacje.'''"
if not args['niekat'] then
if mw.title.new( 'Kategoria:' .. pageType3 .. ' bez dokumentacji.' ).exists then
category = '[[Kategoria:' .. pageType3 .. ' bez dokumentacji]]'
else
category = '[[Kategoria:Strony bez dokumentacji]]'
end
end
elseif badDoc then
colour = 'F9F2EA'
message = "'''Документация " .. pageType .. " была отмечена как плохая. Пожалуйста, дополните или улучшите её.'''\n"
if not args['niekat'] then
if mw.title.new( 'Kategoria:' .. pageType3 .. ' ze złą dokumentacją' ).exists then
category = '[[Kategoria:' .. pageType3 .. ' ze złą dokumentacją]]'
else
category = '[[Kategoria:Strony ze złą dokumentacją]]'
end
end
end
local links = {
'[' .. docPage:fullUrl( 'action=edit' .. preload ) .. ' ' .. action .. ']',
'[' .. page:fullUrl( 'action=purge' ) .. ' odśwież]'
}
local footer = ''
if not noDoc then
table.insert( links, 1, '[[' .. docPage.fullText .. '|podgląd]]' )
footer = table.concat( {
'<div 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
local out = {
'<div style="background-color: #' .. colour .. '; border: 1px solid #AAA; padding: 0.8em 1em 0.7em; clear: both">\n',
'<div style="margin: -0.8em -1em 0.8em; padding: 0.8em 1em 0.7em; background-color: #EAF4F9; border-bottom: 1px solid #AAA">\n',
'<div style="float: right">' .. mw.text.nowiki( '[' ) .. table.concat( links, ' | ' ) .. ']</div>\n',
'<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 ) )
end
return p