Module:DisplayLuaTableContents

From Wikipedia

Documentation for this module may be created at Module:DisplayLuaTableContents/doc

local p={}

function p.test( frame )
    local a = require( 'Module:Citation/CS1/Configuration' );
    return 'Loaded\n\n';
end

function p.test2( frame )
    local b = _G.data;
    
    b.message_list['edition'] = 'Foobar';
    return b.message_list['edition']
end

function p.test3( frame )
    local b = _G.data;
    
    return b.message_list['edition']
end

function p.test4( frame )
    require( 'Module:DisplayLuaTableContents/Test' );
    
    return 'Cloned'
end

function p.test5( frame )
    return _G.test.increment();
end

function p.main(frame)
   local args=frame.args
   local pargs=frame.getParent(frame)
   local dispvar="_G"
   if pargs then dispvar=pargs.dispvar or pargs[1] or dispvar end
   if args then dispvar=args.dispvar or args[1] or dispvar end
   --local base=_G[dispvar]
   local base = _G.test.increment();
   local novar, containssomething
   if base then else base={};novar=yes end
   local output="''Contents of the array '''''" .. tostring(dispvar) .. "''':"
   if novar then output = output .. "<u>nil</u>." end
   local ns=0
   local count=0
   for i,j in pairs(base) do
      containssomething="yes"
      output=output .. "<br />mw." .. tostring (i) .. ":" .. tostring(j)
      if tostring(j)~= "table" then j={} end
   for a,b in pairs(j) do
      output=output .. "<br />mw." .. tostring(i) .. "." .. tostring(a) .. ":" .. tostring(b)
      if tostring(b)~="table" then b={} end
   for x,y in pairs(b) do
      output=output .. "<br />mw." .. tostring(i) .. "." .. tostring(a) .. "." .. tostring(x) .. ":" .. tostring(y)
      if tostring(y)~="table" then y={} end
      for w,z in pairs(y) do
          output=output ..  "<br />-->" .. tostring(w) .. ":" .. tostring(z)
             if tostring(z)~="table" then z={} end
             for u,v in pairs(z) do
                output=output .. "<br />----->" .. tostring(u) .. ":" .. tostring(v)
             end
      end
   end
   end
   end
   --local getc=mw.title.getcontent
   --output=output .. "<br />P.S.: mw.title.getcontent is:" .. tostring(getc)
   --if tostring(getc) == "function" then output = output .. "<br />" .. tostring (getc(mw.title)) end
   if containssomething then else output = output .. "<br />''No pairs(" .. tostring(dispvar) .. ") found!''" end
   return output
 
end
 
return p