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

Should the result for textDocument/hover be markdown or plaintext? #836

Open
rwols opened this issue Aug 1, 2020 · 2 comments
Open

Should the result for textDocument/hover be markdown or plaintext? #836

rwols opened this issue Aug 1, 2020 · 2 comments

Comments

@rwols
Copy link
Contributor

rwols commented Aug 1, 2020

There are a few python docstyles out in the wild. See: https://stackoverflow.com/a/24385103. Most notably, none of these are markdown.

The return type from pyls for a textDocument/hover request is a MarkedString[]. Usually this returns a list of 2 marked strings. The first MarkedString has the form {"language": "python", "value": "some content"}. The second MarkedString is a string.

The LSP spec states that clients should interpret MarkedString strings as markdown. This results in the docblocks being rendered odd for different requests. Here are some examples:

textDocument/hover rendering markdown: (never mind the added text, it's incorrect)
https://cdn.discordapp.com/attachments/645268178397560865/738774901837660210/Snipaste_2020-07-31_23-05-05.png

textDocument/signatureHelp rendering plaintext: (this is correct rendering)
https://cdn.discordapp.com/attachments/645268178397560865/738774912193265785/Snipaste_2020-07-31_23-03-44.png

textDocument/complete rendering plaintext: (this is correct rendering)
https://cdn.discordapp.com/attachments/645268178397560865/738774915062169621/Snipaste_2020-07-31_23-06-57.png

The solution is to update textDocument/hover by making it return plaintext instead of markdown. Since Python has diverse doc-styles it's somewhat hard to translate docs to markdown, so let's just do plaintext for now.

@ccordoba12
Copy link
Contributor

Agreed. Please submit a pull request for that. Thanks!

@krassowski
Copy link

FYI: https://github.com/krassowski/docstring-to-markdown (now used on my fork and by jedi-language-server).

fischerling added a commit to fischerling/vis-lspc that referenced this issue Feb 20, 2022
python-language-server sends a list of MarkedStrings containing
the signature as python code-block and the doc string as string.
palantir/python-language-server#836
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants