-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Show docs in the IDE #4648
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
Show docs in the IDE #4648
Conversation
val symbol = Interactive.enclosingSourceSymbol(trees, pos) | ||
val docComment = ctx.docCtx.flatMap(_.docstring(symbol)) | ||
val markedString = docMarkedString(docComment, tpw.show.toString) | ||
new Hover(List(JEither.forRight(markedString)).asJava, null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if you return two marked strings? One for the docstring and one for the info. The textDocument/hover
response can return MarkedString[]
arrays https://microsoft.github.io/language-server-protocol/specification#textDocument_hover
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion! I've changed it to return 2 different MarkedString
s (one with the doc, the other with the type info). Unfortunately, this doesn't improve much the layout on VSCode: it simply adds an horizontal delimiter between the two hovers, but you still need to scroll.
I've inverted the order of the two MarkedString
.
524a1e9
to
27e85b2
Compare
Yes, open a typescript file in vscode and see what happens when you hover over something, we should match this. The signature is above the documentation, the two are separate by a thin horizontal line, the documentation is shown as rendered markdown. |
Otherwise, we only see the docs at first glance when the docstring is long, and we need to scroll to get to the type info (which is generally a single line).
27e85b2
to
550be22
Compare
Just rebased. Do we agree that the formatting of the comments can be improved in a separate PR? |
val tpw = tp.widenTermRefExpr | ||
|
||
if (tpw == NoType) new Hover | ||
else { | ||
import dotty.tools.dotc.core.Comments._ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put the import at the top of the file.
Builds on top of #4461.
Rendering could certainly be improved, especially for very long docstrings where one needs to scroll to the type info. Maybe the type info should be displayed above the docstring?
I don't know what's the best way to display it would be, but I'm very open to suggestions.