docstring-format-checker 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,39 @@
1
+ class DocstringError(Exception):
2
+ """
3
+ Exception raised when a docstring validation error occurs.
4
+ """
5
+
6
+ def __init__(
7
+ self,
8
+ message: str,
9
+ file_path: str,
10
+ line_number: int,
11
+ item_name: str,
12
+ item_type: str,
13
+ ) -> None:
14
+ self.message = message
15
+ self.file_path = file_path
16
+ self.line_number = line_number
17
+ self.item_name = item_name
18
+ self.item_type = item_type
19
+ super().__init__(f"Line {line_number}, {item_type} '{item_name}': {message}")
20
+
21
+
22
+ class InvalidConfigError(Exception):
23
+ pass
24
+
25
+
26
+ class InvalidConfigError_DuplicateOrderValues(Exception):
27
+ pass
28
+
29
+
30
+ class InvalidTypeValuesError(Exception):
31
+ pass
32
+
33
+
34
+ class InvalidFileError(OSError):
35
+ pass
36
+
37
+
38
+ class DirectoryNotFoundError(OSError):
39
+ pass
@@ -0,0 +1,467 @@
1
+ Metadata-Version: 2.4
2
+ Name: docstring-format-checker
3
+ Version: 0.1.0
4
+ Summary: A CLI tool to check and validate Python docstring formatting and completeness
5
+ Author: Chris Mahoney
6
+ Author-email: Chris Mahoney <docstring-format-checker@data-science-extensions.com>
7
+ License-Expression: MIT
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Topic :: Software Development :: Quality Assurance
11
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
12
+ Classifier: Topic :: Software Development :: Testing :: Unit
13
+ Classifier: Topic :: Utilities
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Intended Audience :: Developers
21
+ Classifier: Environment :: Console
22
+ Requires-Dist: typer>=0.9.0
23
+ Requires-Dist: tomli>=2.0.0 ; python_full_version < '3.11'
24
+ Requires-Dist: rich>=13.0.0
25
+ Requires-Dist: toolbox-python==1.*
26
+ Maintainer: Chris Mahoney
27
+ Maintainer-email: Chris Mahoney <docstring-format-checker@data-science-extensions.com>
28
+ Requires-Python: >=3.9
29
+ Project-URL: Changelog, https://github.com/data-science-extensions/docstring-format-checker/releases
30
+ Project-URL: Documentation, https://github.com/data-science-extensions/docstring-format-checker/blob/main/README.md
31
+ Project-URL: Homepage, https://github.com/data-science-extensions/docstring-format-checker
32
+ Project-URL: Issues, https://github.com/data-science-extensions/docstring-format-checker/issues
33
+ Project-URL: Repository, https://github.com/data-science-extensions/docstring-format-checker
34
+ Description-Content-Type: text/markdown
35
+
36
+ <h1 align="center"><u><code>docstring-format-checker</code></u></h1>
37
+
38
+ <p align="center">
39
+ <a href="https://github.com/data-science-extensions/docstring-format-checker/releases">
40
+ <img src="https://img.shields.io/github/v/release/data-science-extensions/docstring-format-checker?logo=github" alt="github-release"></a>
41
+ <a href="https://pypi.org/project/docstring-format-checker">
42
+ <img src="https://img.shields.io/pypi/implementation/docstring-format-checker?logo=pypi&logoColor=ffde57" alt="implementation"></a>
43
+ <a href="https://pypi.org/project/docstring-format-checker">
44
+ <img src="https://img.shields.io/pypi/v/docstring-format-checker?label=version&logo=python&logoColor=ffde57&color=blue" alt="version"></a>
45
+ <a href="https://pypi.org/project/docstring-format-checker">
46
+ <img src="https://img.shields.io/pypi/pyversions/docstring-format-checker?logo=python&logoColor=ffde57" alt="python-versions"></a>
47
+ <br>
48
+ <a href="https://github.com/data-science-extensions/docstring-format-checker/actions/workflows/ci.yml">
49
+ <img src="https://img.shields.io/static/v1?label=os&message=ubuntu+|+macos+|+windows&color=blue&logo=ubuntu&logoColor=green" alt="os"></a>
50
+ <a href="https://pypi.org/project/docstring-format-checker">
51
+ <img src="https://img.shields.io/pypi/status/docstring-format-checker?color=green" alt="pypi-status"></a>
52
+ <a href="https://pypi.org/project/docstring-format-checker">
53
+ <img src="https://img.shields.io/pypi/format/docstring-format-checker?color=green" alt="pypi-format"></a>
54
+ <a href="https://github.com/data-science-extensions/docstring-format-checker/blob/main/LICENSE">
55
+ <img src="https://img.shields.io/github/license/data-science-extensions/docstring-format-checker?color=green" alt="github-license"></a>
56
+ <a href="https://piptrends.com/package/docstring-format-checker">
57
+ <img src="https://img.shields.io/pypi/dm/docstring-format-checker?color=green" alt="pypi-downloads"></a>
58
+ <a href="https://codecov.io/gh/data-science-extensions/docstring-format-checker">
59
+ <img src="https://codecov.io/gh/data-science-extensions/docstring-format-checker/graph/badge.svg" alt="codecov-repo"></a>
60
+ <a href="https://github.com/psf/black">
61
+ <img src="https://img.shields.io/static/v1?label=style&message=black&color=black&logo=windows-terminal&logoColor=white" alt="style"></a>
62
+ <br>
63
+ <a href="https://github.com/data-science-extensions/docstring-format-checker">
64
+ <img src="https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat" alt="contributions"></a>
65
+ <br>
66
+ <a href="https://github.com/data-science-extensions/docstring-format-checker/actions/workflows/ci.yml">
67
+ <img src="https://github.com/data-science-extensions/docstring-format-checker/actions/workflows/ci.yml/badge.svg?event=pull_request" alt="CI"></a>
68
+ <a href="https://github.com/data-science-extensions/docstring-format-checker/actions/workflows/cd.yml">
69
+ <img src="https://github.com/data-science-extensions/docstring-format-checker/actions/workflows/cd.yml/badge.svg?event=release" alt="CD"></a>
70
+ </p>
71
+
72
+
73
+ ### Introduction
74
+
75
+ A powerful Python CLI tool that validates docstring formatting and completeness using AST parsing. Ensure consistent, high-quality documentation across your entire codebase with configurable validation rules and rich terminal output.
76
+
77
+ **Key Features:**
78
+
79
+ - 🔍 **AST-based parsing** - Robust code analysis without regex fragility
80
+ - ⚙️ **Configurable validation** - Four section types with TOML-based configuration
81
+ - 📁 **Hierarchical config discovery** - Automatic `pyproject.toml` detection
82
+ - 🎨 **Rich terminal output** - Beautiful colored output and error tables
83
+ - 🚀 **Dual CLI entry points** - Use `docstring-format-checker` or `dfc`
84
+ - 🛡️ **100% test coverage** - Thoroughly tested and reliable
85
+
86
+
87
+ ### Quick Start
88
+
89
+ ```bash
90
+ # Install
91
+ uv add docstring-format-checker
92
+
93
+ # Check a single file
94
+ dfc check my_module.py
95
+
96
+ # Check entire directory
97
+ dfc check src/
98
+
99
+ # Generate example configuration
100
+ dfc config-example
101
+ ```
102
+
103
+
104
+ ### Key URLs
105
+
106
+ For reference, these URL's are used:
107
+
108
+ | Type | Source | URL |
109
+ | -------------- | ------ | ------------------------------------------------------------------- |
110
+ | Git Repo | GitHub | https://github.com/data-science-extensions/docstring-format-checker |
111
+ | Python Package | PyPI | https://pypi.org/project/docstring-format-checker |
112
+ | Package Docs | Pages | https://data-science-extensions.com/docstring-format-checker |
113
+
114
+
115
+ ### Section Types
116
+
117
+ Configure validation for four types of docstring sections:
118
+
119
+ | Type | Description | Example Use |
120
+ | -------------------- | ------------------------- | ------------------------------ |
121
+ | `free_text` | Admonition-style sections | Summary, details, examples |
122
+ | `list_name` | Simple name lists | Simple parameter lists |
123
+ | `list_type` | Type-only lists | Raises, yields sections |
124
+ | `list_name_and_type` | Name and type lists | Parameters, returns with types |
125
+
126
+
127
+ ### Configuration
128
+
129
+ Create a `pyproject.toml` with your validation rules:
130
+
131
+ ```toml
132
+ [tool.dfc]
133
+
134
+ [[tool.dfc.sections]]
135
+ order = 1
136
+ name = "summary"
137
+ type = "free_text"
138
+ admonition = "note"
139
+ prefix = "!!!"
140
+ required = true
141
+
142
+ [[tool.dfc.sections]]
143
+ order = 2
144
+ name = "params"
145
+ type = "list_name_and_type"
146
+ required = true
147
+
148
+ [[tool.dfc.sections]]
149
+ order = 3
150
+ name = "returns"
151
+ type = "list_name_and_type"
152
+ required = false
153
+
154
+ [[tool.dfc.sections]]
155
+ order = 4
156
+ name = "raises"
157
+ type = "list_type"
158
+ required = false
159
+ ```
160
+
161
+
162
+ ### Installation
163
+
164
+ You can install and use this package multiple ways by using any of your preferred methods: [`pip`][pip], [`pipenv`][pipenv], [`poetry`][poetry], or [`uv`][uv].
165
+
166
+
167
+ #### Using [`pip`][pip]:
168
+
169
+ 1. In your terminal, run:
170
+
171
+ ```sh
172
+ python3 -m pip install --upgrade pip
173
+ python3 -m pip install docstring-format-checker
174
+ ```
175
+
176
+ 2. Or, in your `requirements.txt` file, add:
177
+
178
+ ```txt
179
+ docstring-format-checker
180
+ ```
181
+
182
+ Then run:
183
+
184
+ ```sh
185
+ python3 -m pip install --upgrade pip
186
+ python3 -m pip install --requirement=requirements.txt
187
+ ```
188
+
189
+
190
+ #### Using [`pipenv`][pipenv]:
191
+
192
+ 1. Install using environment variables:
193
+
194
+ In your `Pipfile` file, add:
195
+
196
+ ```toml
197
+ [[source]]
198
+ url = "https://pypi.org/simple"
199
+ verify_ssl = false
200
+ name = "pypi"
201
+
202
+ [packages]
203
+ docstring-format-checker = "*"
204
+ ```
205
+
206
+ Then run:
207
+
208
+ ```sh
209
+ python3 -m pip install pipenv
210
+ python3 -m pipenv install --verbose --skip-lock --categories=root index=pypi docstring-format-checker
211
+ ```
212
+
213
+ 2. Or, in your `requirements.txt` file, add:
214
+
215
+ ```sh
216
+ docstring-format-checker
217
+ ```
218
+
219
+ Then run:
220
+
221
+ ```sh
222
+ python3 -m pipenv install --verbose --skip-lock --requirements=requirements.txt
223
+ ```
224
+
225
+ 3. Or just run this:
226
+
227
+ ```sh
228
+ python3 -m pipenv install --verbose --skip-lock docstring-format-checker
229
+ ```
230
+
231
+
232
+ #### Using [`poetry`][poetry]:
233
+
234
+ 1. In your `pyproject.toml` file, add:
235
+
236
+ ```toml
237
+ [project]
238
+ dependencies = [
239
+ "docstring-format-checker==0.*",
240
+ ]
241
+ ```
242
+
243
+ Then run:
244
+
245
+ ```sh
246
+ poetry sync
247
+ poetry install
248
+ ```
249
+
250
+ 2. Or just run this:
251
+
252
+ ```sh
253
+ poetry add "docstring-format-checker==0.*"
254
+ poetry sync
255
+ poetry install
256
+ ```
257
+
258
+
259
+ #### Using [`uv`][uv]:
260
+
261
+ 1. In your `pyproject.toml` file, add:
262
+
263
+ ```toml
264
+ [project]
265
+ dependencies = [
266
+ "docstring-format-checker==0.*",
267
+ ]
268
+ ```
269
+
270
+ Then run:
271
+
272
+ ```sh
273
+ uv sync
274
+ ```
275
+
276
+ 2. Or run this:
277
+
278
+ ```sh
279
+ uv add "docstring-format-checker==0.*"
280
+ uv sync
281
+ ```
282
+
283
+ 3. Or just run this:
284
+
285
+ ```sh
286
+ uv pip install "docstring-format-checker==0.*"
287
+ ```
288
+
289
+
290
+ ### Usage Examples
291
+
292
+
293
+ #### Basic Usage
294
+
295
+ ```bash
296
+ # Check a single Python file
297
+ dfc check src/my_module.py
298
+
299
+ # Check entire directory recursively
300
+ dfc check src/
301
+
302
+ # Check with verbose output
303
+ dfc check --verbose src/
304
+
305
+ # Generate example configuration file
306
+ dfc config-example > pyproject.toml
307
+ ```
308
+
309
+
310
+ #### Advanced Configuration
311
+
312
+ ```bash
313
+ # Use custom config file location
314
+ dfc check --config custom_config.toml src/
315
+
316
+ # Check specific function patterns
317
+ dfc check --include-pattern "**/api/*.py" src/
318
+
319
+ # Exclude test files
320
+ dfc check --exclude-pattern "**/test_*.py" src/
321
+ ```
322
+
323
+
324
+ #### Integration with CI/CD
325
+
326
+ ```yaml
327
+ # .github/workflows/docs.yml
328
+ name: Documentation Quality
329
+ on: [push, pull_request]
330
+
331
+ jobs:
332
+ docstring-check:
333
+ runs-on: ubuntu-latest
334
+ steps:
335
+ - uses: actions/checkout@v4
336
+ - uses: astral-sh/setup-uv@v3
337
+ - run: uv pip install docstring-format-checker
338
+ - run: dfc check src/
339
+ ```
340
+
341
+
342
+ ### Example Output
343
+
344
+ ```
345
+ 📋 Docstring Format Checker Results
346
+
347
+ ✅ src/utils/helpers.py
348
+ ❌ src/models/user.py
349
+ └── Function 'create_user' missing required section: 'params'
350
+ └── Function 'delete_user' missing required section: 'returns'
351
+
352
+ ❌ src/api/endpoints.py
353
+ └── Method 'UserAPI.get_user' invalid section format: 'raises'
354
+
355
+ 📊 Summary: 1/3 files passed (33.3%)
356
+ ```
357
+
358
+
359
+ ### Architecture
360
+
361
+ The tool follows a clean, modular architecture:
362
+
363
+ - **`core.py`** - `DocstringChecker` class with AST parsing and validation logic
364
+ - **`config.py`** - Configuration loading and `SectionConfig` management
365
+ - **`cli.py`** - Typer-based CLI with dual entry points
366
+ - **`utils/exceptions.py`** - Custom exception classes for structured error handling
367
+
368
+
369
+ ### Contribution
370
+
371
+ Check the [CONTRIBUTING.md][github-contributing] file or [Contributing][docs-contributing] page.
372
+
373
+
374
+ ### Development
375
+
376
+ 1. **Clone the repository:**
377
+
378
+ ```sh
379
+ git clone https://github.com/data-science-extensions/docstring-format-checker.git
380
+ cd docstring-format-checker
381
+ ```
382
+
383
+ 2. **Set up development environment:**
384
+
385
+ ```sh
386
+ uv sync --all-groups
387
+ ```
388
+
389
+ 3. **Run tests:**
390
+
391
+ ```sh
392
+ uv run pytest --config-file=pyproject.toml --cov-report=term-missing
393
+ ```
394
+
395
+ 4. **Run CLI locally:**
396
+
397
+ ```sh
398
+ uv run dfc check examples/example_code.py
399
+ ```
400
+
401
+
402
+ ### Build and Test
403
+
404
+ To ensure that the package is working as expected, please ensure that:
405
+
406
+ 1. You write your code as per [PEP8][pep8] requirements.
407
+ 2. You write a [UnitTest][unittest] for each function/feature you include.
408
+ 3. The [CodeCoverage][codecov] is 100%.
409
+ 4. All [UnitTests][pytest] are passing.
410
+ 5. [MyPy][mypy] is passing 100%.
411
+
412
+
413
+ #### Testing
414
+
415
+ - Run them all together:
416
+
417
+ ```sh
418
+ uv run pytest --config-file=pyproject.toml
419
+ ```
420
+
421
+ - Or run them individually:
422
+
423
+ - **Tests with Coverage:**
424
+ ```sh
425
+ uv run pytest --config-file=pyproject.toml --cov-report=term-missing
426
+ ```
427
+
428
+ - **Type Checking:**
429
+ ```sh
430
+ uv run mypy src/
431
+ ```
432
+
433
+ - **Code Formatting:**
434
+ ```sh
435
+ uv run black --check src/
436
+ ```
437
+
438
+ - **Linting:**
439
+ ```sh
440
+ uv run ruff check src/
441
+ ```
442
+
443
+
444
+ ### License
445
+
446
+ This project is licensed under the MIT License - see the [LICENSE][github-license] file for details.
447
+
448
+ [github-repo]: https://github.com/data-science-extensions/docstring-format-checker
449
+ [github-contributing]: https://github.com/data-science-extensions/docstring-format-checker/blob/main/CONTRIBUTING.md
450
+ [docs-contributing]: https://data-science-extensions.com/docstring-format-checker/latest/usage/contributing/
451
+ [github-release]: https://github.com/data-science-extensions/docstring-format-checker/releases
452
+ [github-ci]: https://github.com/data-science-extensions/docstring-format-checker/actions/workflows/ci.yml
453
+ [github-cd]: https://github.com/data-science-extensions/docstring-format-checker/actions/workflows/cd.yml
454
+ [github-license]: https://github.com/data-science-extensions/docstring-format-checker/blob/main/LICENSE
455
+ [codecov-repo]: https://codecov.io/gh/data-science-extensions/docstring-format-checker
456
+ [pypi]: https://pypi.org/project/docstring-format-checker
457
+ [docs]: https://data-science-extensions.com/docstring-format-checker
458
+ [pip]: https://pypi.org/project/pip
459
+ [pipenv]: https://github.com/pypa/pipenv
460
+ [poetry]: https://python-poetry.org
461
+ [uv]: https://docs.astral.sh/uv/
462
+ [pep8]: https://peps.python.org/pep-0008/
463
+ [unittest]: https://docs.python.org/3/library/unittest.html
464
+ [codecov]: https://codecov.io/
465
+ [pytest]: https://docs.pytest.org
466
+ [mypy]: http://www.mypy-lang.org/
467
+ [black]: https://black.readthedocs.io/
@@ -0,0 +1,10 @@
1
+ docstring_format_checker/__init__.py,sha256=b1b55d5d088d0f47c7ab9ab764e0ee082911aba152c1d372a2d1f6a96b343aff,552
2
+ docstring_format_checker/cli.py,sha256=b1f06dccaf06bf41afbc85ec7580bce636db1d59002bd89c8e54b4a86bcb0cc7,23572
3
+ docstring_format_checker/config.py,sha256=576af22f4792d5f2c1562cbf398c3e8313ad2ae860b498f96ad1fdbaa227cdcf,12086
4
+ docstring_format_checker/core.py,sha256=12716f465f99d3fa9d39652f01095f047734347e13fe72ced07173e9266b84ed,26291
5
+ docstring_format_checker/utils/__init__.py,sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855,0
6
+ docstring_format_checker/utils/exceptions.py,sha256=b6c5b6f0f8df41a13d3506e56595436838a3411e0ab01581e73b9ccab1b8df6e,804
7
+ docstring_format_checker-0.1.0.dist-info/WHEEL,sha256=ab6157bc637547491fb4567cd7ddf26b04d63382916ca16c29a5c8e94c9c9ef7,79
8
+ docstring_format_checker-0.1.0.dist-info/entry_points.txt,sha256=07f2adf44467d5d217e6106fc0a0de650a57aa8d5a09b461b2e17718e9b5a428,134
9
+ docstring_format_checker-0.1.0.dist-info/METADATA,sha256=70dff3114e69a955b6533b41f3455e996e9e67147524cb1012c74ff888f8397a,14505
10
+ docstring_format_checker-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.7.22
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ dfc = docstring_format_checker.cli:entry_point
3
+ docstring-format-checker = docstring_format_checker.cli:entry_point
4
+