Show richer type parameter information
This commit is contained in:
parent
40f29a9bd0
commit
4cef33ae79
12
src/types.jl
12
src/types.jl
|
@ -54,9 +54,10 @@ function about(io::IO, type::Type)
|
|||
print(Base.summary(type))
|
||||
print(io, styled" defined in {about_module:$(parentmodule(type))}, ")
|
||||
hassizeof(type) && print(io, "$(join(humansize(sizeof(type))))")
|
||||
println(io, "\n ", supertypestr(type))
|
||||
print(io, "\n ")
|
||||
supertypeinfo(io, type)
|
||||
(!isstructtype(type) || fieldcount(type) == 0) && return
|
||||
println(io, styled"\nStruct with {bold:$(fieldcount(type))} fields:")
|
||||
println(io, styled"\n\nStruct with {bold:$(fieldcount(type))} fields:")
|
||||
fieldinfo = AnnotatedString[]
|
||||
if type isa DataType
|
||||
sinfo = structinfo(type)
|
||||
|
@ -80,8 +81,11 @@ function about(io::IO, type::Type)
|
|||
end
|
||||
end
|
||||
|
||||
supertypestr(type::Type) =
|
||||
join(string.(supertypes(type)), styled" {julia_comparator:<:} ")
|
||||
function supertypeinfo(io::IO, type::Type)
|
||||
typestr(t) = highlight(sprint(show, Base.unwrap_unionall(t)))
|
||||
join(io, map(typestr, supertypes(type)),
|
||||
styled" {julia_comparator:<:} ")
|
||||
end
|
||||
|
||||
function memorylayout(io::IO, type::DataType)
|
||||
si = structinfo(type)
|
||||
|
|
|
@ -13,8 +13,9 @@ function about(io::IO, value::T) where {T}
|
|||
if indirectbytes > directbytes
|
||||
print(io, styled" referencing {bold:$(join(humansize(indirectbytes)))}")
|
||||
end
|
||||
print(io, styled" ({julia_comparator:<:} ", supertypestr(supertype(T)), ")")
|
||||
println(io)
|
||||
print(io, styled" ({julia_comparator:<:} ")
|
||||
supertypeinfo(io, supertype(T))
|
||||
println(io, ")")
|
||||
memorylayout(io, value)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue