[Lib] Microscope - Create visuals of Lua values
Posted: Tue Oct 22, 2013 7:52 am
Hi all,
I enjoy digging in the Lua ecosytem, to see trending projects and learn from others code. That's the way I recently came accross a nice project that I wanted to share around here.
Let me introduce you to Microscope.
The project is free, MIT Licensed, and maintained by Philipp Janda.
I'll just quote the main page about waht the project does, it is pure awesomeness.
Will be rendered this way:
How nice is that ?
Links: Hope it helps, anyway.
I enjoy digging in the Lua ecosytem, to see trending projects and learn from others code. That's the way I recently came accross a nice project that I wanted to share around here.
Let me introduce you to Microscope.
The project is free, MIT Licensed, and maintained by Philipp Janda.
I'll just quote the main page about waht the project does, it is pure awesomeness.
As a straigthforward example, shamelessly taken from the same page, the following code:Checking the value of a Lua variable during debugging is often invaluable and print() is a commonly used debugging tool. But what about complex table values? Many Lua programmers have written their own pretty-printer or data dumper and some even use it for (de-)serializing Lua data structures. But this seems to reach its limit when one takes cyclic references, metatables, upvalues and environment tables into account.
This module dumps arbitrarily complex Lua values as GraphViz .dot-files that can be transformed into a variety of image formats.
Code: Select all
local up1 = false
local up2 = io.stdout
local t1 = { val = 1 }
local t2 = { val = 2 }
setmetatable( t1, { __index = function( t, k )
if t2[ k ] ~= nil then
return t2[ k ]
else
return up1 or up2
end
end } )
setmetatable( t2, { __index = t1 } )
How nice is that ?
Links: Hope it helps, anyway.