Skip to content

Style deprecation notices in the API reference - #336

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 them.

First, the styling: a CSS rule for 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, and one rule styles both.

Then a third commit gives this repo's deprecations a notice at all. The key argument of DispatchApiClient.__init__ and the SOLAR member of InverterType were both deprecated in v0.11.2 but said so only in passing prose, so neither showed anything in the API reference. Both now have a Deprecated: admonition following the deprecations guide: right after the summary line, no custom title, version in the text. The decorator reaches neither an argument nor an enum member, so a hand-written admonition is the only channel they have.

The --api-key option is deprecated too and is deliberately left alone: __main__ is not part of the API reference, so an admonition there would render nowhere. That deprecation stays where it is actually visible, in the --help text and the notice printed at runtime.

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 review from a team as code owners September 21, 2026 12:53
@llucax
llucax requested review from Marenz and stefan-brus-frequenz and removed request for a team September 21, 2026 12:53
@github-actions github-actions Bot added part:docs Affects the documentation part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) part:dispatcher labels Sep 21, 2026
The `key` argument of `DispatchApiClient.__init__` and the `SOLAR` member
of `InverterType` were both deprecated in v0.11.2, but said so only in
passing prose, so neither showed a deprecation notice in the API reference.

Give both a `Deprecated:` admonition, right after the summary line and
without a custom title, so they render like the ones the griffe extension
generates. The decorator reaches neither an argument nor an enum member, so
a hand-written admonition is the only channel for them.

The `--api-key` option is deprecated too, but `__main__` is not part of the
API reference, so an admonition there would render nowhere. That
deprecation stays where it is visible, in the `--help` text and the notice
printed at runtime.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
@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 9a7c0f4 and rewrote the description.

The PR originally only added the styling, which on its own changed nothing visible here. The new commit gives this repo's deprecations a notice at all: the key argument of DispatchApiClient.__init__ and the SOLAR member of InverterType were deprecated in v0.11.2 but said so only in passing prose, so the API reference showed nothing. Both now have a Deprecated: admonition following the deprecations guide, which is the only channel available for an argument or an enum member.

The --api-key option is deprecated too and I left it alone on purpose: __main__ is not part of the API reference, so an admonition there would render nowhere. It stays in the --help text and the runtime notice, where it is actually visible.

nox is green (78 tests, mypy, flake8/pydoclint, black). Because it touches src/, cmd:skip-release-notes is applied; only docstrings change.

@llucax
llucax enabled auto-merge September 21, 2026 17:09
@llucax llucax self-assigned this Sep 21, 2026
@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 1fc39fb Sep 22, 2026
12 of 13 checks passed
@llucax
llucax deleted the deprecated-admonitions branch September 22, 2026 08:50
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:dispatcher part:docs Affects the documentation 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