Latest Results
[ty] Render Markdown for reStructuredText fields in docstrings on hover (#25903)
<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:
- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
requests.)
- Does this pull request include references to any relevant issues?
- Does this PR follow our AI policy
(https://github.com/astral-sh/.github/blob/main/AI_POLICY.md)?
-->
## Summary
<!-- What's the purpose of the change? What does it do, and why? -->
This introduces Markdown rendering for reStructuredText (reST) field
lists in docstrings. Here's what it looks like in two different editors:
| | Before | After |
| :--- | :--- | :--- |
| **VS Code** | <img width="1308" height="586" alt="CleanShot 2026-06-17
at 00 02 54@2x"
src="https://github.com/user-attachments/assets/0ba19662-8f34-4dc3-8955-f0d241ad53eb"
/> | <img width="1502" height="558" alt="CleanShot 2026-06-17 at 23 44
19@2x"
src="https://github.com/user-attachments/assets/1b8254af-b6ff-417f-9b66-0bc49ccbf4bb"
/> |
| **Zed** | <img width="1432" height="864" alt="CleanShot 2026-06-17 at
00 02 19@2x"
src="https://github.com/user-attachments/assets/20d409ca-5f03-4a7f-ba20-bf80b370147b"
/> | <img width="1550" height="834" alt="CleanShot 2026-06-17 at 23 45
47@2x"
src="https://github.com/user-attachments/assets/048e3339-c424-41c7-9506-f23a24d1f571"
/> |
The implementation includes the following judgement calls that I think
are acceptable, but that we may want to revisit based on user feedback:
- Our policy for handling malformed, unsupported, or ambiguous fields is
to leave a section raw (i.e. source content, not Markdown) if even a
single field in a field list cannot be confidently rendered (though
other well-formed sections in the same docstring are still rendered as
Markdown). I hope this policy is easy to explain, to identify and
correct in practice, and to maintain.
- We only render Markdown headings for a fixed subset of reST fields
that are commonly used in docstrings. That list can be expanded in the
future.
- Types are rendered with inline code spans, and so do not receive
syntax highlighting. This makes the resulting rendered docstring more
compact vertically at the cost of additional visual cues.
- Physical line breaks in field descriptions are preserved as Markdown
hard breaks rather than being reflowed. This leads to some awkward line
breaks in the rendered docstring, but it saves a lot of complexity in
trying to identify which line breaks are actually collapsible.
**I expect that it will be marginally easier to review this diff
commit-by-commit rather than wholesale.**
Closes https://github.com/astral-sh/ty/issues/3454.
## Test Plan
Please see included tests.
<!-- How was it tested? --> Latest Branches
0%
lerebear/push-ypywzttpymvv 0%
lerebear/push-xkmxkuvqssxr 0%
lerebear/push-mzutpnrrzrww © 2026 CodSpeed Technology