[ty] Implement support for explicit markdown code fences in docstring rendering#22373
[ty] Implement support for explicit markdown code fences in docstring rendering#22373
Conversation
|
Upgraded this into implementing a solution. |
MichaReiser
left a comment
There was a problem hiding this comment.
I think we should add support for ~~~ too. While less common, it is part of the markdown standard.
crates/ty_ide/src/docstring.rs
Outdated
| } | ||
|
|
||
| // If we're not in a codeblock and we see a markdown codefence, start one | ||
| if !in_any_code && line.starts_with("```") { |
crates/ty_ide/src/docstring.rs
Outdated
| } | ||
|
|
||
| // If we're not in a codeblock and we see a markdown codefence, start one | ||
| if !in_any_code && line.starts_with("```") { |
There was a problem hiding this comment.
Code blocks can also be indented (but that's maybe something for another PR) spec
There was a problem hiding this comment.
I expect that one will remain out of scope because python people love random indents in their docstrings and it's a struggle to disambiguate "are we markdown or just some text".
crates/ty_ide/src/docstring.rs
Outdated
| let ticks = &line[..num_ticks]; | ||
| // If we don't see this amount of ticks again on the line, assume we're opening a markdown block | ||
| // (We *don't* want to consider ```hello``` as a codefence, that's inline code!) | ||
| if !without_leading_ticks.contains(ticks) { |
There was a problem hiding this comment.
Oh, I didn't know that you can use multiple backticks for inline code
There was a problem hiding this comment.
Yeah in both reST and markdown! In python docstrings there's a soft convention of `x` and ``x`` being used for different purposes (similar to `x` and [`x`] in rustdoc).
My approval was when this PR only added a test
|
tilde fences added |
Uh oh!
There was an error while loading. Please reload this page.