Pad standalone type chips, keep compound types flush#54
Merged
Conversation
…rackets why: Field-list type chips — standalone types like str and pathlib.Path and union members — rendered with zero horizontal padding, so each type sat crammed against the edge of its chip background. The padding was zeroed globally to keep compound types tight (list[str], not list[ str ]). what: - Restore Furo's 0.2em inline padding on .field-list code.literal - Cancel it only where a chip abuts .p punctuation (brackets, inner commas, pipes), matching both the bare <code> and the <a>-wrapped link form, so list[str] and dict[str, Any] still render flush
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #54 +/- ##
=======================================
Coverage 92.38% 92.38%
=======================================
Files 256 256
Lines 20188 20188
=======================================
Hits 18651 18651
Misses 1537 1537 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
str,pathlib.Path, union members) rendering with zero horizontal padding — each type sat crammed against the edge of its chip background.0.2eminline padding on.field-list code.literal, whichsphinx-autodoc-typehints-gphad zeroed globally.list[str],dict[str, Any]) by cancelling that padding only where a chip abuts.ppunctuation.Background
typehints_gp.csszeroedpadding-inlineon every field-list code chip so compound annotations stayed flush —list[str], notlist[ str ], since the brackets/commas live in separate<span class="p">elements outside the chip. The side effect: standalone types (a parameter that is juststr, a return ofpathlib.Path) lost their chip breathing room and read as text jammed against the background edge. The earlier api-facts padding fix only covered.gp-sphinx-api-facts, so plain autodoc parameter lists on consumer sites (libtmux, django-docutils, …) kept the cramped look.The fix
Restore the padding by default, then drop it adjacently to punctuation:
Linked chips wrap the
<code>in<a>, so the punctuation is the anchor's sibling — the rule matches both the bare and anchored forms. Browsers without:has()degrade gracefully to padded-everywhere.Before / After
str0.2embreathing roompathlib.Path0.2embreathing roomCallable[Server[…]Verified live:
dict[str, Any] | Nonekeepsdict[str, Any]tight while the| Nonemembers gain padding.Test plan
uv run ruff check ./ruff format/uv run mypy .cleanuv run pytest --reruns 0— full suite greenjust build-docssucceeds; the rule is bundled into_static/css/typehints_gp.csslist[str]/dict[str, Any]stay flush