Документация
local p = {}
--[[
local function getAllMedals(frame)
	local entity = mw.wikibase.getEntity()
	local valuePref = entity:formatPropertyValues('P884', { mw.wikibase.entity.claimRanks.RANK_PREFERRED } ).value
 
	table.insert(result.items, WikiDataValueToArray(valuePref))
	table.insert(result.items, WikiDataValueToArray(valueNorm))
	table.insert(result.items, WikiDataValueToArray(valueDepr))
 
	return result
end
]]

function p.getCode( frame )
	local valuePref = ''
	local entity = mw.wikibase.getEntity()
	if frame.args[1] and frame.args[1] ~= '' then
		valuePref = frame.args[1]
	else
		valuePref = entity:formatPropertyValues('P884').value
		if not string.match( valuePref, '%d+' ) then
			valuePref = ''
		end
	end
	return valuePref
end

-- Код басейна
function p.getSwimingPoolCode( frame )
	local code = p.getCode( frame )
	return string.sub(code, 1, 2) .. '.' .. string.sub(code, 3, 4) .. '.' .. string.sub(code, 5, 6) .. '.' .. string.sub(code, 7, 9)
end

-- Маркер
function p.getMarker( frame )
	local code = p.getCode( frame )
	return string.sub(code, 10, 11)
end

-- Код по ГИ
function p.getHydrologyCode( frame )
	local code = p.getCode( frame )
	local marker = p.getMarker( frame )
	local HydrologyCode = string.sub(code, 12, 22)
	if marker == '12' or marker == '22'
		then
		HydrologyCode = '1' .. string.sub(HydrologyCode, 2, 11)
	elseif
		marker == '11' or
		marker == '14' or
		marker == '15' or
		marker == '16' or
		marker == '21'
		then
		HydrologyCode = '2' .. string.sub(HydrologyCode, 1, 11)
	else
		HydrologyCode = string.sub(HydrologyCode, 1, 11)
	end
	return string.sub(HydrologyCode, 0, 4)  .. string.sub(HydrologyCode, 7, 11)
end

-- Том ГИ
function p.getHydrologyBook( frame )
	local code = p.getCode( frame )
	local HydrologyBook = string.sub(code, 13, 15)
	local ref = frame:callParserFunction{ name = '#tag:ref', args = { '{{Книга:РесПовВодСССР|' .. string.sub(HydrologyBook, 1, 2) .. '|' .. string.sub(HydrologyBook, 3) .. '}}' } }
	
	if string.sub(HydrologyBook, 3) == '0' then
		return string.sub(HydrologyBook, 1, 2) .. ref
	else
		return string.sub(HydrologyBook, 1, 2) .. ' (выпуск ' .. string.sub(HydrologyBook, 3) .. ')' .. ref
	end
end

function p.getHydrologyBookRef( frame )
	local code = p.getCode( frame )
	local HydrologyBook = string.sub(code, 13, 15)
	return frame:callParserFunction{ name = '#tag:ref', args = { '{{Книга:РесПовВодСССР|' .. string.sub(HydrologyBook, 1, 2) .. '|' .. string.sub(HydrologyBook, 3) .. '}}' } }
end

return p