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

Show docs in the IDE #4648

Merged
merged 5 commits into from Jun 28, 2018
Merged

Show docs in the IDE #4648

merged 5 commits into from Jun 28, 2018

Conversation

Duhemm
Copy link
Contributor

@Duhemm Duhemm commented Jun 12, 2018

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.

2018-06-12 09 50 11

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)
Copy link
Member

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

Copy link
Contributor Author

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 MarkedStrings (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.

@Duhemm Duhemm force-pushed the topic/tasty-doc-ide branch 2 times, most recently from 524a1e9 to 27e85b2 Compare June 12, 2018 13:47
@smarter
Copy link
Member

smarter commented Jun 15, 2018

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?

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).
@Duhemm
Copy link
Contributor Author

Duhemm commented Jun 26, 2018

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._
Copy link
Member

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.

@Duhemm Duhemm merged commit 71f3aca into scala:master Jun 28, 2018
@Duhemm Duhemm deleted the topic/tasty-doc-ide branch June 28, 2018 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants