diff --git a/docs/_css/mkdocstrings.css b/docs/_css/mkdocstrings.css index 572abff13..851214f26 100644 --- a/docs/_css/mkdocstrings.css +++ b/docs/_css/mkdocstrings.css @@ -42,3 +42,25 @@ a.autorefs-external::after { a.autorefs-external:hover::after { background-color: var(--md-accent-fg-color); } + +/* A "Deprecated" admonition, styled like a warning but with its own icon. */ +:root { + --md-admonition-icon--deprecated: url('data:image/svg+xml;charset=utf-8,'); +} + +.md-typeset .admonition.deprecated, +.md-typeset details.deprecated { + border-color: #cc9900; +} + +.md-typeset .deprecated > .admonition-title, +.md-typeset .deprecated > summary { + background-color: #cc99001a; +} + +.md-typeset .deprecated > .admonition-title::before, +.md-typeset .deprecated > summary::before { + background-color: #cc9900; + -webkit-mask-image: var(--md-admonition-icon--deprecated); + mask-image: var(--md-admonition-icon--deprecated); +} diff --git a/mkdocs.yml b/mkdocs.yml index 83005355f..3c25ee03e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -103,6 +103,8 @@ plugins: python: paths: ["src"] options: + extensions: + - griffe_frequenz_core.deprecations docstring_section_style: spacy inherited_members: true merge_init_into_class: false diff --git a/pyproject.toml b/pyproject.toml index 114b99b4f..522e26b36 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,7 @@ dev-flake8 = [ dev-formatting = ["black == 26.10.1", "isort == 9.0.2"] dev-mkdocs = [ "black == 26.10.1", + "griffe-frequenz-core == 1.1.0", "Markdown==3.11.2", "mike == 2.2.0", "mkdocs-gen-files == 0.6.1", @@ -180,6 +181,14 @@ filterwarnings = [ "error", "once::DeprecationWarning", "once::PendingDeprecationWarning", + # But using our own deprecated symbols is an error, so we don't release code + # still using our own deprecated symbols, which will be noise for users. + # This is only a heuristic: it catches deprecation messages mentioning the + # fully qualified name of the deprecated symbol, as in "frequenz.sdk.OldThing + # is deprecated. Use frequenz.sdk.NewThing instead.". This is the + # recommended style in the deprecation guide: + # https://github.com/frequenz-floss/docs/blob/v0.x.x/python/deprecations.md + 'error:.*frequenz\.sdk\.[\w\.]+ (is|was) deprecated:DeprecationWarning', # We need to ignore PytestUnraisableExceptionWarning because we have some # cleanup issues, and sometimes exceptions are raised in __del__ methods, for # example when trying to do async stuff and the event loop is already closed.