Skip to content

Style deprecation notices in the API reference - #198

Merged
llucax merged 3 commits into
frequenz-floss:v1.x.xfrom
llucax:deprecated-admonitions
Sep 22, 2026
Merged

llucax merged 3 commits into
frequenz-floss:v1.x.xfrom
llucax:deprecated-admonitions

Conversation

@llucax

@llucax llucax commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Preparation for the client-common 0.4.1 update, so deprecation notices already look right by the time it adds more of them.

Two things: a CSS rule that styles the deprecated admonition class (gravestone icon, its own colour, otherwise like a warning), and the griffe-warnings-deprecated extension wired into the mkdocstrings handler so symbols decorated with typing_extensions.deprecated get an admonition generated for them.

The extension's kind is set to deprecated rather than the default warning, so what it emits is markup-identical to a hand-written Deprecated: admonition. One rule styles both, which matters because the decorator cannot reach module-level aliases, a single function argument, enum members or whole modules.

Then a third commit brings this repo's one deprecation notice in line with the deprecations guide: LessThanComparableOrNoneT announced itself with Warning: Deprecated, which renders as an ordinary warning, and it is now a Deprecated: admonition that states the version (v1.4.0) in the text. The decorator cannot reach a module-level type variable, so that admonition is the only channel it has.

Style the `deprecated` admonition class like a warning, but with the
`material/grave-stone` icon and its own colour, so deprecation notices
read as deprecation notices and not as generic warnings.

That class is what a hand-written `Deprecated:` admonition in
a docstring produces, and also what the griffe extension added next
will emit, so a single rule covers both sources.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Wire the `griffe-warnings-deprecated` extension into the mkdocstrings
handler options, so every symbol decorated with
`typing_extensions.deprecated` gets a "Deprecated" admonition in the
API reference with no docstring edit at all.

The extension's `kind` is set to `deprecated` rather than the default
`warning`, so it emits `class="deprecated"`, which is exactly what
a hand-written `Deprecated:` admonition produces. The CSS rule added
in the previous commit then styles both, and the two are visually
indistinguishable. That matters because the decorator cannot reach
everything: module-level aliases, a single function argument, enum
members and whole modules still need the admonition written by hand.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
@llucax
llucax requested a review from a team as a code owner September 21, 2026 12:39
@llucax
llucax requested review from Marenz and removed request for a team September 21, 2026 12:39
@github-actions github-actions Bot added part:docs Affects the documentation part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) labels Sep 21, 2026
@llucax
llucax enabled auto-merge September 21, 2026 12:46
@llucax

llucax commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

Example of how it looks.

image

@llucax llucax self-assigned this Sep 21, 2026
@llucax
llucax disabled auto-merge September 21, 2026 12:52
`LessThanComparableOrNoneT` announced its deprecation through a
`Warning: Deprecated` admonition, which renders as an ordinary warning and
so reads like any other caveat.

Write it as a `Deprecated:` admonition instead, so it picks up the
deprecation styling added in this branch, and state the version that
deprecated it in the text, as the deprecations guide requires. The
decorator cannot reach a module-level type variable, so a hand-written
admonition is the only channel there is.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
@github-actions github-actions Bot added the part:math Affects the math module label Sep 21, 2026
@llucax llucax added the cmd:skip-release-notes It is not necessary to update release notes for this PR label Sep 21, 2026
@llucax

llucax commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

Updated: pushed cafa552 and rewrote the description.

The PR originally only added the styling and left existing notices alone. It now also converts this repo's one deprecation notice to match. LessThanComparableOrNoneT used Warning: Deprecated, which renders as an ordinary warning, so it was the one symbol here the new styling deliberately did not reach; it is now a Deprecated: admonition stating v1.4.0 in the text, per the deprecations guide.

Because that touches src/, the cmd:skip-release-notes label is applied; nothing about the API changes.

@llucax
llucax added this pull request to the merge queue Sep 22, 2026
Merged via the queue into frequenz-floss:v1.x.x with commit ca06caf Sep 22, 2026
12 of 13 checks passed
@llucax
llucax deleted the deprecated-admonitions branch September 22, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmd:skip-release-notes It is not necessary to update release notes for this PR part:docs Affects the documentation part:math Affects the math module part:tooling Affects the development tooling (CI, deployment, dependency management, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants