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

Z Minecraft Wiki Polska
Przejdź do nawigacji Przejdź do wyszukiwania
[wersja nieprzejrzana][wersja przejrzana]
Nie podano opisu zmian
d 6 wersji: zaimportowano zawartość stron i zmian powstałych w staging oraz historie ich edycji
 
(Nie pokazano 47 wersji utworzonych przez 4 użytkowników)
Linia 4: Linia 4:
if f == mw.getCurrentFrame() then  
if f == mw.getCurrentFrame() then  
args = require( 'Module:ProcessArgs' ).merge( true )
args = require( 'Module:ProcessArgs' ).merge( true )
else
f = mw.getCurrentFrame()
end
end
Linia 9: Linia 11:
local default = {
local default = {
scale = 1,
scale = 1,
sheetsize = 256,
["format"] = 256,
size = 16,
["wielkość"] = 16,
pos = 1,
pos = 1,
link = '',
["wyrówn"] = 'text-top'
align = 'text-top',
class = '',
text = '',
title = ''
}
}
local defaultStyle = mw.clone( default )
local defaultStyle = default
if args.settings then
if args["ustawienia"] then
local settings = mw.loadData( 'Module:' .. args.settings )
local settings = mw.loadData( 'Module:' .. args["ustawienia"] )
if not settings["tablica Ikonek"] then
-- Make a separate clone of the current default settings
defaultStyle = mw.clone( default )
end
for k, v in pairs( settings ) do
for k, v in pairs( settings ) do
default[k] = v
default[k] = v
if settings.stylesheet then
defaultStyle[k] = v
end
end
end
end
end
local name = args.name or default.name
local setting = function( arg )
local scale = args.scale or default.scale
return args[arg] or default[arg]
local autoScale = args.autoscale or default.autoscale
end
local sheetWidth = args.sheetsize or default.sheetsize
local size = args.size or default.size
local sprite = mw.html.create( 'span' ):addClass( 'sprite' )
local pos = math.abs( args.pos or default.pos ) - 1
sprite:tag( 'br' )
local link = args.link or default.link
local align = args.align or default.align
if setting( 'tablica Ikonek' ) then
local class = args.class or default.class
sprite:addClass(
local text = args.text or default.text
setting( 'classname' ) or
local title = args.title or default.title
mw.ustring.lower( setting( 'name' ):gsub( ' ', '-' ) ) .. '-sprite'
local css = args.css or default.css
)
local className = args.classname or default.classname
end
 
local class = setting( 'klasa' )
if class then
sprite:addClass( class )
end
local size = setting( 'wielkość' )
local pos = math.abs( setting( 'pos' ) ) - 1
local sheetWidth = setting( 'format' )
local tiles = sheetWidth / size
local tiles = sheetWidth / size
local left = pos % tiles * size
local left = pos % tiles * size
local top = math.floor( pos / tiles ) * size
local top = math.floor( pos / tiles ) * size
local scale = setting( 'scale' )
local autoScale = setting( 'wyrówn' )
local styles = {}
if args.stylesheet or default.stylesheet then
class = ( className or mw.ustring.lower( name:gsub( ' ', '-' ) ) .. '-sprite ' ) .. class
else
table.insert( styles, 'background-image:{{FileUrl|' .. ( args.image or default.image or name .. 'Sprite.png' ) .. '}}' )
end
if left > 0 or top > 0 then
if left > 0 or top > 0 then
table.insert( styles, 'background-position:-' .. left * scale .. 'px -' .. top * scale .. 'px' )
sprite:css('background-position', '-' .. left * scale .. 'px -' .. top * scale .. 'px')
end
end
if not autoScale and scale ~= defaultStyle.scale then
if not autoScale and scale ~= defaultStyle.scale then
table.insert( styles, 'background-size:' .. sheetWidth * scale .. 'px auto' )
sprite:css('background-size', sheetWidth * scale .. 'px auto')
end
end
if size ~= defaultStyle.size or ( not autoScale and scale ~= defaultStyle.scale ) then
if size ~= defaultStyle.size or ( not autoScale and scale ~= defaultStyle.scale ) then
table.insert( styles, 'height:' .. size * scale .. 'px;width:' .. size * scale .. 'px' )
sprite:css('height', size * scale .. 'px')
sprite:css('width', size * scale .. 'px')
end
end
local align = setting( 'wyrówn' )
if align ~= defaultStyle.align then
if align ~= defaultStyle.align then
table.insert( styles, 'vertical-align:' .. align )
sprite:css('vertical-align', align)
end
end
if css then
table.insert( styles, css )
local text = setting( 'text' )
local root
local spriteText
if text then
root = mw.html.create( 'span' ):addClass( 'nowrap' )
spriteText = mw.html.create( 'span' ):addClass( 'sprite-text' ):wikitext( text )
end
end
if title ~= '' then
title = ' title="' .. title .. '"'
local title = setting( 'title' )
if title then
( root or sprite ):attr( 'title', title)
end
end
local sprite = table.concat( {
if not root then
'<span',
root = mw.html.create( '' )
'class="sprite ' .. class .. '"',
end
'style="' .. table.concat( styles, ';' ) .. '"',
root:node( sprite )
title,
if spriteText then
'><br></span>'
root:node( spriteText )
}, ' ' )
sprite = sprite:gsub( '%s+([">])', '%1' )
if text ~= '' then
text = '<span class="sprite-text"' .. title .. '>' .. text .. '</span>'
end
end
local content = '<span class="nowrap">' .. sprite .. text .. '</span>'
local link = setting( 'link' ) or ''
if link ~= '' and mw.ustring.lower( link ) ~= 'none' then
if link ~= '' and mw.ustring.lower( link ) ~= 'nie' then
-- External link
if link:find( '//' ) then
if link:find( '//' ) then
-- External link
return '[' .. link .. ' ' .. tostring( root ) .. ']'
return '[' .. link .. ' ' .. content .. ']'
else
-- Internal link
local linkPrefix = args.linkprefix or default.linkprefix or ''
return '[[' .. linkPrefix .. link .. '|' .. content .. ']]'
end
end
else
return content
-- Internal link
local linkPrefix = setting( 'linkprefix' ) or ''
return '[[' .. linkPrefix .. link .. '|' .. tostring( root ) .. ']]'
end
end
return tostring( root )
end
end


Linia 105: Linia 111:
if f == mw.getCurrentFrame() then
if f == mw.getCurrentFrame() then
args = require( 'Module:ProcessArgs' ).merge( true )
args = require( 'Module:ProcessArgs' ).merge( true )
else
f = mw.getCurrentFrame()
end
end
local category = ''
local categories = {}
if tonumber( args[1] ) then
local idData = args["danychID"]
args.pos = args[1]
if not idData then
else
local default = {}
local default = {}
if args.settings then
if args["ustawienia"] then
default = mw.loadData( 'Module:' .. args.settings )
default = mw.loadData( 'Module:' .. args["ustawienia"] )
end
end
local name = args.name or default.name
local name = args.name or default.name
local ids = mw.loadData( 'Module:' .. ( args.ids or default.ids or 'Sprite/' .. name ) )
local ids = mw.loadData( 'Module:' .. ( args.ids or default.ids or name .. 'Sprite/IDs' ) )
local id = mw.text.trim( args[1] or '' )
ids = ids.ids or ids
local pos = ids[id] or ids[mw.ustring.lower( id ):gsub( '[%s%+]', '-' )]
local id = mw.text.trim( tostring( args[1] or '' ) )
if not pos and not mw.title.getCurrentTitle().isSubpage then
idData = ids[id] or ids[mw.ustring.lower( id ):gsub( '[%s%+]', '-' )]
category = '[[Category:Pages with missing sprites]]'
end
local title = mw.title.getCurrentTitle()
-- Remove categories on language pages, talk pages, and in User/UserWiki/UserProfile namespaces
local disallowCats = title.isTalkPage or title.nsText:find( '^User' )
if idData then
if type( idData ) == 'table' then
if idData.deprecated and not disallowCats then
table.insert( categories, f:expandTemplate{ title = 'Translation category', args = { 'Pages using deprecated sprite names', project = 0 } } )
end
args.pos = idData.pos
else
args.pos = idData
end
end
args.pos = pos
elseif not disallowCats then
table.insert( categories, f:expandTemplate{ title = 'Translation category', args = { 'Pages with missing sprites', project = 0 } } )
end
end
return p.base( args ) .. category
return p.base( args ), table.concat( categories, '' )
end
end


Linia 149: Linia 170:


function p.doc( f )
function p.doc( f )
local settings = mw.loadData( 'Module:' .. f.args[1] )
local args = f
local idTable = mw.title.new( 'Module:' .. ( settings.ids or 'Sprite/' .. settings.name ) ):getContent()
if f == mw.getCurrentFrame() then
idTable = idTable:gsub( '(\n%s*%-%-%s*.-%s*%-%-%s*\n)', '%1,' ):gsub( '^return {', '' ):gsub( '}$', '' )
args = f.args
else
f = mw.getCurrentFrame()
end
local settingsPage = mw.text.trim( args[1] )
local settings = mw.loadData( 'Module:' .. settingsPage )
local idsPage = 'Module:InvSprite/IDs'
local html = {}
local getProtection = function( title, action, extra )
local ids = {}
local protections = { 'edit' }
local posKeys = {}
if extra then
local section = ''
table.insert( protections, extra )
for line in mw.text.gsplit( idTable, ',' ) do
end
line = mw.text.trim( line )
id = line:match( '^%[[\'"](.+)[\'"]%]' ) or line:match( '^%w+' ) or ''
pos = line:match( '=%s*(%d+)%s*,?$' ) or ''
section = line:match( '^%-%-%s*(.+)%s*%-%-$' ) or section
if id ~= '' and pos ~= '' then
local addProtection = function( protection )
if ids[pos] then
if protection == 'autoconfirmed' then
if type( ids[pos].id ) == 'table' then
protection = 'editsemiprotected'
table.insert( ids[pos].id, id )
elseif protection == 'sysop' then
else
protection = 'editprotected'
ids[pos].id = { ids[pos].id, id }
end
else
ids[pos] = { id = id, section = section }
table.insert( posKeys, pos )
end
end
table.insert( protections, protection )
end
end
end
local list = {}
local direct = title.protectionLevels[action]
local listHead = '<ul class="spritedoc-multicolumn">'
for _, protection in ipairs( direct ) do
local listFoot = '</ul>'
addProtection( protection )
local lastSection = ''
end
for i, pos in ipairs( posKeys ) do
if title.cascadingProtection then
local id = ids[pos].id
local cascading = title.cascadingProtection.restrictions[action] or {}
local newSection = mw.text.trim( ids[pos].section )
if #cascading > 0 then
table.insert( protections, 'protect' )
if newSection ~= lastSection or i == 1 then
end
if newSection ~= lastSection then
for _, protection in ipairs( cascading ) do
if lastSection ~= '' then
addProtection( protection )
table.insert( list, listFoot )
end
table.insert( list, '\n===' .. newSection .. '===\n' )
lastSection = newSection
end
end
table.insert( list, listHead )
elseif f:callParserFunction( 'CASCADINGSOURCES', title.prefixedText ) ~= '' then
-- Just adding the requirement for the protect right should be good enough until MW 1.25
table.insert( protections, 'protect' )
end
end
table.insert( list, '<li><table><tr><td data-pos="' .. pos .. '">' )
if type( id ) == 'table' then
return table.concat( protections, ',' )
for i, id2 in ipairs( id ) do
end
if i == 1 then
table.insert( list, p.sprite{ id2, settings = f.args[1] } .. '</td><td><div class="sprite-id"><code>' .. id2 .. '</code></div>' )
local body
else
if args.refresh then
table.insert( list, '<div class="sprite-id"><code>' .. id2 .. '</code></div>' )
body = mw.html.create( '' )
end
else
end
local idsTitle = mw.title.new( idsPage )
else
local spritesheet = settings.image or settings.name .. 'Sprite.png'
table.insert( list, p.sprite{ id, settings = f.args[1] } .. '</td><td><div class="sprite-id"><code>' .. id .. '</code></div>' )
local spriteTitle = mw.title.new( 'File:' .. spritesheet )
local idsProtection = getProtection( idsTitle, 'edit' )
local spriteProtection = getProtection( spriteTitle, 'upload', 'upload,reupload' )
local dataProtection = getProtection( mw.title.new( 'Module:' .. settingsPage ), 'edit' )
body = mw.html.create( 'div' ):attr( {
id = 'spritedoc',
['data-idspage'] = idsPage,
['data-idsprotection'] = idsProtection,
['data-dataprotection'] = dataProtection,
['data-idstimestamp'] = f:callParserFunction( 'REVISIONTIMESTAMP', idsPage ),
['data-spritesheet'] = spritesheet,
['data-spriteprotection'] = spriteProtection,
['data-datapage'] = 'Module:' .. settingsPage,
['data-pos'] = settings.pos or 1,
['data-refreshtext'] = mw.text.nowiki( '{{#invoke:sprite|doc|' .. settingsPage .. '|refresh=1}}' ),
['data-settings'] = mw.text.jsonEncode( settings )
} )
end
local data = mw.loadData( idsPage )
local sections = {}
for _, sectionData in ipairs( data.sections or { 'Uncategorized' } ) do
local sectionTag = body:tag( 'div' ):addClass( 'spritedoc-section' ):attr( 'data-section-id', sectionData.id )
-- https://phabricator.wikimedia.org/T73594
sectionTag:wikitext( '<h3>', sectionData.name, '</h3>' )
sections[sectionData.id] = { boxes = sectionTag:tag( 'ul' ):addClass( 'spritedoc-boxes' ) }
end
local keyedData = {}
for name, idData in pairs( data.ids ) do
table.insert( keyedData, {
sortKey = mw.ustring.lower( name ),
name = name,
data = idData
} )
end
table.sort( keyedData, function( a, b )
return a.sortKey < b.sortKey
end )
for _, data in ipairs( keyedData ) do
local idData = data.data
local pos = idData.pos
local section = sections[idData.section]
local names = section[pos]
if not names then
local box = section.boxes:tag( 'li' ):addClass( 'spritedoc-box' ):attr( 'data-pos', pos )
box:tag( 'div' ):addClass( 'spritedoc-image' )
:wikitext( p.base{ pos = pos, ustawienia = settingsPage } )
names = box:tag( 'ul' ):addClass( 'spritedoc-names' )
section[pos] = names
end
end
table.insert( list, '</td></tr></table></li>' )
local nameElem = mw.html.create( 'li' ):addClass( 'spritedoc-name' )
local codeElem = nameElem:tag( 'code' ):wikitext( data.name )
if i == #posKeys then
if idData.deprecated then
table.insert( list, listFoot )
codeElem:addClass( 'spritedoc-deprecated' )
end
end
names:wikitext( tostring( nameElem ) )
end
end
local out = table.concat( list )
if args.refresh then
if not f.args.refresh then
return '', tostring( body )
out = f:preprocess( '{{#widget:stylesheet|page=Sprite doc}}' ) .. '<div id="sprite-doc" data-settings="' .. f.args[1] .. '">' .. out .. '</div>'
end
end
return [[<style>
return out
#spritedoc {
clear: both;
}
 
.spritedoc-section {
margin-top: 0.3em;
}
.spritedoc-section > h3 {
padding-top: 0;
margin-top: 0;
}
 
#spritedoc .spritedoc-boxes {
    display: flex;
    flex-wrap: wrap;
    padding: 0 0 1px 1px;
    margin: 0.5em 0;
}
.spritedoc-box {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0.5em;
    background: var(--theme-page-background-color--secondary);
    border: 1px solid var(--theme-border-color);
    margin: 0 0 -1px -1px;
}
 
.spritedoc-image {
/* Non-flex fallback */
display: inline-block;
/* Non-flex fallback */
vertical-align: middle;
margin-right: 0.5em;
line-height: 0;
}
 
#spritedoc .spritedoc-names {
/* Non-flex fallback */
display: inline-block;
/* Non-flex fallback */
vertical-align: middle;
width: 14em;
margin: 0;
/* Non-flex fallback */
list-style: none;
}
.spritedoc-name {
line-height: 1.2;
margin-bottom: 0.3em;
}
.spritedoc-name:last-child {
margin: 0;
}
.spritedoc-name > code {
display: inline-block;
border: 0;
border-radius: 0;
padding: 0;
word-wrap: break-word;
/* Necessary to make word-wrap work */
max-width: 14em;
}
.spritedoc-name > .spritedoc-deprecated {
    background-color: rgb(255 210 33 / 30%);
}
</style>]], tostring( body )
end
end
return p
return p

Aktualna wersja na dzień 23:58, 3 gru 2024

[ utwórz | historia | odśwież ]Dokumentacja
W tym module nie ma dokumentacji. Jeśli wiesz jak używać tego modułu, proszę, podaj odpowiednie informacje.
local p = {}
function p.base( f )
	local args = f
	if f == mw.getCurrentFrame() then 
		args = require( 'Module:ProcessArgs' ).merge( true )
	else
		f = mw.getCurrentFrame()
	end
	
	-- Default settings
	local default = {
		scale = 1,
		["format"] = 256,
		["wielkość"] = 16,
		pos = 1,
		["wyrówn"] = 'text-top'
	}
	
	local defaultStyle = default
	if args["ustawienia"] then
		local settings = mw.loadData( 'Module:' .. args["ustawienia"] )
		if not settings["tablica Ikonek"] then
			-- Make a separate clone of the current default settings
			defaultStyle = mw.clone( default )
		end
		for k, v in pairs( settings ) do
			default[k] = v
		end
	end
	
	local setting = function( arg )
		return args[arg] or default[arg]
	end
	
	local sprite = mw.html.create( 'span' ):addClass( 'sprite' )
	sprite:tag( 'br' )
	
	if setting( 'tablica Ikonek' ) then
		sprite:addClass(
			setting( 'classname' ) or
			mw.ustring.lower( setting( 'name' ):gsub( ' ', '-' ) ) .. '-sprite'
		)
	end
	local class = setting( 'klasa' )
	if class then
		sprite:addClass( class )
	end
	
	local size = setting( 'wielkość' )
	local pos = math.abs( setting( 'pos' ) ) - 1
	local sheetWidth = setting( 'format' )
	local tiles = sheetWidth / size
	local left = pos % tiles * size
	local top = math.floor( pos / tiles ) * size
	local scale = setting( 'scale' )
	local autoScale = setting( 'wyrówn' )
	
	if left > 0 or top > 0 then
		sprite:css('background-position', '-' .. left * scale .. 'px -' .. top * scale .. 'px')
	end
	if not autoScale and scale ~= defaultStyle.scale then
		sprite:css('background-size', sheetWidth * scale .. 'px auto')
	end
	if size ~= defaultStyle.size or ( not autoScale and scale ~= defaultStyle.scale ) then
		sprite:css('height', size * scale .. 'px')
		sprite:css('width', size * scale .. 'px')
	end
	local align = setting( 'wyrówn' )
	if align ~= defaultStyle.align then
		sprite:css('vertical-align', align)
	end
	
	local text = setting( 'text' )
	local root
	local spriteText
	if text then
		root = mw.html.create( 'span' ):addClass( 'nowrap' )
		spriteText = mw.html.create( 'span' ):addClass( 'sprite-text' ):wikitext( text )
	end
	
	local title = setting( 'title' )
	if title then
		( root or sprite ):attr( 'title', title)
	end
	
	if not root then
		root = mw.html.create( '' )
	end
	root:node( sprite )
	if spriteText then
		root:node( spriteText )
	end
	
	local link = setting( 'link' ) or ''
	if link ~= '' and mw.ustring.lower( link ) ~= 'nie' then
		-- External link
		if link:find( '//' ) then
			return '[' .. link .. ' ' .. tostring( root ) .. ']'
		end
		
		-- Internal link
		local linkPrefix = setting( 'linkprefix' ) or ''
		return '[[' .. linkPrefix .. link .. '|' .. tostring( root ) .. ']]'
	end
	
	return tostring( root )
end

function p.sprite( f )
	local args = f
	if f == mw.getCurrentFrame() then
		args = require( 'Module:ProcessArgs' ).merge( true )
	else
		f = mw.getCurrentFrame()
	end
	
	local categories = {}
	local idData = args["danychID"]
	if not idData then
		local default = {}
		if args["ustawienia"] then
			default = mw.loadData( 'Module:' .. args["ustawienia"] )
		end
		
		local name = args.name or default.name
		local ids = mw.loadData( 'Module:' .. ( args.ids or default.ids or name .. 'Sprite/IDs' ) )
		ids = ids.ids or ids
		local id = mw.text.trim( tostring( args[1] or '' ) )
		idData = ids[id] or ids[mw.ustring.lower( id ):gsub( '[%s%+]', '-' )]
	end
	
	local title = mw.title.getCurrentTitle()
	-- Remove categories on language pages, talk pages, and in User/UserWiki/UserProfile namespaces
	local disallowCats = title.isTalkPage or title.nsText:find( '^User' )
	if idData then
		if type( idData ) == 'table' then
			if idData.deprecated and not disallowCats then
				table.insert( categories, f:expandTemplate{ title = 'Translation category', args = { 'Pages using deprecated sprite names', project = 0 } } )
			end
			
			args.pos = idData.pos
		else
			args.pos = idData
		end
	elseif not disallowCats then
		table.insert( categories, f:expandTemplate{ title = 'Translation category', args = { 'Pages with missing sprites', project = 0 } } )
	end
	
	return p.base( args ), table.concat( categories, '' )
end

function p.link( f )
	local args = f
	if f == mw.getCurrentFrame() then
		args = require( 'Module:ProcessArgs' ).merge( true )
	end
	
	local link = args[1]
	if args[1] and not args.id then
		link = args[1]:match( '^(.-)%+' ) or args[1]
	end
	local text = args.text or args[2] or link
	
	args[1] = args.id or args[1]
	args.link = args.link or link
	args.text = text
	
	return p.sprite( args )
end

function p.doc( f )
	local args = f
	if f == mw.getCurrentFrame() then
		args = f.args
	else
		f = mw.getCurrentFrame()
	end
	local settingsPage = mw.text.trim( args[1] )
	local settings = mw.loadData( 'Module:' .. settingsPage )
	local idsPage = 'Module:InvSprite/IDs'
	
	local getProtection = function( title, action, extra )
		local protections = { 'edit' }
		if extra then
			table.insert( protections, extra )
		end
		
		local addProtection = function( protection )
			if protection == 'autoconfirmed' then
				protection = 'editsemiprotected'
			elseif protection == 'sysop' then
				protection = 'editprotected'
			end
			
			table.insert( protections, protection )
		end
		
		local direct = title.protectionLevels[action]
		for _, protection in ipairs( direct ) do
			addProtection( protection )
		end
		if title.cascadingProtection then
			local cascading = title.cascadingProtection.restrictions[action] or {}
			if #cascading > 0 then
				table.insert( protections, 'protect' )
			end
			for _, protection in ipairs( cascading ) do
				addProtection( protection )
			end
		elseif f:callParserFunction( 'CASCADINGSOURCES', title.prefixedText ) ~= '' then
			-- Just adding the requirement for the protect right should be good enough until MW 1.25
			table.insert( protections, 'protect' )
		end
		
		return table.concat( protections, ',' )
	end
	
	local body
	if args.refresh then
		body = mw.html.create( '' )
	else
		local idsTitle = mw.title.new( idsPage )
		local spritesheet = settings.image or settings.name .. 'Sprite.png'
		local spriteTitle = mw.title.new( 'File:' .. spritesheet )
		local idsProtection = getProtection( idsTitle, 'edit' )
		local spriteProtection = getProtection( spriteTitle, 'upload', 'upload,reupload' )
		local dataProtection = getProtection( mw.title.new( 'Module:' .. settingsPage ), 'edit' )
		body = mw.html.create( 'div' ):attr( {
			id = 'spritedoc',
			['data-idspage'] = idsPage,
			['data-idsprotection'] = idsProtection,
			['data-dataprotection'] = dataProtection,
			['data-idstimestamp'] = f:callParserFunction( 'REVISIONTIMESTAMP', idsPage ),
			['data-spritesheet'] = spritesheet,
			['data-spriteprotection'] = spriteProtection,
			['data-datapage'] = 'Module:' .. settingsPage,
			['data-pos'] = settings.pos or 1,
			['data-refreshtext'] = mw.text.nowiki( '{{#invoke:sprite|doc|' .. settingsPage .. '|refresh=1}}' ),
			['data-settings'] = mw.text.jsonEncode( settings )
		} )
	end
	
	local data = mw.loadData( idsPage )
	
	local sections = {}
	for _, sectionData in ipairs( data.sections or { 'Uncategorized' } ) do
		local sectionTag = body:tag( 'div' ):addClass( 'spritedoc-section' ):attr( 'data-section-id', sectionData.id )
		-- https://phabricator.wikimedia.org/T73594
		sectionTag:wikitext( '<h3>', sectionData.name, '</h3>' )
		sections[sectionData.id] = { boxes = sectionTag:tag( 'ul' ):addClass( 'spritedoc-boxes' ) }
	end
	
	local keyedData = {}
	for name, idData in pairs( data.ids ) do
		table.insert( keyedData, {
			sortKey = mw.ustring.lower( name ),
			name = name,
			data = idData
		} )
	end
	table.sort( keyedData, function( a, b )
		return a.sortKey < b.sortKey
	end )
	
	for _, data in ipairs( keyedData ) do
		local idData = data.data
		local pos = idData.pos
		local section = sections[idData.section]
		local names = section[pos]
		if not names then
			local box = section.boxes:tag( 'li' ):addClass( 'spritedoc-box' ):attr( 'data-pos', pos )
			box:tag( 'div' ):addClass( 'spritedoc-image' )
				:wikitext( p.base{ pos = pos, ustawienia = settingsPage } )
			
			names = box:tag( 'ul' ):addClass( 'spritedoc-names' )
			section[pos] = names
		end
		local nameElem = mw.html.create( 'li' ):addClass( 'spritedoc-name' )
		local codeElem = nameElem:tag( 'code' ):wikitext( data.name )
		
		if idData.deprecated then
			codeElem:addClass( 'spritedoc-deprecated' )
		end
		names:wikitext( tostring( nameElem ) )
	end
	
	if args.refresh then
		return '', tostring( body )
	end
	return [[<style>
#spritedoc {
	clear: both;
}

.spritedoc-section {
	margin-top: 0.3em;
}
.spritedoc-section > h3 {
	padding-top: 0;
	margin-top: 0;
}

#spritedoc .spritedoc-boxes {
    display: flex;
    flex-wrap: wrap;
    padding: 0 0 1px 1px;
    margin: 0.5em 0;
}
.spritedoc-box {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0.5em;
    background: var(--theme-page-background-color--secondary);
    border: 1px solid var(--theme-border-color);
    margin: 0 0 -1px -1px;
}

.spritedoc-image {
	/* Non-flex fallback */
	display: inline-block;
	/* Non-flex fallback */
	vertical-align: middle;
	margin-right: 0.5em;
	line-height: 0;
}

#spritedoc .spritedoc-names {
	/* Non-flex fallback */
	display: inline-block;
	/* Non-flex fallback */
	vertical-align: middle;
	width: 14em;
	margin: 0;
	/* Non-flex fallback */
	list-style: none;
}
.spritedoc-name {
	line-height: 1.2;
	margin-bottom: 0.3em;
}
.spritedoc-name:last-child {
	margin: 0;
}
.spritedoc-name > code {
	display: inline-block;
	border: 0;
	border-radius: 0;
	padding: 0;
	word-wrap: break-word;
	/* Necessary to make word-wrap work */
	max-width: 14em;
}
.spritedoc-name > .spritedoc-deprecated {
    background-color: rgb(255 210 33 / 30%);
}
</style>]], tostring( body )
end
return p