Skip to content

Commit 445e7e6

Browse files
committed
docs(packages[badges]): Size variants demo and CSS class reference
why: Document the new xs/sm/lg/xl size API alongside existing badge demos. what: - sab_demo.py: size variants row (xs through xl side-by-side) - sphinx-autodoc-badges.md: badge_size param, sab-xs–sab-xl in CSS table, note that explicit sizes override context selectors
1 parent 904b633 commit 445e7e6

2 files changed

Lines changed: 31 additions & 7 deletions

File tree

docs/_ext/sab_demo.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ def _row(*badge_nodes: nodes.Node, label: str = "") -> nodes.paragraph:
3737
p += nodes.literal(text=label)
3838
return p
3939

40+
result.append(_section("Size variants (xs / sm / default / lg / xl)"))
41+
result.append(
42+
_row(
43+
build_badge("xs", size="xs", tooltip="Extra small"),
44+
build_badge("sm", size="sm", tooltip="Small"),
45+
build_badge("md", tooltip="Default (no size class)"),
46+
build_badge("lg", size="lg", tooltip="Large"),
47+
build_badge("xl", size="xl", tooltip="Extra large"),
48+
label='build_badge("lg", size="lg")',
49+
)
50+
)
51+
4052
result.append(_section("Filled (default)"))
4153
result.append(
4254
_row(
@@ -102,9 +114,7 @@ def _row(*badge_nodes: nodes.Node, label: str = "") -> nodes.paragraph:
102114
build_badge("gamma", tooltip="Third"),
103115
]
104116
)
105-
result.append(
106-
_row(group, label="build_badge_group([...badges...])")
107-
)
117+
result.append(_row(group, label="build_badge_group([...badges...])"))
108118

109119
result.append(_section("Toolbar (push-right in flex heading)"))
110120
tb = build_toolbar(
@@ -125,9 +135,7 @@ def _row(*badge_nodes: nodes.Node, label: str = "") -> nodes.paragraph:
125135
heading_p += tb
126136
heading_container += heading_p
127137
result.append(heading_container)
128-
result.append(
129-
_row(label="build_toolbar(build_badge_group([...]))")
130-
)
138+
result.append(_row(label="build_toolbar(build_badge_group([...]))"))
131139

132140
return result
133141

docs/packages/sphinx-autodoc-badges.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ Every variant rendered by the real `build_badge` / `build_badge_group` /
7676
* - ``badge_style``
7777
- ``"full"``
7878
- Structural variant: ``"full"``, ``"icon-only"``, ``"inline-icon"``.
79+
* - ``badge_size``
80+
- ``""``
81+
- Optional size: ``"xs"``, ``"sm"``, ``"lg"``, or ``"xl"``. Empty means default.
7982
* - ``tabindex``
8083
- ``"0"``
8184
- ``"0"`` for keyboard-focusable, ``""`` to skip.
@@ -182,12 +185,25 @@ All classes use the `sab-` prefix (**s**phinx **a**utodoc **b**adges).
182185
* - `sab-toolbar`
183186
- `build_toolbar()`
184187
- Flex push-right (`margin-left: auto`) for title rows.
188+
* - `sab-xs`
189+
- `build_badge(size="xs")` / `BadgeNode(..., badge_size="xs")`
190+
- Extra small (dense tables, tight UI).
191+
* - `sab-sm`
192+
- `build_badge(size="sm")`
193+
- Small inline badges.
194+
* - `sab-lg`
195+
- `build_badge(size="lg")`
196+
- Large (section titles, callouts).
197+
* - `sab-xl`
198+
- `build_badge(size="xl")`
199+
- Extra large (hero / landing emphasis).
185200
```
186201

187202
## Context-aware sizing
188203

189204
Badge size adapts automatically based on where it appears in the document.
190-
No extra classes needed — CSS selectors handle it.
205+
CSS selectors handle it. Explicit size classes (`sab-xs``sab-xl`) override
206+
contextual sizing when present (higher specificity than context rules).
191207

192208
```{list-table}
193209
:header-rows: 1

0 commit comments

Comments
 (0)