docstring-format-checker 1.11.2__tar.gz → 1.11.4__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.
- {docstring_format_checker-1.11.2 → docstring_format_checker-1.11.4}/PKG-INFO +121 -70
- {docstring_format_checker-1.11.2 → docstring_format_checker-1.11.4}/README.md +120 -69
- {docstring_format_checker-1.11.2 → docstring_format_checker-1.11.4}/pyproject.toml +1 -1
- {docstring_format_checker-1.11.2 → docstring_format_checker-1.11.4}/src/docstring_format_checker/cli.py +0 -16
- {docstring_format_checker-1.11.2 → docstring_format_checker-1.11.4}/src/docstring_format_checker/config.py +83 -13
- {docstring_format_checker-1.11.2 → docstring_format_checker-1.11.4}/src/docstring_format_checker/__init__.py +0 -0
- {docstring_format_checker-1.11.2 → docstring_format_checker-1.11.4}/src/docstring_format_checker/core.py +0 -0
- {docstring_format_checker-1.11.2 → docstring_format_checker-1.11.4}/src/docstring_format_checker/utils/__init__.py +0 -0
- {docstring_format_checker-1.11.2 → docstring_format_checker-1.11.4}/src/docstring_format_checker/utils/exceptions.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: docstring-format-checker
|
|
3
|
-
Version: 1.11.
|
|
3
|
+
Version: 1.11.4
|
|
4
4
|
Summary: A CLI tool to check and validate Python docstring formatting and completeness
|
|
5
5
|
Author: Chris Mahoney
|
|
6
6
|
Author-email: Chris Mahoney <docstring-format-checker@data-science-extensions.com>
|
|
@@ -72,7 +72,7 @@ Description-Content-Type: text/markdown
|
|
|
72
72
|
</p>
|
|
73
73
|
|
|
74
74
|
|
|
75
|
-
### Introduction
|
|
75
|
+
### 📝 Introduction
|
|
76
76
|
|
|
77
77
|
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.
|
|
78
78
|
|
|
@@ -87,26 +87,26 @@ A powerful Python CLI tool that validates docstring formatting and completeness
|
|
|
87
87
|
- 🛡️ **100% test coverage** - Thoroughly tested and reliable
|
|
88
88
|
|
|
89
89
|
|
|
90
|
-
### Quick Start
|
|
90
|
+
### 🚀 Quick Start
|
|
91
91
|
|
|
92
92
|
```bash
|
|
93
93
|
# Install
|
|
94
94
|
uv add docstring-format-checker
|
|
95
95
|
|
|
96
96
|
# Check a single file
|
|
97
|
-
dfc check my_module.py
|
|
97
|
+
dfc --check my_module.py
|
|
98
98
|
|
|
99
99
|
# Check entire directory
|
|
100
|
-
dfc check src/
|
|
100
|
+
dfc --check src/
|
|
101
101
|
|
|
102
102
|
# Generate example configuration
|
|
103
|
-
dfc config
|
|
103
|
+
dfc --example=config
|
|
104
104
|
```
|
|
105
105
|
|
|
106
106
|
|
|
107
|
-
### Key URLs
|
|
107
|
+
### 🔗 Key URLs
|
|
108
108
|
|
|
109
|
-
For reference, these
|
|
109
|
+
For reference, these URLs are used:
|
|
110
110
|
|
|
111
111
|
| Type | Source | URL |
|
|
112
112
|
| -------------- | ------ | ---------------------------------------------------------------------- |
|
|
@@ -115,7 +115,7 @@ For reference, these URL's are used:
|
|
|
115
115
|
| Package Docs | Pages | https://data-science-extensions.com/toolboxes/docstring-format-checker |
|
|
116
116
|
|
|
117
117
|
|
|
118
|
-
### Section Types
|
|
118
|
+
### 📂 Section Types
|
|
119
119
|
|
|
120
120
|
Configure validation for four types of docstring sections:
|
|
121
121
|
|
|
@@ -127,7 +127,7 @@ Configure validation for four types of docstring sections:
|
|
|
127
127
|
| `list_name_and_type` | Name and type lists | Parameters, returns with types |
|
|
128
128
|
|
|
129
129
|
|
|
130
|
-
### Configuration
|
|
130
|
+
### ⚙️ Configuration
|
|
131
131
|
|
|
132
132
|
Create a `pyproject.toml` with your validation rules. The `order` attribute is optional; sections without an order (like "deprecation warning") can appear anywhere in the docstring.
|
|
133
133
|
|
|
@@ -168,26 +168,27 @@ required = false
|
|
|
168
168
|
Or like this in a single block:
|
|
169
169
|
|
|
170
170
|
```toml
|
|
171
|
-
[tool.dfc]
|
|
172
|
-
# or [tool.docstring-format-checker]
|
|
173
|
-
allow_undefined_sections = false
|
|
174
|
-
require_docstrings = true
|
|
175
|
-
check_private = true
|
|
176
|
-
validate_param_types = true
|
|
177
|
-
optional_style = "validate" # "silent", "validate", or "strict"
|
|
178
|
-
sections = [
|
|
179
|
-
{ order = 1, name = "summary", type = "free_text", required = true, admonition = "note", prefix = "!!!" },
|
|
180
|
-
{ order = 2, name = "details", type = "free_text", required = false, admonition = "abstract", prefix = "???+" },
|
|
181
|
-
{ order = 3, name = "params", type = "list_name_and_type", required = false },
|
|
182
|
-
{ order = 4, name = "raises", type = "list_type", required = false },
|
|
183
|
-
{ order = 5, name = "returns", type = "list_name_and_type", required = false },
|
|
184
|
-
{ order = 6, name = "yields", type = "list_type", required = false },
|
|
185
|
-
{ order = 7, name = "examples", type = "free_text", required = false, admonition = "example", prefix = "???+" },
|
|
186
|
-
{ order = 8, name = "notes", type = "free_text", required = false, admonition = "note", prefix = "???" },
|
|
171
|
+
[tool.dfc]
|
|
172
|
+
# or [tool.docstring-format-checker]
|
|
173
|
+
allow_undefined_sections = false
|
|
174
|
+
require_docstrings = true
|
|
175
|
+
check_private = true
|
|
176
|
+
validate_param_types = true
|
|
177
|
+
optional_style = "validate" # "silent", "validate", or "strict"
|
|
178
|
+
sections = [
|
|
179
|
+
{ order = 1, name = "summary", type = "free_text", required = true, admonition = "note", prefix = "!!!" },
|
|
180
|
+
{ order = 2, name = "details", type = "free_text", required = false, admonition = "abstract", prefix = "???+" },
|
|
181
|
+
{ order = 3, name = "params", type = "list_name_and_type", required = false },
|
|
182
|
+
{ order = 4, name = "raises", type = "list_type", required = false },
|
|
183
|
+
{ order = 5, name = "returns", type = "list_name_and_type", required = false },
|
|
184
|
+
{ order = 6, name = "yields", type = "list_type", required = false },
|
|
185
|
+
{ order = 7, name = "examples", type = "free_text", required = false, admonition = "example", prefix = "???+" },
|
|
186
|
+
{ order = 8, name = "notes", type = "free_text", required = false, admonition = "note", prefix = "???" },
|
|
187
187
|
]
|
|
188
188
|
```
|
|
189
189
|
|
|
190
|
-
|
|
190
|
+
|
|
191
|
+
### 📥 Installation
|
|
191
192
|
|
|
192
193
|
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].
|
|
193
194
|
|
|
@@ -264,7 +265,7 @@ You can install and use this package multiple ways by using any of your preferre
|
|
|
264
265
|
```toml
|
|
265
266
|
[project]
|
|
266
267
|
dependencies = [
|
|
267
|
-
"docstring-format-checker==
|
|
268
|
+
"docstring-format-checker==1.*",
|
|
268
269
|
]
|
|
269
270
|
```
|
|
270
271
|
|
|
@@ -278,7 +279,7 @@ You can install and use this package multiple ways by using any of your preferre
|
|
|
278
279
|
2. Or just run this:
|
|
279
280
|
|
|
280
281
|
```sh
|
|
281
|
-
poetry add "docstring-format-checker==
|
|
282
|
+
poetry add "docstring-format-checker==1.*"
|
|
282
283
|
poetry sync
|
|
283
284
|
poetry install
|
|
284
285
|
```
|
|
@@ -291,7 +292,7 @@ You can install and use this package multiple ways by using any of your preferre
|
|
|
291
292
|
```toml
|
|
292
293
|
[project]
|
|
293
294
|
dependencies = [
|
|
294
|
-
"docstring-format-checker==
|
|
295
|
+
"docstring-format-checker==1.*",
|
|
295
296
|
]
|
|
296
297
|
```
|
|
297
298
|
|
|
@@ -304,34 +305,34 @@ You can install and use this package multiple ways by using any of your preferre
|
|
|
304
305
|
2. Or run this:
|
|
305
306
|
|
|
306
307
|
```sh
|
|
307
|
-
uv add "docstring-format-checker==
|
|
308
|
+
uv add "docstring-format-checker==1.*"
|
|
308
309
|
uv sync
|
|
309
310
|
```
|
|
310
311
|
|
|
311
312
|
3. Or just run this:
|
|
312
313
|
|
|
313
314
|
```sh
|
|
314
|
-
uv pip install "docstring-format-checker==
|
|
315
|
+
uv pip install "docstring-format-checker==1.*"
|
|
315
316
|
```
|
|
316
317
|
|
|
317
318
|
|
|
318
|
-
### Usage Examples
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
#### Basic Usage
|
|
319
|
+
### 💡 Usage Examples
|
|
322
320
|
|
|
323
321
|
```bash
|
|
324
322
|
# Check a single Python file
|
|
325
|
-
dfc check src/my_module.py
|
|
323
|
+
dfc --check src/my_module.py
|
|
324
|
+
|
|
325
|
+
# Check multiple Python files
|
|
326
|
+
dfc file1.py file2.py
|
|
326
327
|
|
|
327
328
|
# Check entire directory recursively
|
|
328
|
-
dfc check src/
|
|
329
|
+
dfc --check src/
|
|
329
330
|
|
|
330
|
-
# Check with
|
|
331
|
-
dfc
|
|
331
|
+
# Check with table output format
|
|
332
|
+
dfc --output=table src/
|
|
332
333
|
|
|
333
334
|
# Generate example configuration file
|
|
334
|
-
dfc config
|
|
335
|
+
dfc --example=config > pyproject.toml
|
|
335
336
|
```
|
|
336
337
|
|
|
337
338
|
|
|
@@ -339,13 +340,16 @@ dfc config-example > pyproject.toml
|
|
|
339
340
|
|
|
340
341
|
```bash
|
|
341
342
|
# Use custom config file location
|
|
342
|
-
dfc
|
|
343
|
+
dfc --config=custom_config.toml src/
|
|
344
|
+
|
|
345
|
+
# Exclude specific files using glob patterns
|
|
346
|
+
dfc src/ --exclude "**/test_*.py"
|
|
343
347
|
|
|
344
|
-
#
|
|
345
|
-
dfc check
|
|
348
|
+
# Stop on first failure (CI environments)
|
|
349
|
+
dfc --check src/
|
|
346
350
|
|
|
347
|
-
#
|
|
348
|
-
dfc
|
|
351
|
+
# Suppress non-error output
|
|
352
|
+
dfc --quiet src/
|
|
349
353
|
```
|
|
350
354
|
|
|
351
355
|
|
|
@@ -363,43 +367,90 @@ jobs:
|
|
|
363
367
|
- uses: actions/checkout@v4
|
|
364
368
|
- uses: astral-sh/setup-uv@v3
|
|
365
369
|
- run: uv pip install docstring-format-checker
|
|
366
|
-
- run: dfc check src/
|
|
370
|
+
- run: dfc --check src/
|
|
367
371
|
```
|
|
368
372
|
|
|
369
373
|
|
|
370
|
-
|
|
374
|
+
#### Integration with Pre-commit
|
|
371
375
|
|
|
376
|
+
```yaml
|
|
377
|
+
# .pre-commit-config.yaml
|
|
378
|
+
repos:
|
|
379
|
+
- repo: https://github.com/data-science-extensions/docstring-format-checker
|
|
380
|
+
rev: "v1.11.3"
|
|
381
|
+
hooks:
|
|
382
|
+
- id: docstring-format-checker
|
|
383
|
+
name: Docstring Format Checker
|
|
384
|
+
entry: dfc --check
|
|
372
385
|
```
|
|
373
|
-
📋 Docstring Format Checker Results
|
|
374
386
|
|
|
375
|
-
✅ src/utils/helpers.py
|
|
376
|
-
❌ src/models/user.py
|
|
377
|
-
└── Function 'create_user' missing required section: 'params'
|
|
378
|
-
└── Function 'delete_user' missing required section: 'returns'
|
|
379
387
|
|
|
380
|
-
|
|
381
|
-
|
|
388
|
+
### 📋 Example Output
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
#### Standard List Output
|
|
392
|
+
|
|
393
|
+
The option `output=list` is the default:
|
|
394
|
+
|
|
395
|
+
```sh
|
|
396
|
+
dfc --check src/models/user.py
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
Or you can declare it explicitly:
|
|
400
|
+
|
|
401
|
+
```sh
|
|
402
|
+
dfc --check --output=list src/models/user.py
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
Which returns:
|
|
406
|
+
|
|
407
|
+
```text
|
|
408
|
+
src/models/user.py
|
|
409
|
+
Line 12 - function 'create_user':
|
|
410
|
+
- Missing required section: 'params'
|
|
411
|
+
Line 45 - function 'delete_user':
|
|
412
|
+
- Missing required section: 'returns'
|
|
413
|
+
|
|
414
|
+
Found 2 error(s) in 2 functions over 1 file
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
#### Table Output Format
|
|
419
|
+
|
|
420
|
+
```sh
|
|
421
|
+
dfc --check --output=table src/models/user.py
|
|
422
|
+
```
|
|
382
423
|
|
|
383
|
-
|
|
424
|
+
```text
|
|
425
|
+
┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
|
426
|
+
┃ File ┃ Line ┃ Item ┃ Type ┃ Error ┃
|
|
427
|
+
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
|
|
428
|
+
│ src/models/user.py │ 12 │ create_user │ function │ - Missing required section: │
|
|
429
|
+
│ │ │ │ │ 'params'. │
|
|
430
|
+
│ │ 45 │ delete_user │ function │ - Missing required section: │
|
|
431
|
+
│ │ │ │ │ 'returns'. │
|
|
432
|
+
└────────────────────┴──────┴─────────────┴──────────┴──────────────────────────────────┘
|
|
433
|
+
|
|
434
|
+
Found 2 error(s) in 2 functions over 1 file
|
|
384
435
|
```
|
|
385
436
|
|
|
386
437
|
|
|
387
|
-
### Architecture
|
|
438
|
+
### 🏗️ Architecture
|
|
388
439
|
|
|
389
440
|
The tool follows a clean, modular architecture:
|
|
390
441
|
|
|
391
|
-
- **`core.py`** - `DocstringChecker` class with AST parsing and validation logic
|
|
392
|
-
- **`config.py`** - Configuration loading and `SectionConfig` management
|
|
442
|
+
- **`core.py`** - `DocstringChecker()` class with AST parsing and validation logic
|
|
443
|
+
- **`config.py`** - Configuration loading and `SectionConfig()` management
|
|
393
444
|
- **`cli.py`** - Typer-based CLI with dual entry points
|
|
394
445
|
- **`utils/exceptions.py`** - Custom exception classes for structured error handling
|
|
395
446
|
|
|
396
447
|
|
|
397
|
-
### Contribution
|
|
448
|
+
### 🤝 Contribution
|
|
398
449
|
|
|
399
450
|
Check the [CONTRIBUTING.md][github-contributing] file or [Contributing][docs-contributing] page.
|
|
400
451
|
|
|
401
452
|
|
|
402
|
-
### Development
|
|
453
|
+
### 🛠️ Development
|
|
403
454
|
|
|
404
455
|
1. **Clone the repository:**
|
|
405
456
|
|
|
@@ -423,19 +474,19 @@ Check the [CONTRIBUTING.md][github-contributing] file or [Contributing][docs-con
|
|
|
423
474
|
4. **Run CLI locally:**
|
|
424
475
|
|
|
425
476
|
```sh
|
|
426
|
-
uv run dfc check examples/example_code.py
|
|
477
|
+
uv run dfc --check examples/example_code.py
|
|
427
478
|
```
|
|
428
479
|
|
|
429
480
|
|
|
430
|
-
### Build and Test
|
|
481
|
+
### 🧪 Build and Test
|
|
431
482
|
|
|
432
|
-
To ensure that the package
|
|
483
|
+
To ensure that the package works as expected, ensure that:
|
|
433
484
|
|
|
434
|
-
1.
|
|
435
|
-
2.
|
|
436
|
-
3.
|
|
437
|
-
4.
|
|
438
|
-
5. [MyPy][mypy]
|
|
485
|
+
1. Write code in accordance with [PEP8][pep8] requirements.
|
|
486
|
+
2. Write a [UnitTest][unittest] for each function or feature included.
|
|
487
|
+
3. Maintain [CodeCoverage][codecov] at 100%.
|
|
488
|
+
4. Ensure all [UnitTests][pytest] pass.
|
|
489
|
+
5. Ensure [MyPy][mypy] passes 100%.
|
|
439
490
|
|
|
440
491
|
|
|
441
492
|
#### Testing
|
|
@@ -469,7 +520,7 @@ To ensure that the package is working as expected, please ensure that:
|
|
|
469
520
|
```
|
|
470
521
|
|
|
471
522
|
|
|
472
|
-
### License
|
|
523
|
+
### 📄 License
|
|
473
524
|
|
|
474
525
|
This project is licensed under the MIT License - see the [LICENSE][github-license] file for details.
|
|
475
526
|
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
</p>
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
### Introduction
|
|
38
|
+
### 📝 Introduction
|
|
39
39
|
|
|
40
40
|
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.
|
|
41
41
|
|
|
@@ -50,26 +50,26 @@ A powerful Python CLI tool that validates docstring formatting and completeness
|
|
|
50
50
|
- 🛡️ **100% test coverage** - Thoroughly tested and reliable
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
### Quick Start
|
|
53
|
+
### 🚀 Quick Start
|
|
54
54
|
|
|
55
55
|
```bash
|
|
56
56
|
# Install
|
|
57
57
|
uv add docstring-format-checker
|
|
58
58
|
|
|
59
59
|
# Check a single file
|
|
60
|
-
dfc check my_module.py
|
|
60
|
+
dfc --check my_module.py
|
|
61
61
|
|
|
62
62
|
# Check entire directory
|
|
63
|
-
dfc check src/
|
|
63
|
+
dfc --check src/
|
|
64
64
|
|
|
65
65
|
# Generate example configuration
|
|
66
|
-
dfc config
|
|
66
|
+
dfc --example=config
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
### Key URLs
|
|
70
|
+
### 🔗 Key URLs
|
|
71
71
|
|
|
72
|
-
For reference, these
|
|
72
|
+
For reference, these URLs are used:
|
|
73
73
|
|
|
74
74
|
| Type | Source | URL |
|
|
75
75
|
| -------------- | ------ | ---------------------------------------------------------------------- |
|
|
@@ -78,7 +78,7 @@ For reference, these URL's are used:
|
|
|
78
78
|
| Package Docs | Pages | https://data-science-extensions.com/toolboxes/docstring-format-checker |
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
### Section Types
|
|
81
|
+
### 📂 Section Types
|
|
82
82
|
|
|
83
83
|
Configure validation for four types of docstring sections:
|
|
84
84
|
|
|
@@ -90,7 +90,7 @@ Configure validation for four types of docstring sections:
|
|
|
90
90
|
| `list_name_and_type` | Name and type lists | Parameters, returns with types |
|
|
91
91
|
|
|
92
92
|
|
|
93
|
-
### Configuration
|
|
93
|
+
### ⚙️ Configuration
|
|
94
94
|
|
|
95
95
|
Create a `pyproject.toml` with your validation rules. The `order` attribute is optional; sections without an order (like "deprecation warning") can appear anywhere in the docstring.
|
|
96
96
|
|
|
@@ -131,26 +131,27 @@ required = false
|
|
|
131
131
|
Or like this in a single block:
|
|
132
132
|
|
|
133
133
|
```toml
|
|
134
|
-
[tool.dfc]
|
|
135
|
-
# or [tool.docstring-format-checker]
|
|
136
|
-
allow_undefined_sections = false
|
|
137
|
-
require_docstrings = true
|
|
138
|
-
check_private = true
|
|
139
|
-
validate_param_types = true
|
|
140
|
-
optional_style = "validate" # "silent", "validate", or "strict"
|
|
141
|
-
sections = [
|
|
142
|
-
{ order = 1, name = "summary", type = "free_text", required = true, admonition = "note", prefix = "!!!" },
|
|
143
|
-
{ order = 2, name = "details", type = "free_text", required = false, admonition = "abstract", prefix = "???+" },
|
|
144
|
-
{ order = 3, name = "params", type = "list_name_and_type", required = false },
|
|
145
|
-
{ order = 4, name = "raises", type = "list_type", required = false },
|
|
146
|
-
{ order = 5, name = "returns", type = "list_name_and_type", required = false },
|
|
147
|
-
{ order = 6, name = "yields", type = "list_type", required = false },
|
|
148
|
-
{ order = 7, name = "examples", type = "free_text", required = false, admonition = "example", prefix = "???+" },
|
|
149
|
-
{ order = 8, name = "notes", type = "free_text", required = false, admonition = "note", prefix = "???" },
|
|
134
|
+
[tool.dfc]
|
|
135
|
+
# or [tool.docstring-format-checker]
|
|
136
|
+
allow_undefined_sections = false
|
|
137
|
+
require_docstrings = true
|
|
138
|
+
check_private = true
|
|
139
|
+
validate_param_types = true
|
|
140
|
+
optional_style = "validate" # "silent", "validate", or "strict"
|
|
141
|
+
sections = [
|
|
142
|
+
{ order = 1, name = "summary", type = "free_text", required = true, admonition = "note", prefix = "!!!" },
|
|
143
|
+
{ order = 2, name = "details", type = "free_text", required = false, admonition = "abstract", prefix = "???+" },
|
|
144
|
+
{ order = 3, name = "params", type = "list_name_and_type", required = false },
|
|
145
|
+
{ order = 4, name = "raises", type = "list_type", required = false },
|
|
146
|
+
{ order = 5, name = "returns", type = "list_name_and_type", required = false },
|
|
147
|
+
{ order = 6, name = "yields", type = "list_type", required = false },
|
|
148
|
+
{ order = 7, name = "examples", type = "free_text", required = false, admonition = "example", prefix = "???+" },
|
|
149
|
+
{ order = 8, name = "notes", type = "free_text", required = false, admonition = "note", prefix = "???" },
|
|
150
150
|
]
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
|
|
154
|
+
### 📥 Installation
|
|
154
155
|
|
|
155
156
|
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].
|
|
156
157
|
|
|
@@ -227,7 +228,7 @@ You can install and use this package multiple ways by using any of your preferre
|
|
|
227
228
|
```toml
|
|
228
229
|
[project]
|
|
229
230
|
dependencies = [
|
|
230
|
-
"docstring-format-checker==
|
|
231
|
+
"docstring-format-checker==1.*",
|
|
231
232
|
]
|
|
232
233
|
```
|
|
233
234
|
|
|
@@ -241,7 +242,7 @@ You can install and use this package multiple ways by using any of your preferre
|
|
|
241
242
|
2. Or just run this:
|
|
242
243
|
|
|
243
244
|
```sh
|
|
244
|
-
poetry add "docstring-format-checker==
|
|
245
|
+
poetry add "docstring-format-checker==1.*"
|
|
245
246
|
poetry sync
|
|
246
247
|
poetry install
|
|
247
248
|
```
|
|
@@ -254,7 +255,7 @@ You can install and use this package multiple ways by using any of your preferre
|
|
|
254
255
|
```toml
|
|
255
256
|
[project]
|
|
256
257
|
dependencies = [
|
|
257
|
-
"docstring-format-checker==
|
|
258
|
+
"docstring-format-checker==1.*",
|
|
258
259
|
]
|
|
259
260
|
```
|
|
260
261
|
|
|
@@ -267,34 +268,34 @@ You can install and use this package multiple ways by using any of your preferre
|
|
|
267
268
|
2. Or run this:
|
|
268
269
|
|
|
269
270
|
```sh
|
|
270
|
-
uv add "docstring-format-checker==
|
|
271
|
+
uv add "docstring-format-checker==1.*"
|
|
271
272
|
uv sync
|
|
272
273
|
```
|
|
273
274
|
|
|
274
275
|
3. Or just run this:
|
|
275
276
|
|
|
276
277
|
```sh
|
|
277
|
-
uv pip install "docstring-format-checker==
|
|
278
|
+
uv pip install "docstring-format-checker==1.*"
|
|
278
279
|
```
|
|
279
280
|
|
|
280
281
|
|
|
281
|
-
### Usage Examples
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
#### Basic Usage
|
|
282
|
+
### 💡 Usage Examples
|
|
285
283
|
|
|
286
284
|
```bash
|
|
287
285
|
# Check a single Python file
|
|
288
|
-
dfc check src/my_module.py
|
|
286
|
+
dfc --check src/my_module.py
|
|
287
|
+
|
|
288
|
+
# Check multiple Python files
|
|
289
|
+
dfc file1.py file2.py
|
|
289
290
|
|
|
290
291
|
# Check entire directory recursively
|
|
291
|
-
dfc check src/
|
|
292
|
+
dfc --check src/
|
|
292
293
|
|
|
293
|
-
# Check with
|
|
294
|
-
dfc
|
|
294
|
+
# Check with table output format
|
|
295
|
+
dfc --output=table src/
|
|
295
296
|
|
|
296
297
|
# Generate example configuration file
|
|
297
|
-
dfc config
|
|
298
|
+
dfc --example=config > pyproject.toml
|
|
298
299
|
```
|
|
299
300
|
|
|
300
301
|
|
|
@@ -302,13 +303,16 @@ dfc config-example > pyproject.toml
|
|
|
302
303
|
|
|
303
304
|
```bash
|
|
304
305
|
# Use custom config file location
|
|
305
|
-
dfc
|
|
306
|
+
dfc --config=custom_config.toml src/
|
|
307
|
+
|
|
308
|
+
# Exclude specific files using glob patterns
|
|
309
|
+
dfc src/ --exclude "**/test_*.py"
|
|
306
310
|
|
|
307
|
-
#
|
|
308
|
-
dfc check
|
|
311
|
+
# Stop on first failure (CI environments)
|
|
312
|
+
dfc --check src/
|
|
309
313
|
|
|
310
|
-
#
|
|
311
|
-
dfc
|
|
314
|
+
# Suppress non-error output
|
|
315
|
+
dfc --quiet src/
|
|
312
316
|
```
|
|
313
317
|
|
|
314
318
|
|
|
@@ -326,43 +330,90 @@ jobs:
|
|
|
326
330
|
- uses: actions/checkout@v4
|
|
327
331
|
- uses: astral-sh/setup-uv@v3
|
|
328
332
|
- run: uv pip install docstring-format-checker
|
|
329
|
-
- run: dfc check src/
|
|
333
|
+
- run: dfc --check src/
|
|
330
334
|
```
|
|
331
335
|
|
|
332
336
|
|
|
333
|
-
|
|
337
|
+
#### Integration with Pre-commit
|
|
334
338
|
|
|
339
|
+
```yaml
|
|
340
|
+
# .pre-commit-config.yaml
|
|
341
|
+
repos:
|
|
342
|
+
- repo: https://github.com/data-science-extensions/docstring-format-checker
|
|
343
|
+
rev: "v1.11.3"
|
|
344
|
+
hooks:
|
|
345
|
+
- id: docstring-format-checker
|
|
346
|
+
name: Docstring Format Checker
|
|
347
|
+
entry: dfc --check
|
|
335
348
|
```
|
|
336
|
-
📋 Docstring Format Checker Results
|
|
337
349
|
|
|
338
|
-
✅ src/utils/helpers.py
|
|
339
|
-
❌ src/models/user.py
|
|
340
|
-
└── Function 'create_user' missing required section: 'params'
|
|
341
|
-
└── Function 'delete_user' missing required section: 'returns'
|
|
342
350
|
|
|
343
|
-
|
|
344
|
-
|
|
351
|
+
### 📋 Example Output
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
#### Standard List Output
|
|
355
|
+
|
|
356
|
+
The option `output=list` is the default:
|
|
357
|
+
|
|
358
|
+
```sh
|
|
359
|
+
dfc --check src/models/user.py
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Or you can declare it explicitly:
|
|
363
|
+
|
|
364
|
+
```sh
|
|
365
|
+
dfc --check --output=list src/models/user.py
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
Which returns:
|
|
369
|
+
|
|
370
|
+
```text
|
|
371
|
+
src/models/user.py
|
|
372
|
+
Line 12 - function 'create_user':
|
|
373
|
+
- Missing required section: 'params'
|
|
374
|
+
Line 45 - function 'delete_user':
|
|
375
|
+
- Missing required section: 'returns'
|
|
376
|
+
|
|
377
|
+
Found 2 error(s) in 2 functions over 1 file
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
#### Table Output Format
|
|
382
|
+
|
|
383
|
+
```sh
|
|
384
|
+
dfc --check --output=table src/models/user.py
|
|
385
|
+
```
|
|
345
386
|
|
|
346
|
-
|
|
387
|
+
```text
|
|
388
|
+
┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
|
389
|
+
┃ File ┃ Line ┃ Item ┃ Type ┃ Error ┃
|
|
390
|
+
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
|
|
391
|
+
│ src/models/user.py │ 12 │ create_user │ function │ - Missing required section: │
|
|
392
|
+
│ │ │ │ │ 'params'. │
|
|
393
|
+
│ │ 45 │ delete_user │ function │ - Missing required section: │
|
|
394
|
+
│ │ │ │ │ 'returns'. │
|
|
395
|
+
└────────────────────┴──────┴─────────────┴──────────┴──────────────────────────────────┘
|
|
396
|
+
|
|
397
|
+
Found 2 error(s) in 2 functions over 1 file
|
|
347
398
|
```
|
|
348
399
|
|
|
349
400
|
|
|
350
|
-
### Architecture
|
|
401
|
+
### 🏗️ Architecture
|
|
351
402
|
|
|
352
403
|
The tool follows a clean, modular architecture:
|
|
353
404
|
|
|
354
|
-
- **`core.py`** - `DocstringChecker` class with AST parsing and validation logic
|
|
355
|
-
- **`config.py`** - Configuration loading and `SectionConfig` management
|
|
405
|
+
- **`core.py`** - `DocstringChecker()` class with AST parsing and validation logic
|
|
406
|
+
- **`config.py`** - Configuration loading and `SectionConfig()` management
|
|
356
407
|
- **`cli.py`** - Typer-based CLI with dual entry points
|
|
357
408
|
- **`utils/exceptions.py`** - Custom exception classes for structured error handling
|
|
358
409
|
|
|
359
410
|
|
|
360
|
-
### Contribution
|
|
411
|
+
### 🤝 Contribution
|
|
361
412
|
|
|
362
413
|
Check the [CONTRIBUTING.md][github-contributing] file or [Contributing][docs-contributing] page.
|
|
363
414
|
|
|
364
415
|
|
|
365
|
-
### Development
|
|
416
|
+
### 🛠️ Development
|
|
366
417
|
|
|
367
418
|
1. **Clone the repository:**
|
|
368
419
|
|
|
@@ -386,19 +437,19 @@ Check the [CONTRIBUTING.md][github-contributing] file or [Contributing][docs-con
|
|
|
386
437
|
4. **Run CLI locally:**
|
|
387
438
|
|
|
388
439
|
```sh
|
|
389
|
-
uv run dfc check examples/example_code.py
|
|
440
|
+
uv run dfc --check examples/example_code.py
|
|
390
441
|
```
|
|
391
442
|
|
|
392
443
|
|
|
393
|
-
### Build and Test
|
|
444
|
+
### 🧪 Build and Test
|
|
394
445
|
|
|
395
|
-
To ensure that the package
|
|
446
|
+
To ensure that the package works as expected, ensure that:
|
|
396
447
|
|
|
397
|
-
1.
|
|
398
|
-
2.
|
|
399
|
-
3.
|
|
400
|
-
4.
|
|
401
|
-
5. [MyPy][mypy]
|
|
448
|
+
1. Write code in accordance with [PEP8][pep8] requirements.
|
|
449
|
+
2. Write a [UnitTest][unittest] for each function or feature included.
|
|
450
|
+
3. Maintain [CodeCoverage][codecov] at 100%.
|
|
451
|
+
4. Ensure all [UnitTests][pytest] pass.
|
|
452
|
+
5. Ensure [MyPy][mypy] passes 100%.
|
|
402
453
|
|
|
403
454
|
|
|
404
455
|
#### Testing
|
|
@@ -432,7 +483,7 @@ To ensure that the package is working as expected, please ensure that:
|
|
|
432
483
|
```
|
|
433
484
|
|
|
434
485
|
|
|
435
|
-
### License
|
|
486
|
+
### 📄 License
|
|
436
487
|
|
|
437
488
|
This project is licensed under the MIT License - see the [LICENSE][github-license] file for details.
|
|
438
489
|
|
|
@@ -199,14 +199,6 @@ def _show_usage_examples_callback() -> None:
|
|
|
199
199
|
!!! note "Summary"
|
|
200
200
|
Show examples and exit.
|
|
201
201
|
|
|
202
|
-
Params:
|
|
203
|
-
ctx (Context):
|
|
204
|
-
The context object.
|
|
205
|
-
param (CallbackParam):
|
|
206
|
-
The parameter object.
|
|
207
|
-
value (bool):
|
|
208
|
-
The boolean value indicating if the flag was set.
|
|
209
|
-
|
|
210
202
|
Returns:
|
|
211
203
|
(None):
|
|
212
204
|
Nothing is returned.
|
|
@@ -248,14 +240,6 @@ def _show_config_example_callback() -> None:
|
|
|
248
240
|
!!! note "Summary"
|
|
249
241
|
Show configuration example and exit.
|
|
250
242
|
|
|
251
|
-
Params:
|
|
252
|
-
ctx (Context):
|
|
253
|
-
The context object.
|
|
254
|
-
param (CallbackParam):
|
|
255
|
-
The parameter object.
|
|
256
|
-
value (bool):
|
|
257
|
-
The boolean value indicating if the flag was set.
|
|
258
|
-
|
|
259
243
|
Returns:
|
|
260
244
|
(None):
|
|
261
245
|
Nothing is returned.
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
|
|
45
45
|
# ## Python StdLib Imports ----
|
|
46
46
|
import sys
|
|
47
|
-
from dataclasses import dataclass
|
|
47
|
+
from dataclasses import dataclass, field
|
|
48
48
|
from pathlib import Path
|
|
49
49
|
from typing import Any, Literal, Optional, Union
|
|
50
50
|
|
|
@@ -111,11 +111,41 @@ class GlobalConfig:
|
|
|
111
111
|
Global configuration for docstring checking behavior.
|
|
112
112
|
"""
|
|
113
113
|
|
|
114
|
-
allow_undefined_sections: bool =
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
allow_undefined_sections: bool = field(
|
|
115
|
+
default=False,
|
|
116
|
+
metadata={
|
|
117
|
+
"title": "Allow Undefined Sections",
|
|
118
|
+
"description": "Allow sections not defined in the configuration.",
|
|
119
|
+
},
|
|
120
|
+
)
|
|
121
|
+
require_docstrings: bool = field(
|
|
122
|
+
default=True,
|
|
123
|
+
metadata={
|
|
124
|
+
"title": "Require Docstrings",
|
|
125
|
+
"description": "Require docstrings for all functions/methods.",
|
|
126
|
+
},
|
|
127
|
+
)
|
|
128
|
+
check_private: bool = field(
|
|
129
|
+
default=False,
|
|
130
|
+
metadata={
|
|
131
|
+
"title": "Check Private Members",
|
|
132
|
+
"description": "Check docstrings for private members (starting with an underscore).",
|
|
133
|
+
},
|
|
134
|
+
)
|
|
135
|
+
validate_param_types: bool = field(
|
|
136
|
+
default=True,
|
|
137
|
+
metadata={
|
|
138
|
+
"title": "Validate Parameter Types",
|
|
139
|
+
"description": "Validate that parameter types are provided in the docstring.",
|
|
140
|
+
},
|
|
141
|
+
)
|
|
142
|
+
optional_style: Literal["silent", "validate", "strict"] = field(
|
|
143
|
+
default="validate",
|
|
144
|
+
metadata={
|
|
145
|
+
"title": "Optional Style",
|
|
146
|
+
"description": "The style for reporting issues in optional sections.",
|
|
147
|
+
},
|
|
148
|
+
)
|
|
119
149
|
|
|
120
150
|
|
|
121
151
|
## --------------------------------------------------------------------------- #
|
|
@@ -130,13 +160,53 @@ class SectionConfig:
|
|
|
130
160
|
Configuration for a docstring section.
|
|
131
161
|
"""
|
|
132
162
|
|
|
133
|
-
name: str
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
163
|
+
name: str = field(
|
|
164
|
+
metadata={
|
|
165
|
+
"title": "Name",
|
|
166
|
+
"description": "Name of the docstring section.",
|
|
167
|
+
},
|
|
168
|
+
)
|
|
169
|
+
type: Literal["free_text", "list_name", "list_type", "list_name_and_type"] = field(
|
|
170
|
+
metadata={
|
|
171
|
+
"title": "Type",
|
|
172
|
+
"description": "Type of the section content.",
|
|
173
|
+
},
|
|
174
|
+
)
|
|
175
|
+
order: Optional[int] = field(
|
|
176
|
+
default=None,
|
|
177
|
+
metadata={
|
|
178
|
+
"title": "Order",
|
|
179
|
+
"description": "Order of the section in the docstring.",
|
|
180
|
+
},
|
|
181
|
+
)
|
|
182
|
+
admonition: Union[bool, str] = field(
|
|
183
|
+
default=False,
|
|
184
|
+
metadata={
|
|
185
|
+
"title": "Admonition",
|
|
186
|
+
"description": "Admonition style for the section. Can be False (no admonition) or a string specifying the admonition type.",
|
|
187
|
+
},
|
|
188
|
+
)
|
|
189
|
+
prefix: str = field(
|
|
190
|
+
default="",
|
|
191
|
+
metadata={
|
|
192
|
+
"title": "Prefix",
|
|
193
|
+
"description": "Prefix string for the admonition values.",
|
|
194
|
+
},
|
|
195
|
+
)
|
|
196
|
+
required: bool = field(
|
|
197
|
+
default=False,
|
|
198
|
+
metadata={
|
|
199
|
+
"title": "Required",
|
|
200
|
+
"description": "Whether this section is required in the docstring.",
|
|
201
|
+
},
|
|
202
|
+
)
|
|
203
|
+
message: str = field(
|
|
204
|
+
default="",
|
|
205
|
+
metadata={
|
|
206
|
+
"title": "Message",
|
|
207
|
+
"description": "Optional message for validation errors.",
|
|
208
|
+
},
|
|
209
|
+
)
|
|
140
210
|
|
|
141
211
|
def __post_init__(self) -> None:
|
|
142
212
|
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|