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

A way to request documentation from LSP server #291

Closed
bstaletic opened this issue Sep 2, 2017 · 6 comments
Closed

A way to request documentation from LSP server #291

bstaletic opened this issue Sep 2, 2017 · 6 comments

Comments

@bstaletic
Copy link
Contributor

bstaletic commented Sep 2, 2017

Is there a way to send a request that would return doxygen/pydoc/java doc parsed documentatioin?

Libclang (C-family), jedi (python), racer (rust), tern (javascript) and probably others already provide ways to parse comments and return formated documentation (if available). Would be great if LSP supported this as well.

@rcjsuen
Copy link
Contributor

rcjsuen commented Sep 3, 2017

public interface MathOperation {
  /**
   * Returns the result of adding the two integers together.
   * @param x the first value
   * @param y the second value
   * @return the sum of the two integers
   */
  public int add(int x, int y);
}

@bstaletic So you mean if your mouse hovered over the string add, the editor that you are using (a language client that supported the language server protocol) would provide a hover tooltip that contains the parsed Javadoc documentation in a readable format without the @param and @return tags?

@bstaletic
Copy link
Contributor Author

@rcjsuen Thanks for taking the time to respond.

Yes, the tooltip with a parsed javadoc in a readable format is what I'm looking for.

@rcjsuen
Copy link
Contributor

rcjsuen commented Sep 3, 2017

@bstaletic It sounds like the language server just needs to support a textDocument/hover request at that given position then. It would then satisfy the exact requirement that my comment describes.

Or did you have something else in mind?

@bstaletic
Copy link
Contributor Author

So textDocument/hover does support parsing javadoc? That wasn't clear to me. I'm actually helping in developing a LSP client. Thanks for the clarification.

Now I'd like to ask a slightly different question. What's the best way to get just the type of the variable from the server? I initially used hover to request for getting the type. Is there a way to easily get two distinct respinses (type and doc)? Or will I have to parse the response I get from hover response?

@rcjsuen
Copy link
Contributor

rcjsuen commented Sep 3, 2017

So textDocument/hover does support parsing javadoc?

@bstaletic Uh, that's really up to the language server. The language server the client is connected to may or may not parse the comments defined above a function/method/member/whatever. The client just sends a textDocument/hover request to say "tell me what I should write in a hover tooltip at this location" and then the language server may say "this is a function with no parameters and returns a boolean" or it might just return the empty string. It may even tell you the type of the variable. The content of what a language server is "supposed" to return is not spec'd. Thus, language clients can't really "parse" the response as the returned string can be anything.

You could perhaps use textDocument/definition and or textDocument/documentSymbol to figure out what the type of a variable is but your mileage may vary here.

@bstaletic
Copy link
Contributor Author

Okay, thanks again for taking the time to respond and help me

I'll close tge issue now, as there really is no issue here.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 21, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants