Skip to content

Commit

Permalink
feat: Implement no-op extension
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Aug 16, 2024
1 parent dfb4c79 commit 4a375c7
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,25 @@ Set docstring style to 'auto' for external packages.
This project is available to sponsors only, through my Insiders program.
See Insiders [explanation](https://mkdocstrings.github.io/griffe-autodocstringstyle/insiders/)
and [installation instructions](https://mkdocstrings.github.io/griffe-autodocstringstyle/insiders/installation/).

## Usage

[Enable(https://mkdocstrings.github.io/griffe/guide/users/extending/#using-extensions)] the `griffe_autodocstringstyle` extension. Now all packages loaded from a virtual environment will have their docstrings parsed with the `auto` style (automatically guessing the docstring style).

Use the `exclude` option to pass package names that shouldn't be considered. This can be useful if you must first install your sources as a package before loading/documenting them (meaning they end up in the virtual environment too).

With MkDocs:

```yaml
plugins:
- mkdocstrings:
handlers:
python:
options:
extensions:
- griffe_autodocstringstyle:
# only useful if your sources can't be found
# in the current working directory
exclude:
- my_package
```
4 changes: 3 additions & 1 deletion src/griffe_autodocstringstyle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@

from __future__ import annotations

__all__: list[str] = []
from griffe_autodocstringstyle._internals.extension import AutoDocstringStyleExtension

__all__: list[str] = ["AutoDocstringStyleExtension"]
Empty file.
7 changes: 7 additions & 0 deletions src/griffe_autodocstringstyle/_internals/extension.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from __future__ import annotations

import griffe


class AutoDocstringStyleExtension(griffe.Extension):
"""Set `auto` docstring style on external packages."""
9 changes: 9 additions & 0 deletions tests/test_extension.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Test extension."""

from __future__ import annotations


def test_noop() -> None:
"""Dummy test."""
assert True

0 comments on commit 4a375c7

Please sign in to comment.