-- <pre>
local StringBuffer = require( 'Module:StringBuffer' )
return function( namespace )
local methods = mw.loadData( StringBuffer()
:add( 'Module:Data' )
:add( namespace )
:add( 'methods' )
:flush( '/' )
:toString()
)
return setmetatable( {}, {
__index = function( self, key ) -- only if it doesn't contain the key
local subModule = methods[ key ]
if not subModule then
-- Let it explode on the calling code, just like it would
-- if all of the functions were explicitly declared.
return nil
else
rawset( self, key, require( 'Module:Data/' .. subModule ) )
return rawget( self, key )
end
end,
__call = function( self, moduleName )
return require( 'Module:Data/static/' .. moduleName .. '/data' ).main;
end,
} )
end
-- </pre>