Style deprecation notices in the API reference - #336
Conversation
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>
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>
|
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 The
|
1fc39fb
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
deprecatedadmonition class (gravestone icon, its own colour, otherwise like a warning), and the griffe-warnings-deprecated extension wired into the mkdocstrings handler so symbols decorated withtyping_extensions.deprecatedget an admonition generated for them. The extension'skindis set todeprecatedrather than the defaultwarning, so what it emits is markup-identical to a hand-writtenDeprecated:admonition, and one rule styles both.Then a third commit gives this repo's deprecations a notice at all. The
keyargument ofDispatchApiClient.__init__and theSOLARmember ofInverterTypewere both deprecated in v0.11.2 but said so only in passing prose, so neither showed anything in the API reference. Both now have aDeprecated: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-keyoption 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--helptext and the notice printed at runtime.