From a36f889ead557c14d139afd488002c6b64117f7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Sun, 18 Aug 2024 15:54:59 +0200 Subject: [PATCH] feat: Implement no-op extension --- README.md | 25 +++++++++++++++++++ docs/insiders/goals.yml | 5 +++- pyproject.toml | 4 ++- .../__init__.py | 4 ++- .../_internals/__init__.py | 0 .../_internals/extension.py | 5 ++++ tests/test_extension.py | 6 +++++ 7 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 src/griffe_public_redundant_aliases/_internals/__init__.py create mode 100644 src/griffe_public_redundant_aliases/_internals/extension.py create mode 100644 tests/test_extension.py diff --git a/README.md b/README.md index 85f96d3..96bbf2d 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,28 @@ Mark objects imported with redundant aliases as public. This project is available to sponsors only, through my Insiders program. See Insiders [explanation](https://mkdocstrings.github.io/griffe-public-redundant-aliases/insiders/) and [installation instructions](https://mkdocstrings.github.io/griffe-public-redundant-aliases/insiders/installation/). + +## Usage + +[Enable](https://mkdocstrings.github.io/griffe/guide/users/extending/#using-extensions) the `griffe_public_redundant_aliases` extension. Now all objects imported with redundant aliases will be marked as public, as per the convention. + +```python +# Following objects will be marked as public. +from somewhere import Thing as Thing +from somewhere import Other as Other + +# Following object won't be marked as public. +from somewhere import Stuff +``` + +With MkDocs: + +```yaml +plugins: +- mkdocstrings: + handlers: + python: + options: + extensions: + - griffe_public_redundant_aliases +``` diff --git a/docs/insiders/goals.yml b/docs/insiders/goals.yml index 0e27b99..58a66c0 100644 --- a/docs/insiders/goals.yml +++ b/docs/insiders/goals.yml @@ -7,7 +7,10 @@ goals: features: [] 1500: name: HyperLamp Navigation Tips - features: [] + features: + - name: "[Project] Mark objects imported with redundant aliases as public" + ref: / + since: 2024/08/18 2000: name: FusionDrive Ejection Configuration features: [] diff --git a/pyproject.toml b/pyproject.toml index 7b944b8..d6c1038 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,9 @@ classifiers = [ "Topic :: Utilities", "Typing :: Typed", ] -dependencies = [] +dependencies = [ + "griffe>=1.1", +] [project.urls] Homepage = "https://mkdocstrings.github.io/griffe-public-redundant-aliases" diff --git a/src/griffe_public_redundant_aliases/__init__.py b/src/griffe_public_redundant_aliases/__init__.py index 382de0d..afe7712 100644 --- a/src/griffe_public_redundant_aliases/__init__.py +++ b/src/griffe_public_redundant_aliases/__init__.py @@ -5,4 +5,6 @@ from __future__ import annotations -__all__: list[str] = [] +from griffe_public_redundant_aliases._internals.extension import PublicRedundantAliasesExtension + +__all__: list[str] = ["PublicRedundantAliasesExtension"] diff --git a/src/griffe_public_redundant_aliases/_internals/__init__.py b/src/griffe_public_redundant_aliases/_internals/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/griffe_public_redundant_aliases/_internals/extension.py b/src/griffe_public_redundant_aliases/_internals/extension.py new file mode 100644 index 0000000..7c73695 --- /dev/null +++ b/src/griffe_public_redundant_aliases/_internals/extension.py @@ -0,0 +1,5 @@ +import griffe + + +class PublicRedundantAliasesExtension(griffe.Extension): + """Mark objects imported with redundant aliases as public.""" diff --git a/tests/test_extension.py b/tests/test_extension.py new file mode 100644 index 0000000..f879ace --- /dev/null +++ b/tests/test_extension.py @@ -0,0 +1,6 @@ +"""Test the extension.""" + + +def test_extension() -> None: + """Dummy test.""" + assert True