Skip to content

Commit 4a375c7

Browse files
committed
feat: Implement no-op extension
1 parent dfb4c79 commit 4a375c7

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,25 @@ Set docstring style to 'auto' for external packages.
1111
This project is available to sponsors only, through my Insiders program.
1212
See Insiders [explanation](https://mkdocstrings.github.io/griffe-autodocstringstyle/insiders/)
1313
and [installation instructions](https://mkdocstrings.github.io/griffe-autodocstringstyle/insiders/installation/).
14+
15+
## Usage
16+
17+
[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).
18+
19+
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).
20+
21+
With MkDocs:
22+
23+
```yaml
24+
plugins:
25+
- mkdocstrings:
26+
handlers:
27+
python:
28+
options:
29+
extensions:
30+
- griffe_autodocstringstyle:
31+
# only useful if your sources can't be found
32+
# in the current working directory
33+
exclude:
34+
- my_package
35+
```

src/griffe_autodocstringstyle/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55

66
from __future__ import annotations
77

8-
__all__: list[str] = []
8+
from griffe_autodocstringstyle._internals.extension import AutoDocstringStyleExtension
9+
10+
__all__: list[str] = ["AutoDocstringStyleExtension"]

src/griffe_autodocstringstyle/_internals/__init__.py

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from __future__ import annotations
2+
3+
import griffe
4+
5+
6+
class AutoDocstringStyleExtension(griffe.Extension):
7+
"""Set `auto` docstring style on external packages."""

tests/test_extension.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""Test extension."""
2+
3+
from __future__ import annotations
4+
5+
6+
def test_noop() -> None:
7+
"""Dummy test."""
8+
assert True
9+

0 commit comments

Comments
 (0)