Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live Docs: show package defining a function #2737

Open
fonsp opened this issue Dec 6, 2023 · 5 comments
Open

Live Docs: show package defining a function #2737

fonsp opened this issue Dec 6, 2023 · 5 comments
Labels
backend Concerning the julia server and runtime enhancement New feature or request frontend Concerning the HTML editor good first issue Good for newcomers Live Docs The Live Docs panel on the bottom right of the editor

Comments

@fonsp
Copy link
Owner

fonsp commented Dec 6, 2023

When reading docs, it would be nice to show from which package a function/method originates.

Current:

image
@fonsp fonsp added enhancement New feature or request frontend Concerning the HTML editor backend Concerning the julia server and runtime Live Docs The Live Docs panel on the bottom right of the editor labels Dec 6, 2023
@fonsp
Copy link
Owner Author

fonsp commented Oct 29, 2024

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 sqrt gives two entries for two methods.
  • For each method:
    • In which package is it defined?
    • Can we get the Method object? (And link to the source code?)

@cstjean
Copy link

cstjean commented Oct 30, 2024

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

{4982748C-D3F4-41E7-B180-AF28308EF54D}

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.

@fonsp
Copy link
Owner Author

fonsp commented Oct 31, 2024

Yes amazing! For stacktraces we are have this already implemented: #2813 and we are working on supporting URLs for more methods in https://github.com/JuliaPluto/MethodURL.jl (see JuliaLang/julia#47709)

@fonsp
Copy link
Owner Author

fonsp commented Oct 31, 2024

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.

@fonsp fonsp added the good first issue Good for newcomers label Oct 31, 2024
@cstjean
Copy link

cstjean commented Oct 31, 2024

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,

{D81769B9-40DC-448E-917F-D408D56BF6FA}

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Concerning the julia server and runtime enhancement New feature or request frontend Concerning the HTML editor good first issue Good for newcomers Live Docs The Live Docs panel on the bottom right of the editor
Projects
None yet
Development

No branches or pull requests

2 participants