Skip to content

Commit 5f13225

Browse files
committed
docs(_ext[sphinx_pytest_fixtures]): right-align badges, reorder sig elements, restore FIXTURE visibility
why: Badges should be right-aligned in the card header with [source] at the very end. The FIXTURE badge at opacity 0.55 was too dim. The signature elements needed tighter flow with badges pushed right. what: - Reorder sig children in _on_doctree_resolved: detach [source] and headerlink, re-append as ¶ → badges → [source] - Restore margin-left: auto on spf-badge-group for right alignment - Increase FIXTURE badge opacity from 0.55 to 0.82 - Keep align-items: center for vertical middle alignment - Keep gap: 0.35rem for tight signature element spacing
1 parent fb07aed commit 5f13225

2 files changed

Lines changed: 21 additions & 17 deletions

File tree

docs/_ext/sphinx_pytest_fixtures.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,27 +1812,31 @@ def _on_doctree_resolved(
18121812

18131813
badge_group = _build_badge_group_node(scope, kind, autouse)
18141814

1815-
# Insert badges after the headerlink (¶) but before the [source]
1816-
# viewcode link. Desired order:
1817-
# name → return → ¶ → badges → [source]
1818-
# The [source] link is a ``reference`` with a ``viewcode-link``
1819-
# child span. If found, move it to the end after the badge group.
1815+
# Reorder signature children to:
1816+
# name → return → ¶ → badges (right-aligned) → [source]
1817+
# Detach [source] and ¶ links, then re-append in desired order.
18201818
viewcode_ref = None
1819+
headerlink_ref = None
18211820
for child in list(sig_node.children):
1822-
if (
1823-
isinstance(child, nodes.reference)
1824-
and child.get("internal") is not True
1825-
and any(
1821+
if isinstance(child, nodes.reference):
1822+
# [source] link: external reference with viewcode-link child
1823+
if child.get("internal") is not True and any(
18261824
"viewcode-link"
18271825
in getattr(gc, "get", lambda *_: "")("classes", [])
18281826
for gc in child.children
18291827
if isinstance(gc, nodes.inline)
1830-
)
1831-
):
1832-
viewcode_ref = child
1833-
sig_node.remove(child)
1834-
break
1835-
1828+
):
1829+
viewcode_ref = child
1830+
sig_node.remove(child)
1831+
# ¶ headerlink: internal reference with "headerlink" class
1832+
elif "headerlink" in child.get("classes", []):
1833+
headerlink_ref = child
1834+
sig_node.remove(child)
1835+
1836+
# Re-append: ¶ first (inline with signature), then badges
1837+
# (right-aligned via margin-left:auto), then [source] last.
1838+
if headerlink_ref is not None:
1839+
sig_node += headerlink_ref
18361840
sig_node += badge_group
18371841
if viewcode_ref is not None:
18381842
sig_node += viewcode_ref

docs/_static/css/custom.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ dl.py.fixture > dt span.spf-badge-group {
373373
align-items: center;
374374
gap: 0.3rem;
375375
flex-shrink: 0;
376-
margin-left: auto; /* push badges to the right edge */
376+
margin-left: auto;
377377
white-space: nowrap;
378378
user-select: none;
379379
-webkit-user-select: none;
@@ -410,7 +410,7 @@ dl.py.fixture > dt span.spf-badge--fixture {
410410
background-color: var(--spf-fixture-bg);
411411
color: var(--spf-fixture-fg);
412412
border-color: var(--spf-fixture-border);
413-
opacity: 0.55;
413+
opacity: 0.82;
414414
font-size: calc(var(--spf-badge-font-size) * 0.85);
415415
}
416416

0 commit comments

Comments
 (0)