Minecraft Wiki
Advertisement
[view | edit | history | purge]DocumentationJump to code ↴

This module implements {{development versions}}.

[view | edit | history | purge]The above documentation is transcluded from Module:Development versions/doc.
local p = {}
p.list = function( f )
	local args = f:getParent().args
	local title = mw.title.getCurrentTitle().rootText
	local version = args[1] or title
	
	f:callParserFunction ( '#dplvar:set', 'parentVersion', version )
	
	local categories = args.categories or 'snapshots, pre-releases'
	local devVersions = {}
	for category in mw.text.gsplit( categories, '%s*,%s*' ) do
		table.insert( devVersions,
			f:callParserFunction( '#dpl', {
				category = version .. ' ' .. category,
				format = ',|%PAGE%',
				ordermethod = 'sortkey',
				debug = '1'
			} )
		)
	end
	devVersions = mw.text.trim( table.concat( devVersions ), '%s|' )
	
	local edition
	if title:find( '^Pocket Edition ' ) then
		edition = 'Pocket Edition '
	else
		edition = ''
	end

	local content = {}
	for v in mw.text.gsplit( devVersions, '|' ) do
		local wikitext = mw.title.new( v ):getContent()
		if not wikitext:match( '<onlyinclude>' ) then
			wikitext = '<onlyinclude>' .. wikitext .. '</onlyinclude>'
		end
		table.insert( content, '<onlyinclude>=' .. v:gsub( '^' .. edition, '' ) .. '=</onlyinclude>' .. wikitext )
	end
	
	content = table.concat( content )
		:gsub( '^.-<onlyinclude>%s*', '\n' )
		:gsub( '%s*</onlyinclude>.-<onlyinclude>%s*', '\n' )
		:gsub( '%s*</onlyinclude>.*$', '\n' )
		:gsub( '\n(=+ *[^\n]+ *=+)', '\n=%1=' )
	
	return f:preprocess( mw.text.trim( content ) )
end
return p
Advertisement