-
Notifications
You must be signed in to change notification settings - Fork 133
Consider not converting spaces to entities in kind=markdown #422
Comments
This might actually get a bit more dicey than it seems, unfortunately. I believe there are a couple cases where we have to "cheat" with using HTML-style whitespace (spaces/line breaks) in order to work around issues we have with tooltips in VS Code. For example, in some random cases, triple-quoted code strings (which we use for the first line to give the function signature before the docs) won't end and will cause intermittent issues like #328. In other cases, I believe using HTML allows us to position documentation as it is written in docstrings, whereas markdown is of course a language which does not care about whitespace. That being said, there are definitely a few cases I've seen where we do goofy things like encode some HTML bits twice, which might be part of the problem you're seeing. It'd certainly be great to make things consistent and revisit the behavior to see if anything we have is no longer needed. I noticed in that post that you've set the preferred format to |
I understand that you're being constrained to a certain extent by Visual Studio Code. However, we've all seen zillions of markdown files, most of which don't contain this many I would already be very happy if you could make an exception or configuration for only With regard to your last question: Even when I specify |
Oh, I didn't mean that we wouldn't want to change things; I just wanted to write down my thoughts as to why I believe this happens to be the current behavior and some places to look and challenges to consider when writing a fix. Those |
I'm sending Doing this affects some things but not others. I can confirm that I still get markdown documentation as a response to textDocument/hover -- I looked at the raw json coming back from the LS. |
Unfortunately, a lot of Python documentation in files is formatted with space/tab indentation - such as samples. If whitespace is not converted to |
Is that actually an issue if the language server is configured to output plaintext? The documentation in files is by definition plaintext, because it's the source code. I think it'd be better to not do any sort of modification to docstrings when in plaintext mode. Formatting for showing in markdown is likely a different story. |
Plaintext means no colors in VS Code. Since extension with Jedi traditionally provided colored code (as do other extensions), we should be doing the same. |
@MikhailArkhipov The point was that even when the LS is instructed via its API to return plaintext, it still returns markdown and Also, I don't understand your reasoning with regards to TABs and Furthermore, from a software engineering standpoint, this really goes against separation of concerns. Ideally the MS LS should generate fully compliant, textbook markdown, whilst vs.code and other clients simply should simply render that compliant, textbook markdown. Although markdown strictly speaking might allow for As I mentioned earlier: Fundamentally, most (all?) markdown renderers render All of that being said: I don't really care how you decide to deviate from what everybody else is doing, as long as you stay consistent in how you do it so I don't have to keep on updating my patches to Emacs. ;P |
LS sends |
VS Code always requests markdown, never plaintext, so I don't think fixing plaintext output to actually be plaintext will affect VS Code (not that plaintext can't contain I'm a bit confused what triple backtick <body>
<p>Hello world!
</body> Is:
That doesn't mean that HTML is rendered, but that it's highlighted as HTML. When I was looking into #328, I didn't see us outputting triple backtick If we want that bottom docstring to be spaced as plaintext with the original characters, I'd think that a plain triple backtick block would work, or explicitly stating |
HTML is to keep documentation text preformatted/indented with significant whitespace. |
All backtick blocks should be able to do that, like:
Which is:
|
With #596, the docstring handling has been completely rewritten for the new language server. There is no longer any manual spacing of elements, instead converting from the docstring to something markdown will be able to format. I don't think we'll be inserting any more HTML-specific whitespace (unless it can't be avoided, which I can't see happening). If plaintext is specified, all docstrings returned will come through unmodified, other than removing consistent indents. I'll file another bug for handling LSP capability-based MarkupKind support, but that's a further improvement. |
In getting the Microsoft PyLS working with Emacs, see https://vxlabs.com/2018/11/19/configuring-emacs-lsp-mode-and-microsofts-visual-studio-code-python-language-server/ -- I had to hack around the fact that PyLS converts all spaces in the Python source docstrings to
elements.As far as I can tell, this is strictly speaking valid Markdown, although it's making life difficult for non-HTML based MarkDown renderers, like those in VIM and Emacs.
Would you consider disabling this function, or at least making it configurable?
In short, I would like contents with kind=markdown to use simple spaces instead of
entities.The text was updated successfully, but these errors were encountered: