How to make own type explanation in Workspace?

How to make own type explanation in Workspace for my type like HypothsisTest or GLM.

I see only type name and variable names, but for other types like GLM there are prety text output.

I assume you are talking about docstrings? If so, check out

1 Like

I think it’s rather pretty printing:

1 Like

Hi, I am using this feature, but it leads only for changing in console output.

I try code:

struct ConfidenceInterval

function, ::MIME"text/plain", obj::ConfidenceInterval)
    compact = get(io, :compact, false)
    println(io, "Confidence interval:")
    if compact
       print(io, "Upper: $(obj.upper) , Lower: $(obj.lower)")
       println(io, "Upper: ", obj.upper)
       println(io, "Lower: ", obj.lower)

Docs.getdoc(obj::ConfidenceInterval) = "ConfidenceInterval $(obj.estimate)"

ci = ConfidenceInterval(2,1,3)

And this not help to get result like in green rectangle… only boring red…

You may find this code to be of interest:

1 Like

I don’t know what io context the juno variable browser uses (maybe @pfitzseb can help), but the show function you defined should work if you do print(ci) and look at the repl output

1 Like

Right now you need to overload, obj::ConfidenceInterval), and not the three argument form. This is consistent with what the help for show says:

The default MIME type is MIME"text/plain". There is a fallback definition for text/plain output that calls show with 2 arguments. Therefore, this case should be handled by defining a 2-argument show(io::IO, x::MyType) method.

I think we can safely check for both forms though.


Thx! Its my fault:, obj::ConfidenceInterval) instead of, ::MIME"text/plain", obj::ConfidenceInterval) works perfectly!