Two of rich’s best features, in my opinion, are
inspect which prints out details and methods about a python object and
tracebacks which styles and organize error messages making them much easier to read.
I’m trying to implement these in Term.jl but struggling with find nice ways to introspect Julia code. I’ve looked at:
- Reflection and introspection · The Julia Language
- Documentation · The Julia Language
but still struggle to get a few bits of information.
For instance given:
abstract type AA end abstract type AbstractTest <: AA end """ Test A test `struct` for inspection """ mutable struct Test <: AbstractTest x::Int y::String end Test(x) = Test(x, x)
I’m writing a function
inspect that spits out formatted information about
using things like
to get the docstring I’ve tried
string(@doc my_type) within my
inspect function, but that doesn’t work. If outside my
inspect function I call
@doc Test I can retrieve the docstring correctly, but when passing
Test as an argument to
I’ve seen that
Docs.jl has methods like
metadata, but I can’t find any good docs. Anyone has any idea on how to do this better?
Related, is there any docs on how the tracebacks are created in Julia and if there are methods to access them? In python you can have code that replaces the default tracebacks with ones you like, is there a way to do something similar in Julia?