docstring-generator 2.0.1__tar.gz → 2.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (18) hide show
  1. docstring_generator-2.1.1/LICENSE +13 -0
  2. docstring_generator-2.1.1/NOTICE +25 -0
  3. {docstring_generator-2.0.1 → docstring_generator-2.1.1}/PKG-INFO +191 -13
  4. {docstring_generator-2.0.1 → docstring_generator-2.1.1}/README.md +184 -11
  5. {docstring_generator-2.0.1 → docstring_generator-2.1.1}/pyproject.toml +14 -8
  6. docstring_generator-2.1.1/src/docstring_generator/new_gen_docs.py +255 -0
  7. {docstring_generator-2.0.1 → docstring_generator-2.1.1}/src/docstring_generator/output.py +60 -1
  8. {docstring_generator-2.0.1 → docstring_generator-2.1.1}/src/docstring_generator.egg-info/PKG-INFO +191 -13
  9. {docstring_generator-2.0.1 → docstring_generator-2.1.1}/src/docstring_generator.egg-info/SOURCES.txt +4 -1
  10. docstring_generator-2.1.1/src/docstring_generator.egg-info/requires.txt +2 -0
  11. docstring_generator-2.1.1/tests/test_library.py +354 -0
  12. docstring_generator-2.0.1/src/docstring_generator/new_gen_docs.py +0 -109
  13. docstring_generator-2.0.1/src/docstring_generator.egg-info/requires.txt +0 -2
  14. {docstring_generator-2.0.1 → docstring_generator-2.1.1}/setup.cfg +0 -0
  15. {docstring_generator-2.0.1 → docstring_generator-2.1.1}/src/docstring_generator/__init__.py +0 -0
  16. {docstring_generator-2.0.1 → docstring_generator-2.1.1}/src/docstring_generator.egg-info/dependency_links.txt +0 -0
  17. {docstring_generator-2.0.1 → docstring_generator-2.1.1}/src/docstring_generator.egg-info/entry_points.txt +0 -0
  18. {docstring_generator-2.0.1 → docstring_generator-2.1.1}/src/docstring_generator.egg-info/top_level.txt +0 -0
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2026 FelixTheC
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,25 @@
1
+ Docstring Generator
2
+
3
+ Copyright (c) 2026 FelixTheC
4
+
5
+ This product is licensed under the Apache License, Version 2.0.
6
+ You may obtain a copy of the License at:
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ Third-party attributions
17
+ ------------------------
18
+ If you include third-party libraries or other content that require
19
+ attribution, list them here with their license and a short note. For
20
+ example:
21
+
22
+ - SomeLibrary — MIT License — https://example.org/somelibrary
23
+
24
+ (If you don't have any third-party attributions to declare, you can
25
+ leave this section as-is or remove it.)
@@ -1,24 +1,32 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: docstring-generator
3
- Version: 2.0.1
3
+ Version: 2.1.1
4
4
  Summary: Auto generate docstring from type-hints.
5
5
  Author: FelixTheC
6
+ License: Apache-2.0
6
7
  Project-URL: Repository, https://github.com/FelixTheC/docstring_generator
7
8
  Classifier: Environment :: Console
8
9
  Classifier: Programming Language :: Python :: 3
9
10
  Classifier: Topic :: Utilities
10
11
  Classifier: Topic :: Software Development :: Documentation
11
12
  Classifier: Typing :: Typed
13
+ Classifier: License :: OSI Approved :: Apache Software License
12
14
  Requires-Python: >=3.13
13
15
  Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ License-File: NOTICE
14
18
  Requires-Dist: click==8.4.2
15
- Requires-Dist: docstring-generator-ext==2.0.2
19
+ Requires-Dist: docstring-generator-ext>=2.0.9
20
+ Dynamic: license-file
16
21
 
17
22
  [![Python 3.10](https://img.shields.io/badge/python-3-blue.svg)](https://www.python.org/downloads/)
18
23
  [![PyPI version](https://badge.fury.io/py/docstring-generator.svg)](https://badge.fury.io/py/docstring-generator)
24
+ ![Actions](https://github.com/FelixTheC/docstring_generator/actions/workflows/python-app.yml/badge.svg)
19
25
  [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
20
26
  [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
21
27
  [![](https://img.shields.io/pypi/dm/docstring-generator.svg)](https://pypi.org/project/docstring-generator/)
28
+ [![VS Code Extension](https://img.shields.io/badge/VS%20Code-Extension-007ACC?logo=visualstudiocode&logoColor=white)](https://marketplace.visualstudio.com/items?itemName=felixthec.docstring-generator-vscode)
29
+ [![JetBrains File Watcher](https://img.shields.io/badge/JetBrains-File%20Watcher-000000?logo=jetbrains&logoColor=white)](gendocs_file_watchers.xml)
22
30
 
23
31
  # docstring_generator
24
32
 
@@ -39,6 +47,9 @@ Good documentation is no longer optional. AI coding assistants, static analysis
39
47
  - ✍️ **Preserving your words** — existing descriptions and custom notes are never overwritten
40
48
  - 🧠 **AI-workflow friendly** — well-structured docstrings improve context quality for LLM-assisted development
41
49
  - 🚨 **Exception-aware** — automatically detects `raise` statements and documents them in a `Raises` section, so failure modes are part of your API contract
50
+ - 🙈 **Convention-correct** — `self` and `cls` are automatically excluded from generated parameter sections, matching every major docstring standard
51
+ - ⚙️ **Async-ready** — handles both `def` and `async def` functions transparently, no extra configuration needed
52
+ - 🎨 **Style-safe** — detects the existing docstring style and refuses to silently mix conventions; explicit opt-in required to convert styles
42
53
  - 🏎️ **Blazing fast** — core engine written in C++ via [pybind11](https://github.com/FelixTheC/docstring_generator_ext)
43
54
 
44
55
  ---
@@ -58,6 +69,8 @@ gendocs_new mydir/ # entire directory
58
69
 
59
70
  That's it. Your functions now have properly formatted docstrings.
60
71
 
72
+ > 💡 **Prefer working inside your editor?** Skip the terminal entirely — install the [VS Code extension](https://marketplace.visualstudio.com/items?itemName=felixthec.docstring-generator-vscode) or import the [JetBrains File Watcher](#jetbrains-ides-pycharm-intellij--python-plugin) to generate docstrings automatically every time you save a `.py` file. → [Jump to IDE Integration](#ide-integration)
73
+
61
74
  ---
62
75
 
63
76
  ## Options
@@ -102,6 +115,81 @@ gendocs_new mydir/ --check --threshold 80
102
115
 
103
116
  Useful in CI pipelines to enforce documentation standards across the codebase.
104
117
 
118
+ ### `--exclude-file` — Skip specific files
119
+
120
+ Exclude one or more files from processing by name. Can be passed multiple times:
121
+
122
+ ```shell
123
+ gendocs_new mydir/ --exclude-file conftest.py --exclude-file settings.py
124
+ ```
125
+
126
+ Files whose name matches any of the provided values are skipped during docstring generation.
127
+
128
+ ### `--exclude-dir` — Skip specific directories
129
+
130
+ Exclude one or more directories from processing. Can be passed multiple times:
131
+
132
+ ```shell
133
+ gendocs_new mydir/ --exclude-dir tests --exclude-dir migrations
134
+ ```
135
+
136
+ Any file whose path contains one of the given directory names is skipped.
137
+
138
+ ### `--dry-run` — Preview changes without modifying any file
139
+
140
+ Run the generator in read-only mode and see exactly what would be added or changed as a unified diff:
141
+
142
+ ```shell
143
+ gendocs_new mydir/ --dry-run
144
+ ```
145
+
146
+ Files that already have complete docstrings print `<file>: no changes`. Files with missing docstrings show a `+`/`-` diff so you can review before committing. Combine with `--style` or `--overwrite-style` to preview a style migration:
147
+
148
+ ```shell
149
+ gendocs_new mydir/ --style google --overwrite-style --dry-run
150
+ ```
151
+
152
+ ### `--changed-only` — Only process git-changed files
153
+
154
+ Restrict processing to files that are modified or staged in git — perfect for large repos where running on the full `src/` directory on every commit would be slow:
155
+
156
+ ```shell
157
+ gendocs_new mydir/ --changed-only
158
+ ```
159
+
160
+ Internally runs `git diff --name-only HEAD` and `git diff --cached --name-only` to collect the list of changed and staged `.py` files, then intersects that list with the paths you provided. If git is not installed or not available on `PATH`, the command aborts immediately with a clear error message rather than silently processing everything.
161
+
162
+ Combines well with `--dry-run` to preview what *would* change for only the files you touched:
163
+
164
+ ```shell
165
+ gendocs_new mydir/ --changed-only --dry-run
166
+ ```
167
+
168
+ ### `--ignore-magic` — Skip dunder / magic methods
169
+
170
+ Exclude dunder methods such as `__init__`, `__str__`, `__repr__`, `__eq__`, etc. from docstring generation. These are often implementation details that add noise rather than value to public documentation:
171
+
172
+ ```shell
173
+ gendocs_new mydir/ --ignore-magic
174
+ ```
175
+
176
+ Can also be enabled permanently via `pyproject.toml` so every invocation skips magic methods without an explicit flag:
177
+
178
+ ```toml
179
+ [tool.docstring_generator]
180
+ ignore_magic = true
181
+ ```
182
+
183
+ ### `--overwrite-style` — Re-format existing docstrings in a different style
184
+
185
+ Force regeneration of existing docstrings using the specified style, even if they already have content:
186
+
187
+ ```shell
188
+ gendocs_new mydir/ --style google --overwrite-style true
189
+ ```
190
+
191
+ Useful when migrating a codebase from one docstring convention to another.
192
+
105
193
  ---
106
194
 
107
195
  ## Configuration via `pyproject.toml`
@@ -112,6 +200,9 @@ Instead of passing flags on every invocation, persist defaults in your project's
112
200
  [tool.docstring_generator]
113
201
  strict = true
114
202
  threshold = 90
203
+ exclude_files = ["conftest.py", "settings.py"]
204
+ exclude_dirs = ["tests", "migrations"]
205
+ ignore_magic = true
115
206
  ```
116
207
 
117
208
  CLI flags always override `pyproject.toml` values. The tool automatically walks up from the target path to find the nearest `pyproject.toml`.
@@ -161,6 +252,37 @@ def foo(val_a: int, val_b: List[int]):
161
252
 
162
253
  ---
163
254
 
255
+ ## Preserve Return Description with `>>` Marker
256
+
257
+ Use `>>` on its own line inside an existing docstring to provide a description for the return value. On the next `gendocs_new` run the marker is consumed and wired into the `Returns` section automatically.
258
+
259
+ ```python
260
+ def square(x: int) -> int:
261
+ """Square a number.
262
+
263
+ >> The squared value of x.
264
+ """
265
+ return x * x
266
+ ```
267
+
268
+ After running `gendocs_new` (Google style):
269
+
270
+ ```python
271
+ def square(x: int) -> int:
272
+ """Square a number.
273
+
274
+ Args:
275
+ x (int):
276
+ Returns:
277
+ int: The squared value of x.
278
+ """
279
+ return x * x
280
+ ```
281
+
282
+ Combine `$N` for parameter descriptions and `>>` for the return description to fully annotate a function before running the generator — no manual editing of the structured sections needed.
283
+
284
+ ---
285
+
164
286
  ## Automatic `Raises` Extraction
165
287
 
166
288
  `docstring_generator` statically analyzes your function body for `raise` statements and adds a `Raises` section describing each exception — including the condition that triggers it. This works seamlessly with frameworks like **Pydantic**, **FastAPI**, or any custom validation logic.
@@ -196,7 +318,6 @@ class PluginConfig(BaseModel):
196
318
  """
197
319
  Parameters
198
320
  ----------
199
- cls : [Argument]
200
321
  values : dict [Argument]
201
322
 
202
323
  Returns
@@ -270,6 +391,57 @@ hooks:
270
391
 
271
392
  ---
272
393
 
394
+ ## IDE Integration
395
+
396
+ ### VS Code Extension
397
+
398
+ Install the [docstring-generator VS Code extension](https://marketplace.visualstudio.com/items?itemName=felixthec.docstring-generator-vscode) from the marketplace to generate docstrings directly from the editor — no terminal required.
399
+
400
+ **Features:**
401
+ - Right-click any `.py` file → **Generate Docstrings**
402
+ - Keyboard shortcut: `Ctrl+Shift+D` (Windows/Linux) / `Cmd+Shift+D` (macOS)
403
+ - Configurable style (`numpy`, `google`, `rest`) via VS Code settings
404
+
405
+ **Setup:**
406
+ 1. Install from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=felixthec.docstring-generator-vscode)
407
+ 2. Make sure `gendocs_new` is on your `PATH` (install `docstring-generator` via pip)
408
+ 3. Optionally configure the style in your VS Code settings:
409
+ ```json
410
+ {
411
+ "docstringGenerator.style": "google"
412
+ }
413
+ ```
414
+
415
+ ### JetBrains IDEs (PyCharm, IntelliJ + Python plugin)
416
+
417
+ Use the provided **File Watcher** configuration to automatically generate docstrings every time you save a `.py` file.
418
+
419
+ **Setup:**
420
+ 1. Copy [`gendocs_file_watchers.xml`](gendocs_file_watchers.xml) from the repository root into your project's `.idea/watcherTasks.xml` — or import it via **Settings → Tools → File Watchers → Import**.
421
+ 2. The watcher is pre-configured to:
422
+ - Run on every `.py` file in the project scope
423
+ - Use `$PROJECT_DIR$/.venv/bin/gendocs_new` as the executable (adjust the path if your venv lives elsewhere)
424
+ - Pass `--style numpy $FilePath$` by default — change `numpy` to `google` or `rest` as needed
425
+ - Write the result back to the same file (`$FilePath$`)
426
+
427
+ ```xml
428
+ <TaskOptions>
429
+ <TaskOptions>
430
+ <option name="arguments" value="--style numpy $FilePath$" />
431
+ <option name="fileExtension" value="py" />
432
+ <option name="name" value="gendocs_new" />
433
+ <option name="output" value="$FilePath$" />
434
+ <option name="program" value="$PROJECT_DIR$/.venv/bin/gendocs_new" />
435
+ <option name="scopeName" value="Project Files" />
436
+ <option name="workingDir" value="$FileDir$" />
437
+ </TaskOptions>
438
+ </TaskOptions>
439
+ ```
440
+
441
+ > **Tip:** Combine the File Watcher with `--ignore-magic` or `pyproject.toml` configuration to tailor which methods are documented automatically on save.
442
+
443
+ ---
444
+
273
445
  ## FAQ
274
446
 
275
447
  ### What happens if I re-run docstring generation?
@@ -298,13 +470,13 @@ Ready-to-run examples are available in the [`examples/`](examples/) directory.
298
470
  pip install docstring-generator
299
471
  ```
300
472
 
301
- Requires Python 3.10+.
473
+ Requires Python 3.13+.
302
474
 
303
475
  ---
304
476
 
305
477
  ## How It Works
306
478
 
307
- The core engine is implemented in C++ and exposed to Python via [pybind11](https://github.com/pybind/pybind11), delivering performance that scales to large codebases without slowing down your workflow.
479
+ The core engine is implemented in C++ (C++20) and exposed to Python via [pybind11](https://github.com/pybind/pybind11), delivering performance that scales to large codebases without slowing down your workflow.
308
480
 
309
481
  - **Extension:** [docstring-generator-ext](https://github.com/FelixTheC/docstring_generator_ext) — the high-performance backbone of this project
310
482
 
@@ -314,15 +486,21 @@ The core engine is implemented in C++ and exposed to Python via [pybind11](https
314
486
 
315
487
  Planned features and areas of investment:
316
488
 
317
- - [x] Pre-commit hook integration for automatic docstring enforcement
318
- - [x] Return type documentation generation
319
- - [x] Raises documentation generation
320
- - [x] Docstring coverage reporting (`--check`, `--strict`, `--threshold`)
321
- - [x] `pyproject.toml` configuration support
322
- - [ ] add `>>` as placeholder for additional return description like `$1`
323
- - [ ] IDE plugin support (JetBrains, VS Code)
489
+ ### Medium-term
490
+
491
+ - [x] File Watcher configuration for JetBrains IDEs (PyCharm) — import `gendocs_file_watchers.xml` to auto-generate docstrings on every file save
492
+ - [x] VS Code extension — available on the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=felixthec.docstring-generator-vscode)
493
+ - [ ] GitHub Action — publish a ready-to-use Action to the Marketplace so teams can enforce docstring coverage in CI without any local installation
494
+ - [ ] Coverage badge generation (`--badge`) — produce an SVG badge from `--check` results to embed in README, similar to a test-coverage badge
495
+ - [ ] JUnit/SARIF output for `--check` — emit machine-readable results for GitHub, GitLab, and Azure DevOps CI panels; enables PR annotations that highlight undocumented functions inline
496
+
497
+ ### Longer-term
498
+
499
+ - [ ] Watch mode (`--watch`) — monitor the project for file saves and regenerate docstrings automatically in the background
500
+ - [ ] Sphinx / mkdocs bridge (`--export-rst`) — generate `.rst` or `.md` stubs ready for Sphinx/mkdocs autodoc pipelines
501
+ - [ ] Custom docstring templates — let teams define their own format via `pyproject.toml` for internal style guides that extend NumPy or Google
502
+ - [ ] LLM-assisted description generation (opt-in enrichment mode) — use a local or remote LLM to fill in meaningful parameter descriptions beyond the type hint
324
503
  - [ ] CI/CD pipeline gate (fail build below coverage threshold)
325
- - [ ] LLM-assisted description generation (opt-in enrichment mode)
326
504
 
327
505
  Community feedback shapes priorities — open an issue to vote on features or suggest new ones.
328
506
 
@@ -1,8 +1,11 @@
1
1
  [![Python 3.10](https://img.shields.io/badge/python-3-blue.svg)](https://www.python.org/downloads/)
2
2
  [![PyPI version](https://badge.fury.io/py/docstring-generator.svg)](https://badge.fury.io/py/docstring-generator)
3
+ ![Actions](https://github.com/FelixTheC/docstring_generator/actions/workflows/python-app.yml/badge.svg)
3
4
  [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
4
5
  [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
5
6
  [![](https://img.shields.io/pypi/dm/docstring-generator.svg)](https://pypi.org/project/docstring-generator/)
7
+ [![VS Code Extension](https://img.shields.io/badge/VS%20Code-Extension-007ACC?logo=visualstudiocode&logoColor=white)](https://marketplace.visualstudio.com/items?itemName=felixthec.docstring-generator-vscode)
8
+ [![JetBrains File Watcher](https://img.shields.io/badge/JetBrains-File%20Watcher-000000?logo=jetbrains&logoColor=white)](gendocs_file_watchers.xml)
6
9
 
7
10
  # docstring_generator
8
11
 
@@ -23,6 +26,9 @@ Good documentation is no longer optional. AI coding assistants, static analysis
23
26
  - ✍️ **Preserving your words** — existing descriptions and custom notes are never overwritten
24
27
  - 🧠 **AI-workflow friendly** — well-structured docstrings improve context quality for LLM-assisted development
25
28
  - 🚨 **Exception-aware** — automatically detects `raise` statements and documents them in a `Raises` section, so failure modes are part of your API contract
29
+ - 🙈 **Convention-correct** — `self` and `cls` are automatically excluded from generated parameter sections, matching every major docstring standard
30
+ - ⚙️ **Async-ready** — handles both `def` and `async def` functions transparently, no extra configuration needed
31
+ - 🎨 **Style-safe** — detects the existing docstring style and refuses to silently mix conventions; explicit opt-in required to convert styles
26
32
  - 🏎️ **Blazing fast** — core engine written in C++ via [pybind11](https://github.com/FelixTheC/docstring_generator_ext)
27
33
 
28
34
  ---
@@ -42,6 +48,8 @@ gendocs_new mydir/ # entire directory
42
48
 
43
49
  That's it. Your functions now have properly formatted docstrings.
44
50
 
51
+ > 💡 **Prefer working inside your editor?** Skip the terminal entirely — install the [VS Code extension](https://marketplace.visualstudio.com/items?itemName=felixthec.docstring-generator-vscode) or import the [JetBrains File Watcher](#jetbrains-ides-pycharm-intellij--python-plugin) to generate docstrings automatically every time you save a `.py` file. → [Jump to IDE Integration](#ide-integration)
52
+
45
53
  ---
46
54
 
47
55
  ## Options
@@ -86,6 +94,81 @@ gendocs_new mydir/ --check --threshold 80
86
94
 
87
95
  Useful in CI pipelines to enforce documentation standards across the codebase.
88
96
 
97
+ ### `--exclude-file` — Skip specific files
98
+
99
+ Exclude one or more files from processing by name. Can be passed multiple times:
100
+
101
+ ```shell
102
+ gendocs_new mydir/ --exclude-file conftest.py --exclude-file settings.py
103
+ ```
104
+
105
+ Files whose name matches any of the provided values are skipped during docstring generation.
106
+
107
+ ### `--exclude-dir` — Skip specific directories
108
+
109
+ Exclude one or more directories from processing. Can be passed multiple times:
110
+
111
+ ```shell
112
+ gendocs_new mydir/ --exclude-dir tests --exclude-dir migrations
113
+ ```
114
+
115
+ Any file whose path contains one of the given directory names is skipped.
116
+
117
+ ### `--dry-run` — Preview changes without modifying any file
118
+
119
+ Run the generator in read-only mode and see exactly what would be added or changed as a unified diff:
120
+
121
+ ```shell
122
+ gendocs_new mydir/ --dry-run
123
+ ```
124
+
125
+ Files that already have complete docstrings print `<file>: no changes`. Files with missing docstrings show a `+`/`-` diff so you can review before committing. Combine with `--style` or `--overwrite-style` to preview a style migration:
126
+
127
+ ```shell
128
+ gendocs_new mydir/ --style google --overwrite-style --dry-run
129
+ ```
130
+
131
+ ### `--changed-only` — Only process git-changed files
132
+
133
+ Restrict processing to files that are modified or staged in git — perfect for large repos where running on the full `src/` directory on every commit would be slow:
134
+
135
+ ```shell
136
+ gendocs_new mydir/ --changed-only
137
+ ```
138
+
139
+ Internally runs `git diff --name-only HEAD` and `git diff --cached --name-only` to collect the list of changed and staged `.py` files, then intersects that list with the paths you provided. If git is not installed or not available on `PATH`, the command aborts immediately with a clear error message rather than silently processing everything.
140
+
141
+ Combines well with `--dry-run` to preview what *would* change for only the files you touched:
142
+
143
+ ```shell
144
+ gendocs_new mydir/ --changed-only --dry-run
145
+ ```
146
+
147
+ ### `--ignore-magic` — Skip dunder / magic methods
148
+
149
+ Exclude dunder methods such as `__init__`, `__str__`, `__repr__`, `__eq__`, etc. from docstring generation. These are often implementation details that add noise rather than value to public documentation:
150
+
151
+ ```shell
152
+ gendocs_new mydir/ --ignore-magic
153
+ ```
154
+
155
+ Can also be enabled permanently via `pyproject.toml` so every invocation skips magic methods without an explicit flag:
156
+
157
+ ```toml
158
+ [tool.docstring_generator]
159
+ ignore_magic = true
160
+ ```
161
+
162
+ ### `--overwrite-style` — Re-format existing docstrings in a different style
163
+
164
+ Force regeneration of existing docstrings using the specified style, even if they already have content:
165
+
166
+ ```shell
167
+ gendocs_new mydir/ --style google --overwrite-style true
168
+ ```
169
+
170
+ Useful when migrating a codebase from one docstring convention to another.
171
+
89
172
  ---
90
173
 
91
174
  ## Configuration via `pyproject.toml`
@@ -96,6 +179,9 @@ Instead of passing flags on every invocation, persist defaults in your project's
96
179
  [tool.docstring_generator]
97
180
  strict = true
98
181
  threshold = 90
182
+ exclude_files = ["conftest.py", "settings.py"]
183
+ exclude_dirs = ["tests", "migrations"]
184
+ ignore_magic = true
99
185
  ```
100
186
 
101
187
  CLI flags always override `pyproject.toml` values. The tool automatically walks up from the target path to find the nearest `pyproject.toml`.
@@ -145,6 +231,37 @@ def foo(val_a: int, val_b: List[int]):
145
231
 
146
232
  ---
147
233
 
234
+ ## Preserve Return Description with `>>` Marker
235
+
236
+ Use `>>` on its own line inside an existing docstring to provide a description for the return value. On the next `gendocs_new` run the marker is consumed and wired into the `Returns` section automatically.
237
+
238
+ ```python
239
+ def square(x: int) -> int:
240
+ """Square a number.
241
+
242
+ >> The squared value of x.
243
+ """
244
+ return x * x
245
+ ```
246
+
247
+ After running `gendocs_new` (Google style):
248
+
249
+ ```python
250
+ def square(x: int) -> int:
251
+ """Square a number.
252
+
253
+ Args:
254
+ x (int):
255
+ Returns:
256
+ int: The squared value of x.
257
+ """
258
+ return x * x
259
+ ```
260
+
261
+ Combine `$N` for parameter descriptions and `>>` for the return description to fully annotate a function before running the generator — no manual editing of the structured sections needed.
262
+
263
+ ---
264
+
148
265
  ## Automatic `Raises` Extraction
149
266
 
150
267
  `docstring_generator` statically analyzes your function body for `raise` statements and adds a `Raises` section describing each exception — including the condition that triggers it. This works seamlessly with frameworks like **Pydantic**, **FastAPI**, or any custom validation logic.
@@ -180,7 +297,6 @@ class PluginConfig(BaseModel):
180
297
  """
181
298
  Parameters
182
299
  ----------
183
- cls : [Argument]
184
300
  values : dict [Argument]
185
301
 
186
302
  Returns
@@ -254,6 +370,57 @@ hooks:
254
370
 
255
371
  ---
256
372
 
373
+ ## IDE Integration
374
+
375
+ ### VS Code Extension
376
+
377
+ Install the [docstring-generator VS Code extension](https://marketplace.visualstudio.com/items?itemName=felixthec.docstring-generator-vscode) from the marketplace to generate docstrings directly from the editor — no terminal required.
378
+
379
+ **Features:**
380
+ - Right-click any `.py` file → **Generate Docstrings**
381
+ - Keyboard shortcut: `Ctrl+Shift+D` (Windows/Linux) / `Cmd+Shift+D` (macOS)
382
+ - Configurable style (`numpy`, `google`, `rest`) via VS Code settings
383
+
384
+ **Setup:**
385
+ 1. Install from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=felixthec.docstring-generator-vscode)
386
+ 2. Make sure `gendocs_new` is on your `PATH` (install `docstring-generator` via pip)
387
+ 3. Optionally configure the style in your VS Code settings:
388
+ ```json
389
+ {
390
+ "docstringGenerator.style": "google"
391
+ }
392
+ ```
393
+
394
+ ### JetBrains IDEs (PyCharm, IntelliJ + Python plugin)
395
+
396
+ Use the provided **File Watcher** configuration to automatically generate docstrings every time you save a `.py` file.
397
+
398
+ **Setup:**
399
+ 1. Copy [`gendocs_file_watchers.xml`](gendocs_file_watchers.xml) from the repository root into your project's `.idea/watcherTasks.xml` — or import it via **Settings → Tools → File Watchers → Import**.
400
+ 2. The watcher is pre-configured to:
401
+ - Run on every `.py` file in the project scope
402
+ - Use `$PROJECT_DIR$/.venv/bin/gendocs_new` as the executable (adjust the path if your venv lives elsewhere)
403
+ - Pass `--style numpy $FilePath$` by default — change `numpy` to `google` or `rest` as needed
404
+ - Write the result back to the same file (`$FilePath$`)
405
+
406
+ ```xml
407
+ <TaskOptions>
408
+ <TaskOptions>
409
+ <option name="arguments" value="--style numpy $FilePath$" />
410
+ <option name="fileExtension" value="py" />
411
+ <option name="name" value="gendocs_new" />
412
+ <option name="output" value="$FilePath$" />
413
+ <option name="program" value="$PROJECT_DIR$/.venv/bin/gendocs_new" />
414
+ <option name="scopeName" value="Project Files" />
415
+ <option name="workingDir" value="$FileDir$" />
416
+ </TaskOptions>
417
+ </TaskOptions>
418
+ ```
419
+
420
+ > **Tip:** Combine the File Watcher with `--ignore-magic` or `pyproject.toml` configuration to tailor which methods are documented automatically on save.
421
+
422
+ ---
423
+
257
424
  ## FAQ
258
425
 
259
426
  ### What happens if I re-run docstring generation?
@@ -282,13 +449,13 @@ Ready-to-run examples are available in the [`examples/`](examples/) directory.
282
449
  pip install docstring-generator
283
450
  ```
284
451
 
285
- Requires Python 3.10+.
452
+ Requires Python 3.13+.
286
453
 
287
454
  ---
288
455
 
289
456
  ## How It Works
290
457
 
291
- The core engine is implemented in C++ and exposed to Python via [pybind11](https://github.com/pybind/pybind11), delivering performance that scales to large codebases without slowing down your workflow.
458
+ The core engine is implemented in C++ (C++20) and exposed to Python via [pybind11](https://github.com/pybind/pybind11), delivering performance that scales to large codebases without slowing down your workflow.
292
459
 
293
460
  - **Extension:** [docstring-generator-ext](https://github.com/FelixTheC/docstring_generator_ext) — the high-performance backbone of this project
294
461
 
@@ -298,15 +465,21 @@ The core engine is implemented in C++ and exposed to Python via [pybind11](https
298
465
 
299
466
  Planned features and areas of investment:
300
467
 
301
- - [x] Pre-commit hook integration for automatic docstring enforcement
302
- - [x] Return type documentation generation
303
- - [x] Raises documentation generation
304
- - [x] Docstring coverage reporting (`--check`, `--strict`, `--threshold`)
305
- - [x] `pyproject.toml` configuration support
306
- - [ ] add `>>` as placeholder for additional return description like `$1`
307
- - [ ] IDE plugin support (JetBrains, VS Code)
468
+ ### Medium-term
469
+
470
+ - [x] File Watcher configuration for JetBrains IDEs (PyCharm) — import `gendocs_file_watchers.xml` to auto-generate docstrings on every file save
471
+ - [x] VS Code extension — available on the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=felixthec.docstring-generator-vscode)
472
+ - [ ] GitHub Action — publish a ready-to-use Action to the Marketplace so teams can enforce docstring coverage in CI without any local installation
473
+ - [ ] Coverage badge generation (`--badge`) — produce an SVG badge from `--check` results to embed in README, similar to a test-coverage badge
474
+ - [ ] JUnit/SARIF output for `--check` — emit machine-readable results for GitHub, GitLab, and Azure DevOps CI panels; enables PR annotations that highlight undocumented functions inline
475
+
476
+ ### Longer-term
477
+
478
+ - [ ] Watch mode (`--watch`) — monitor the project for file saves and regenerate docstrings automatically in the background
479
+ - [ ] Sphinx / mkdocs bridge (`--export-rst`) — generate `.rst` or `.md` stubs ready for Sphinx/mkdocs autodoc pipelines
480
+ - [ ] Custom docstring templates — let teams define their own format via `pyproject.toml` for internal style guides that extend NumPy or Google
481
+ - [ ] LLM-assisted description generation (opt-in enrichment mode) — use a local or remote LLM to fill in meaningful parameter descriptions beyond the type hint
308
482
  - [ ] CI/CD pipeline gate (fail build below coverage threshold)
309
- - [ ] LLM-assisted description generation (opt-in enrichment mode)
310
483
 
311
484
  Community feedback shapes priorities — open an issue to vote on features or suggest new ones.
312
485
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "docstring-generator"
3
- version = "2.0.1"
3
+ version = "2.1.1"
4
4
  description = "Auto generate docstring from type-hints."
5
5
  authors = [
6
6
  { name = "FelixTheC" },
@@ -8,17 +8,21 @@ authors = [
8
8
  readme = "README.md"
9
9
  requires-python = ">=3.13"
10
10
 
11
+ # License metadata
12
+ license = { text = "Apache-2.0" }
13
+
11
14
  classifiers=[
12
15
  "Environment :: Console",
13
16
  "Programming Language :: Python :: 3",
14
17
  "Topic :: Utilities",
15
18
  "Topic :: Software Development :: Documentation",
16
19
  "Typing :: Typed",
20
+ "License :: OSI Approved :: Apache Software License",
17
21
  ]
18
22
 
19
23
  dependencies = [
20
24
  "click == 8.4.2",
21
- "docstring-generator-ext==2.0.2",
25
+ "docstring-generator-ext>=2.0.9",
22
26
  ]
23
27
 
24
28
  [dependency-groups]
@@ -26,7 +30,7 @@ dev = [
26
30
  "pytest>=9.1.1",
27
31
  "pytest-cov>=7.1.0",
28
32
  "ruff==0.15.21",
29
- "fastapi==0.139.0",
33
+ "fastapi==0.140.0",
30
34
  "sqlalchemy==2.0.51"
31
35
  ]
32
36
 
@@ -36,11 +40,6 @@ no-binary-package = ["docstring-generator-ext"]
36
40
  [tool.uv.extra-build-variables]
37
41
  docstring-generator-ext = { MACOSX_DEPLOYMENT_TARGET = "13.3", CXXFLAGS = "-std=c++20", CL = "/std:c++20" }
38
42
 
39
- [tool.poetry.group.dev.dependencies]
40
- black = ">=22.8,<25.0"
41
- isort = "^5.10.1"
42
- pytest = "^7.1.3"
43
-
44
43
  [project.urls]
45
44
  Repository = "https://github.com/FelixTheC/docstring_generator"
46
45
 
@@ -57,3 +56,10 @@ exclude = ["tests"]
57
56
 
58
57
  [project.scripts]
59
58
  gendocs_new = "docstring_generator.new_gen_docs:main"
59
+
60
+ # Ensure non-code files like NOTICE are included in sdist/wheel
61
+ [tool.setuptools]
62
+ include-package-data = true
63
+
64
+ [tool.setuptools.data-files]
65
+ "doc" = ["NOTICE"]