Module:Protocol version

local p = {}

-- function p.protocol_version( f ) local args = f   if f == mw.getCurrentFrame then args = require( 'Module:ProcessArgs' ).merge( true ) end local version = mw.text.trim( args[1] or '' ) -- load the values from the submodule local version_data = mw.loadData( 'Module:Protocol version/Versions' ).versions[version] local category = '' local value if version_data then value = version_data.protocol else value = '—' local title = mw.title.getCurrentTitle if not args.nocat and title.namespace == 0 and not title.isSubpage then category = '' end end return value .. category end

-- function p.data_version( f ) local args = f   if f == mw.getCurrentFrame then args = require( 'Module:ProcessArgs' ).merge( true ) end local version = mw.text.trim( args[1] or '' ) -- load the values from the submodule local version_data = mw.loadData( 'Module:Protocol version/Versions' ).versions[version] local category = '' local value if version_data then if version_data.data then value = version_data.data else value = "N/A" end else value = '—' local title = mw.title.getCurrentTitle if not args.nocat and title.namespace == 0 and not title.isSubpage then category = '' end end return value .. category end

-- Version table function p.table( f ) local args = f   if f == mw.getCurrentFrame then args = require( 'Module:ProcessArgs' ).merge( true ) end local html = {} local groups = mw.loadData( 'Module:Protocol version/Versions' ).groups

for _, group in ipairs(groups) do   	local include = true if #args ~= 0 then include = nil for __, name in ipairs(args) do   			if name == group.name then include = true break end end end

if include then table.insert( html, "=== ' .. group.name .. " ===\n" ) if group.desc ~= nil then table.insert( html, group.desc .. '\n') end table.insert( html, " \n' )       end    end

return table.concat( html ) end

return p