Skip to content

Commit cdd9cd6

Browse files
committed
sphinx-autodoc-fastmcp(fix[badges]): suppress dotted underline on safety/tool badges
why: The live-demo badges on <https://gp-sphinx.git-pull.com/packages/sphinx-autodoc-fastmcp/#live-demos> (and the Gallery page) carried a dotted underline under the label text that was visually noisy and read as a link affordance. The decoration is a deliberate default of the `sab-dense` badge variant in `sphinx-ux-badges`, where `.sab-badge.sab-dense .sab-badge-label` sets `text-decoration: underline dotted` — explicitly designed to be overridable via the shipped modifier classes (`sab-no-underline`, `sab-underline`, `sab-underline-solid`, `sab-underline-dotted`) which the `SAB` enum already exposes at `sphinx-ux-badges/_css.py:87-91`. Using the designed escape hatch lets us keep every other visual property of the dense variant (compact metrics, 1 px bordered pill, tooltip, icon) while dropping only the text decoration, and keeps the change local to fastmcp — pytest-fixtures and api-style don't even use `sab-dense`, so they're unaffected. what: - Compose `SAB.NO_UNDERLINE` alongside `SAB.DENSE` in the four badge-builder call sites in `sphinx-autodoc-fastmcp/_badges.py`: - `build_safety_badge` — `[SAB.DENSE, SAB.NO_UNDERLINE, …]` - `build_type_tool_badge` — `[SAB.DENSE, SAB.NO_UNDERLINE, …]` - `build_tool_badge_group` (safety spec) — `(SAB.DENSE, SAB.NO_UNDERLINE, …)` - `build_tool_badge_group` (type spec) — `(SAB.DENSE, SAB.NO_UNDERLINE, …)` - Update `test_fastmcp_tool_prototype_snapshot` (the one snapshot covering the assembled tool-card doctree) to reflect the new class list — existing `in` assertions in `test_fastmcp.py` still pass since they don't check class-set equality - No changes to `sphinx-ux-badges`, no new CSS, no new API — the override mechanism (`classes` on `build_badge`/`BadgeSpec` + the `SAB.NO_UNDERLINE` constant) was already public surface Verified via `just build-docs`: rendered fastmcp badges now carry `sab-badge sab-dense sab-no-underline …`; pytest-fixtures and api-style badges remain untouched.
1 parent 837532c commit cdd9cd6

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

packages/sphinx-autodoc-fastmcp/src/sphinx_autodoc_fastmcp/_badges.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ def build_safety_badge(
6262
style: t.Literal["full", "icon-only", "inline-icon"] = (
6363
"icon-only" if icon_only else "full"
6464
)
65-
classes = [SAB.DENSE, _CSS.BADGE_SAFETY, _CSS.safety_class(safety)]
65+
classes = [
66+
SAB.DENSE,
67+
SAB.NO_UNDERLINE,
68+
_CSS.BADGE_SAFETY,
69+
_CSS.safety_class(safety),
70+
]
6671
return build_badge(
6772
text,
6873
tooltip=_SAFETY_TOOLTIPS.get(safety, f"Safety: {safety}"),
@@ -84,7 +89,7 @@ def build_type_tool_badge() -> BadgeNode:
8489
return build_badge(
8590
"tool",
8691
tooltip=_TYPE_TOOLTIP,
87-
classes=[SAB.DENSE, SAB.BADGE_TYPE, _CSS.TYPE_TOOL],
92+
classes=[SAB.DENSE, SAB.NO_UNDERLINE, SAB.BADGE_TYPE, _CSS.TYPE_TOOL],
8893
)
8994

9095

@@ -112,12 +117,17 @@ def build_tool_badge_group(safety: str) -> nodes.inline:
112117
safety if safety in _SAFETY_LABELS else safety,
113118
tooltip=_SAFETY_TOOLTIPS.get(safety, f"Safety: {safety}"),
114119
icon=_SAFETY_ICONS.get(safety, ""),
115-
classes=(SAB.DENSE, _CSS.BADGE_SAFETY, _CSS.safety_class(safety)),
120+
classes=(
121+
SAB.DENSE,
122+
SAB.NO_UNDERLINE,
123+
_CSS.BADGE_SAFETY,
124+
_CSS.safety_class(safety),
125+
),
116126
),
117127
BadgeSpec(
118128
"tool",
119129
tooltip=_TYPE_TOOLTIP,
120-
classes=(SAB.DENSE, SAB.BADGE_TYPE, _CSS.TYPE_TOOL),
130+
classes=(SAB.DENSE, SAB.NO_UNDERLINE, SAB.BADGE_TYPE, _CSS.TYPE_TOOL),
121131
),
122132
],
123133
)

tests/ext/layout/__snapshots__/test_snapshots.ambr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,10 @@
256256
<api_component classes="api-layout-right sab-toolbar" name="api-layout-right" tag="div">
257257
<api_inline_component classes="api-badge-container" name="api-badge-container" tag="span">
258258
<inline classes="sab-badge-group">
259-
<BadgeNode badge_icon="🔍" badge_tooltip="Read-only — does not modify external state" classes="sab-badge sab-dense smf-badge--safety smf-safety-readonly" tabindex="0">
259+
<BadgeNode badge_icon="🔍" badge_tooltip="Read-only — does not modify external state" classes="sab-badge sab-dense sab-no-underline smf-badge--safety smf-safety-readonly" tabindex="0">
260260
readonly
261261

262-
<BadgeNode badge_tooltip="MCP tool" classes="sab-badge sab-dense sab-badge--type smf-type-tool" tabindex="0">
262+
<BadgeNode badge_tooltip="MCP tool" classes="sab-badge sab-dense sab-no-underline sab-badge--type smf-type-tool" tabindex="0">
263263
tool
264264
<desc_content classes="api-content">
265265
<api_component classes="api-description api-region api-region--narrative" name="api-description" tag="div">

0 commit comments

Comments
 (0)