Vés al contingut

Mòdul:Wikidades/proves/debug

De la Viquipèdia, l'enciclopèdia lliure
-- Helper functions for debugging Wikidata data, do not use them on any article or template
local p = {}

-- Function archived, not use anymore, just in case of futture need.
--
-- the "qualifiers" and "snaks" field have a respective "qualifiers-order" and "snaks-order" field
-- use these as the second parameter and this function instead of the built-in "pairs" function
-- to iterate over all qualifiers and snaks in the intended order.
local function orderedpairs(array, order)
	if not order then return pairs(array) end
	-- return iterator function
	local i = 0
	return function()
		i = i + 1
		if order[i] then
			return order[i], array[order[i]]
		end
	end
end

-- utility for tracking how the module is used
-- see documentation at [[wikt:en:Template:tracking]]
-- see your tracking at Special:WhatLinksHere/Template:track/wikidata/<your label>
function p.track(label)
	--local frame = mw.getCurrentFrame()
	--pcall(frame.expandTemplate, frame, {title = 'track/wikidata/' .. label})
	return
end

return p