Object and type viewer for Julia
Eyeball exports one main tool to browse Julia objects and types.
eye(object)
eye(object, depth)
eye(object = Main, depth = 10; interactive = true, all = false)
depth
controls the depth of folding. all
expands options.
The user can interactively browse the object tree using the following keys:
↑
↓
←
→
-- Up and down moves through the tree. Left collapses a tree. Right expands a folded tree. Vim movement keys (h
j
k
l
) are also supported.d
-- Docs. Show documentation on the object.e
-- Expand. Show more subobjects. The number of objects is doubled each time.f
-- Toggle fields. By default, parameters are shown for most objects.
f
toggles between the normal view and a view showing the fields of an object.m
-- Methodswith. Show methods available for objects of this type. M
specifies supertypes = true
.o
-- Open. Open the object in a new tree view. O
opens all (mainly useful for modules).r
-- Return tree (a FoldingTrees.Node
). s
-- Show object.S
-- Sort. Open the sorted object in a new view.t
-- Typeof. Show the type of the object in a new tree view.z
-- Summarize. Toggle a summary of the object and child objects.
For arrays, this shows the mean and 0, 25, 50, 75, and 100% quantiles (skipping missings)..
-- Sizes. Toggle display of sizes between none, Base.summarysize
(includes subobjects), and sizeof
.0
-9
-- Fold to depth. Also toggles expansion of items normally left folded.enter
-- Return the selected object.q
-- Quit.Notes:
e
to expand.o
to open these in a new tree view.O
and all = true
adds a wrapper Eyeball.All
around the object.
This is mainly for use with modules where options are taken with name(module, all = true)
.z
shows a summary of child objects. That's useful for DataFrames, nested arrays, and similar types.a = (h=rand(5), e=:(5sin(pi*t)), f=sin, c=33im, set=Set((:a, 9, rand(1:5, 8))), b=(c=1,d=9,e=(i=9,f=0)), x=9 => 99:109, d=Dict(1=>2, 3=>4), ds=Dict(:s=>4,:t=>7), dm=Dict(1=>9, "x"=>8))
eye(a)
julia> eye(a)
[f] fields [d] docs [e] expand [m/M] methodswith [o] open [r] tree [s] show [t] typeof [z] summarize [q] quit
> : NamedTuple{(:h, :e, :f, :c, :set, :b, :x, :d, :ds, :dm), Tuple{Vector{Float64}, Expr, typeof(sin), Complex{Int64} + h: Vector{Float64} (5,) 40 [0.589398, 0.761107, 0.963494, 0.835393, 0.488657]
e: Expr :(5 * sin(pi * t))
head: Symbol :call
args: Vector{Any} (3,) 24 Any[:*, 5, :(sin(pi * t))]
1: Symbol :*
2: Int64 5
3: Expr :(sin(pi * t))
head: Symbol :call
args: Vector{Any} (2,) 16 Any[:sin, :(pi * t)]
1: Symbol :sin
2: Expr :(pi * t)
head: Symbol :call
args: Vector{Any} (3,) 24 Any[:*, :pi, :t]
1: Symbol :*
2: Symbol :pi
3: Symbol :t
f: typeof(sin) sin
+ c: Complex{Int64} 0+33im
set: Set{Any} Set(Any[:a, 9, [2, 3, 2, 5, 5, 1, 4, 5]])
: Symbol :a
: Int64 9
+ : Vector{Int64} (8,) 64 [2, 3, 2, 5, 5, 1, 4, 5]
b: NamedTuple{(:c, :d, :e), Tuple{Int64, Int64, NamedTuple{(:i, :f), Tuple{Int64, Int64}}}} (c = 1, d = 9, e = (i c: Int64 1
d: Int64 9
e: NamedTuple{(:i, :f), Tuple{Int64, Int64}} (i = 9, f = 0)
i: Int64 9
f: Int64 0
+ x: Pair{Int64, UnitRange{Int64}} 9=>99:109
d: Dict{Int64, Int64} Dict(3=>4, 1=>2)
3: Int64 4
1: Int64 2
ds: Dict{Symbol, Int64} Dict(:s=>4, :t=>7)
s: Int64 4
v t: Int64 7
eye() # equivalent to `eye(Main)`
eye(Number)
With the keyword argument interactive
set to false
, eye
returns the tree as a FoldingTrees.Node
.
That is automatically displayed via show
or by using FoldingTrees.print_tree
.
eye(Number, interactive = false)
Show a summary of arrays in a named tuple (also useful for DataFrames).
d = (a = rand(100), b = rand(100:200, 100), c = 4rand(Float32, 100))
eye(d) # then hit `z` to summarize
By default, eye
shows the properties of an object.
That can be customized for different objects.
For example, Dict
s are shown with the key then the value, and abstract types are shown with subtypes.
To customize what's shown for SomeType
, define Eyeball.getobjects(x::SomeType)
.
This method should return an iterator that returns a key and a value describing each of the child objects to be shown.
The display of objects can also be customized with the following boolean methods:
Eyeball.shouldrecurse(x)
Eyeball.foldobject(x)
shouldrecurse
controls whether eye
recurses into object x
.
This defaults to true
.
For overly large or complex objects, it helps to return false
.
That's done internally for Module
s, Method
s, and a few other types.
foldobject
controls whether eye
automatically folds the object.
This is useful for types where the components usually don't need to be shown.
This defaults to false
.
To add additional "summarize" options, define Base.show(io::IO, x::Eyeball.Summarize{T})
for type T
.
Eyeball
uses FoldingTrees for display of trees and interactivity.
This fork
was extended to support customized key presses.
TerminalPager is used for paging.
The code was adapted from InteractiveErrors.jl and Cthulhu.jl.