モジュール:サンドボックス/Frozen-mikan/Sandbox

モジュールの解説[作成]
local p = {}

p.main = function (frame)
	local id = frame.args[1] or nil
	local entity = mw.wikibase.getEntity( id )
	if entity then
		local result = table.concat(printTable(entity))
		mw.log(result)
		mw.log('[[' .. entity:getSitelink() .. '|' .. entity:getLabel() .. ']]')
		mw.log(table.concat(entity:getProperties(), ', '))
		return result
	end
end

function printTable(t, msg, indent)
	local t = t or {}
	local msg = msg or {}
	local indent = indent or ''
	for k, v in pairs( t ) do
		table.insert(msg, indent .. k .. ' = ' .. tostring(v) .. '\n')
		if type(v) == 'table' then
			printTable(v, msg, indent .. '*')
		end
	end
	return msg
end

return p