Live Docs: show package defining a function
When reading docs, it would be nice to show from which package a function/method originates.
Current:
I did some experiments here, and the big question in this issue is on the Julia side:
Currently, we use Docs.doc(binding) to get documentation, but this just returns a Markdown.MD, but we are not sure how to get more info, such as:
- For how many methods did you show docs? E.g. docs for
sqrtgives two entries for two methods. - For each method:
- In which package is it defined?
- Can we get the
Methodobject? (And link to the source code?)
Why not evaluate the symbol (in a try/catch), and show its methods(f) if it is a function?
Incidentally, because I have JULIA_EDITOR configured, I can take advantage of
or type edit(some_function). It is super useful for debugging in the REPL, and there's no reason why Pluto couldn't link its stacktraces/methods in the same way. I can figure out the relevant methods if that helps.
Yes amazing! For stacktraces we are have this already implemented: https://github.com/fonsp/Pluto.jl/pull/2813 and we are working on supporting URLs for more methods in https://github.com/JuliaPluto/MethodURL.jl (see https://github.com/JuliaLang/julia/issues/47709)
Evaluating in trycatch and getting methods is a first step, the question is:
Docs.doc gives all docs for a search string as one single Markdown.MD object. And this object often contains docs for multiple methods.
What we want is to get something like:
[
Dict(
:method => "sqrt(::Matrix)",
:method_url => "https://...",
:docs => "<p>..."
),
Dict(
:method => "sqrt(::Real)",
...
)
]
We can give this list to the frontend and show documentation for multiple methods in a nicer way, and include URLs to source code. I.e. the goal is to get more structured information than what Docs.doc currently provides, because that structured data allows the frontend to be more helpful.
For stacktraces we are have this already implemented
Perhaps I'm missing something or I was not clear, but when I look at a StackTrace in Pluto,
There's nowhere I can click to go that that definition, right? Whereas in the REPL, I'd just type 5 and CTRL-q to immediately have my editor (eg. emacs) go to the line of that error.
I know this is already supported for code defined in the same Pluto notebook, but the REPL functionality works for any code.
That REPL code to do that is here: https://github.com/JuliaLang/julia/blob/master/stdlib/REPL/src/REPL.jl#L1638. Being able to click somewhere in Pluto to open up my editor would be fantastic! Could be conditional on JULIA_EDITOR being defined, of course.
You can click on the filename (ends in .jl), but it does not always work because of https://github.com/JuliaLang/julia/issues/47709 (when it does not work you cannot click).