docstring-format-checker 1.11.4__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.
- docstring_format_checker/__init__.py +27 -0
- docstring_format_checker/cli.py +917 -0
- docstring_format_checker/config.py +622 -0
- docstring_format_checker/core.py +2289 -0
- docstring_format_checker/utils/__init__.py +0 -0
- docstring_format_checker/utils/exceptions.py +103 -0
- docstring_format_checker-1.11.4.dist-info/METADATA +546 -0
- docstring_format_checker-1.11.4.dist-info/RECORD +10 -0
- docstring_format_checker-1.11.4.dist-info/WHEEL +4 -0
- docstring_format_checker-1.11.4.dist-info/entry_points.txt +4 -0
|
File without changes
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# ============================================================================ #
|
|
2
|
+
# #
|
|
3
|
+
# Title: Exceptions Module for Docstring Format Checker #
|
|
4
|
+
# Purpose: Custom exceptions for error handling in the docstring format #
|
|
5
|
+
# checker. #
|
|
6
|
+
# #
|
|
7
|
+
# ============================================================================ #
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# ---------------------------------------------------------------------------- #
|
|
11
|
+
# #
|
|
12
|
+
# Overview ####
|
|
13
|
+
# #
|
|
14
|
+
# ---------------------------------------------------------------------------- #
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# ---------------------------------------------------------------------------- #
|
|
18
|
+
# Description ####
|
|
19
|
+
# ---------------------------------------------------------------------------- #
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
"""
|
|
23
|
+
!!! note "Summary"
|
|
24
|
+
This module defines custom exceptions for handling various error scenarios
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# ---------------------------------------------------------------------------- #
|
|
29
|
+
# #
|
|
30
|
+
# Main Section ####
|
|
31
|
+
# #
|
|
32
|
+
# ---------------------------------------------------------------------------- #
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class DocstringError(Exception):
|
|
36
|
+
"""
|
|
37
|
+
!!! note "Summary"
|
|
38
|
+
Exception raised when a docstring validation error occurs.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
def __init__(
|
|
42
|
+
self,
|
|
43
|
+
message: str,
|
|
44
|
+
file_path: str,
|
|
45
|
+
line_number: int,
|
|
46
|
+
item_name: str,
|
|
47
|
+
item_type: str,
|
|
48
|
+
) -> None:
|
|
49
|
+
"""
|
|
50
|
+
!!! note "Summary"
|
|
51
|
+
Initialize a DocstringError.
|
|
52
|
+
"""
|
|
53
|
+
self.message: str = message
|
|
54
|
+
self.file_path: str = file_path
|
|
55
|
+
self.line_number: int = line_number
|
|
56
|
+
self.item_name: str = item_name
|
|
57
|
+
self.item_type: str = item_type
|
|
58
|
+
super().__init__(f"Line {line_number}, {item_type} '{item_name}': {message}")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class InvalidConfigError(Exception):
|
|
62
|
+
"""
|
|
63
|
+
!!! note "Summary"
|
|
64
|
+
Exception raised for invalid configuration errors.
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
pass
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class InvalidConfigError_DuplicateOrderValues(Exception):
|
|
71
|
+
"""
|
|
72
|
+
!!! note "Summary"
|
|
73
|
+
Exception raised for duplicate order values in configuration.
|
|
74
|
+
"""
|
|
75
|
+
|
|
76
|
+
pass
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class InvalidTypeValuesError(Exception):
|
|
80
|
+
"""
|
|
81
|
+
!!! note "Summary"
|
|
82
|
+
Exception raised for invalid type values in configuration.
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
pass
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class InvalidFileError(OSError):
|
|
89
|
+
"""
|
|
90
|
+
!!! note "Summary"
|
|
91
|
+
Exception raised for invalid file errors.
|
|
92
|
+
"""
|
|
93
|
+
|
|
94
|
+
pass
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class DirectoryNotFoundError(OSError):
|
|
98
|
+
"""
|
|
99
|
+
!!! note "Summary"
|
|
100
|
+
Exception raised for directory not found errors.
|
|
101
|
+
"""
|
|
102
|
+
|
|
103
|
+
pass
|
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: docstring-format-checker
|
|
3
|
+
Version: 1.11.4
|
|
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 :: 5 - Production/Stable
|
|
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: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Intended Audience :: Developers
|
|
22
|
+
Classifier: Environment :: Console
|
|
23
|
+
Requires-Dist: typer>=0.9.0
|
|
24
|
+
Requires-Dist: tomli>=2.0.0 ; python_full_version < '3.11'
|
|
25
|
+
Requires-Dist: rich>=13.0.0
|
|
26
|
+
Requires-Dist: toolbox-python==1.*
|
|
27
|
+
Requires-Dist: pyfiglet==1.*
|
|
28
|
+
Maintainer: Chris Mahoney
|
|
29
|
+
Maintainer-email: Chris Mahoney <docstring-format-checker@data-science-extensions.com>
|
|
30
|
+
Requires-Python: >=3.9
|
|
31
|
+
Project-URL: Changelog, https://data-science-extensions.com/toolboxes/docstring-format-checker/latest/usage/changelog/
|
|
32
|
+
Project-URL: Documentation, https://data-science-extensions.com/toolboxes/docstring-format-checker/latest/code/
|
|
33
|
+
Project-URL: Homepage, https://data-science-extensions.com/toolboxes/docstring-format-checker
|
|
34
|
+
Project-URL: Issues, https://github.com/data-science-extensions/docstring-format-checker/issues
|
|
35
|
+
Project-URL: Repository, https://github.com/data-science-extensions/docstring-format-checker
|
|
36
|
+
Description-Content-Type: text/markdown
|
|
37
|
+
|
|
38
|
+
<h1 align="center"><u><code>docstring-format-checker</code></u></h1>
|
|
39
|
+
|
|
40
|
+
<p align="center">
|
|
41
|
+
<a href="https://github.com/data-science-extensions/docstring-format-checker/releases">
|
|
42
|
+
<img src="https://img.shields.io/github/v/release/data-science-extensions/docstring-format-checker?logo=github" alt="github-release"></a>
|
|
43
|
+
<a href="https://pypi.org/project/docstring-format-checker">
|
|
44
|
+
<img src="https://img.shields.io/pypi/implementation/docstring-format-checker?logo=pypi&logoColor=ffde57" alt="implementation"></a>
|
|
45
|
+
<a href="https://pypi.org/project/docstring-format-checker">
|
|
46
|
+
<img src="https://img.shields.io/pypi/v/docstring-format-checker?label=version&logo=python&logoColor=ffde57&color=blue" alt="version"></a>
|
|
47
|
+
<a href="https://pypi.org/project/docstring-format-checker">
|
|
48
|
+
<img src="https://img.shields.io/pypi/pyversions/docstring-format-checker?logo=python&logoColor=ffde57" alt="python-versions"></a>
|
|
49
|
+
<br>
|
|
50
|
+
<a href="https://github.com/data-science-extensions/docstring-format-checker/actions/workflows/ci.yml">
|
|
51
|
+
<img src="https://img.shields.io/static/v1?label=os&message=ubuntu+|+macos+|+windows&color=blue&logo=ubuntu&logoColor=green" alt="os"></a>
|
|
52
|
+
<a href="https://pypi.org/project/docstring-format-checker">
|
|
53
|
+
<img src="https://img.shields.io/pypi/status/docstring-format-checker?color=green" alt="pypi-status"></a>
|
|
54
|
+
<a href="https://pypi.org/project/docstring-format-checker">
|
|
55
|
+
<img src="https://img.shields.io/pypi/format/docstring-format-checker?color=green" alt="pypi-format"></a>
|
|
56
|
+
<a href="https://github.com/data-science-extensions/docstring-format-checker/blob/main/LICENSE">
|
|
57
|
+
<img src="https://img.shields.io/github/license/data-science-extensions/docstring-format-checker?color=green" alt="github-license"></a>
|
|
58
|
+
<a href="https://piptrends.com/package/docstring-format-checker">
|
|
59
|
+
<img src="https://img.shields.io/pypi/dm/docstring-format-checker?color=green" alt="pypi-downloads"></a>
|
|
60
|
+
<a href="https://codecov.io/gh/data-science-extensions/docstring-format-checker">
|
|
61
|
+
<img src="https://codecov.io/gh/data-science-extensions/docstring-format-checker/graph/badge.svg" alt="codecov-repo"></a>
|
|
62
|
+
<a href="https://github.com/psf/black">
|
|
63
|
+
<img src="https://img.shields.io/static/v1?label=style&message=black&color=black&logo=windows-terminal&logoColor=white" alt="style"></a>
|
|
64
|
+
<br>
|
|
65
|
+
<a href="https://github.com/data-science-extensions/docstring-format-checker">
|
|
66
|
+
<img src="https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat" alt="contributions"></a>
|
|
67
|
+
<br>
|
|
68
|
+
<a href="https://github.com/data-science-extensions/docstring-format-checker/actions/workflows/ci.yml">
|
|
69
|
+
<img src="https://github.com/data-science-extensions/docstring-format-checker/actions/workflows/ci.yml/badge.svg?event=pull_request" alt="CI"></a>
|
|
70
|
+
<a href="https://github.com/data-science-extensions/docstring-format-checker/actions/workflows/cd.yml">
|
|
71
|
+
<img src="https://github.com/data-science-extensions/docstring-format-checker/actions/workflows/cd.yml/badge.svg?event=release" alt="CD"></a>
|
|
72
|
+
</p>
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
### 📝 Introduction
|
|
76
|
+
|
|
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
|
+
|
|
79
|
+
**Key Features:**
|
|
80
|
+
|
|
81
|
+
- 🔍 **AST-based parsing** - Robust code analysis without regex fragility
|
|
82
|
+
- ⚙️ **Configurable validation** - Four section types with TOML-based configuration
|
|
83
|
+
- 📚 **Flexible section ordering** - Support for unordered "floating" sections
|
|
84
|
+
- 📁 **Hierarchical config discovery** - Automatic `pyproject.toml` detection
|
|
85
|
+
- 🎨 **Rich terminal output** - Beautiful colored output and error tables
|
|
86
|
+
- 🚀 **Dual CLI entry points** - Use `docstring-format-checker` or `dfc`
|
|
87
|
+
- 🛡️ **100% test coverage** - Thoroughly tested and reliable
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
### 🚀 Quick Start
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Install
|
|
94
|
+
uv add docstring-format-checker
|
|
95
|
+
|
|
96
|
+
# Check a single file
|
|
97
|
+
dfc --check my_module.py
|
|
98
|
+
|
|
99
|
+
# Check entire directory
|
|
100
|
+
dfc --check src/
|
|
101
|
+
|
|
102
|
+
# Generate example configuration
|
|
103
|
+
dfc --example=config
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
### 🔗 Key URLs
|
|
108
|
+
|
|
109
|
+
For reference, these URLs are used:
|
|
110
|
+
|
|
111
|
+
| Type | Source | URL |
|
|
112
|
+
| -------------- | ------ | ---------------------------------------------------------------------- |
|
|
113
|
+
| Git Repo | GitHub | https://github.com/data-science-extensions/docstring-format-checker |
|
|
114
|
+
| Python Package | PyPI | https://pypi.org/project/docstring-format-checker |
|
|
115
|
+
| Package Docs | Pages | https://data-science-extensions.com/toolboxes/docstring-format-checker |
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
### 📂 Section Types
|
|
119
|
+
|
|
120
|
+
Configure validation for four types of docstring sections:
|
|
121
|
+
|
|
122
|
+
| Type | Description | Example Use |
|
|
123
|
+
| -------------------- | ------------------------- | ------------------------------ |
|
|
124
|
+
| `free_text` | Admonition-style sections | Summary, details, examples |
|
|
125
|
+
| `list_name` | Simple name lists | Simple parameter lists |
|
|
126
|
+
| `list_type` | Type-only lists | Raises, yields sections |
|
|
127
|
+
| `list_name_and_type` | Name and type lists | Parameters, returns with types |
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
### ⚙️ Configuration
|
|
131
|
+
|
|
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
|
+
|
|
134
|
+
You can utilise a layout in separate blocks like this:
|
|
135
|
+
|
|
136
|
+
```toml
|
|
137
|
+
[tool.dfc]
|
|
138
|
+
|
|
139
|
+
[[tool.dfc.sections]]
|
|
140
|
+
order = 1
|
|
141
|
+
name = "summary"
|
|
142
|
+
type = "free_text"
|
|
143
|
+
admonition = "note"
|
|
144
|
+
prefix = "!!!"
|
|
145
|
+
required = true
|
|
146
|
+
|
|
147
|
+
[[tool.dfc.sections]]
|
|
148
|
+
order = 2
|
|
149
|
+
name = "params"
|
|
150
|
+
type = "list_name_and_type"
|
|
151
|
+
required = true
|
|
152
|
+
|
|
153
|
+
# Unordered section - can appear anywhere
|
|
154
|
+
[[tool.dfc.sections]]
|
|
155
|
+
name = "deprecation warning"
|
|
156
|
+
type = "free_text"
|
|
157
|
+
admonition = "deprecation"
|
|
158
|
+
prefix = "!!!"
|
|
159
|
+
required = false
|
|
160
|
+
|
|
161
|
+
[[tool.dfc.sections]]
|
|
162
|
+
order = 3
|
|
163
|
+
name = "returns"
|
|
164
|
+
type = "list_name_and_type"
|
|
165
|
+
required = false
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Or like this in a single block:
|
|
169
|
+
|
|
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 = "???" },
|
|
187
|
+
]
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
### 📥 Installation
|
|
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].
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
#### Using [`pip`][pip]:
|
|
197
|
+
|
|
198
|
+
1. In your terminal, run:
|
|
199
|
+
|
|
200
|
+
```sh
|
|
201
|
+
python3 -m pip install --upgrade pip
|
|
202
|
+
python3 -m pip install docstring-format-checker
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
2. Or, in your `requirements.txt` file, add:
|
|
206
|
+
|
|
207
|
+
```txt
|
|
208
|
+
docstring-format-checker
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Then run:
|
|
212
|
+
|
|
213
|
+
```sh
|
|
214
|
+
python3 -m pip install --upgrade pip
|
|
215
|
+
python3 -m pip install --requirement=requirements.txt
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
#### Using [`pipenv`][pipenv]:
|
|
220
|
+
|
|
221
|
+
1. Install using environment variables:
|
|
222
|
+
|
|
223
|
+
In your `Pipfile` file, add:
|
|
224
|
+
|
|
225
|
+
```toml
|
|
226
|
+
[[source]]
|
|
227
|
+
url = "https://pypi.org/simple"
|
|
228
|
+
verify_ssl = false
|
|
229
|
+
name = "pypi"
|
|
230
|
+
|
|
231
|
+
[packages]
|
|
232
|
+
docstring-format-checker = "*"
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Then run:
|
|
236
|
+
|
|
237
|
+
```sh
|
|
238
|
+
python3 -m pip install pipenv
|
|
239
|
+
python3 -m pipenv install --verbose --skip-lock --categories=root index=pypi docstring-format-checker
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
2. Or, in your `requirements.txt` file, add:
|
|
243
|
+
|
|
244
|
+
```sh
|
|
245
|
+
docstring-format-checker
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Then run:
|
|
249
|
+
|
|
250
|
+
```sh
|
|
251
|
+
python3 -m pipenv install --verbose --skip-lock --requirements=requirements.txt
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
3. Or just run this:
|
|
255
|
+
|
|
256
|
+
```sh
|
|
257
|
+
python3 -m pipenv install --verbose --skip-lock docstring-format-checker
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
#### Using [`poetry`][poetry]:
|
|
262
|
+
|
|
263
|
+
1. In your `pyproject.toml` file, add:
|
|
264
|
+
|
|
265
|
+
```toml
|
|
266
|
+
[project]
|
|
267
|
+
dependencies = [
|
|
268
|
+
"docstring-format-checker==1.*",
|
|
269
|
+
]
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Then run:
|
|
273
|
+
|
|
274
|
+
```sh
|
|
275
|
+
poetry sync
|
|
276
|
+
poetry install
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
2. Or just run this:
|
|
280
|
+
|
|
281
|
+
```sh
|
|
282
|
+
poetry add "docstring-format-checker==1.*"
|
|
283
|
+
poetry sync
|
|
284
|
+
poetry install
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
#### Using [`uv`][uv]:
|
|
289
|
+
|
|
290
|
+
1. In your `pyproject.toml` file, add:
|
|
291
|
+
|
|
292
|
+
```toml
|
|
293
|
+
[project]
|
|
294
|
+
dependencies = [
|
|
295
|
+
"docstring-format-checker==1.*",
|
|
296
|
+
]
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
Then run:
|
|
300
|
+
|
|
301
|
+
```sh
|
|
302
|
+
uv sync
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
2. Or run this:
|
|
306
|
+
|
|
307
|
+
```sh
|
|
308
|
+
uv add "docstring-format-checker==1.*"
|
|
309
|
+
uv sync
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
3. Or just run this:
|
|
313
|
+
|
|
314
|
+
```sh
|
|
315
|
+
uv pip install "docstring-format-checker==1.*"
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
### 💡 Usage Examples
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
# Check a single Python file
|
|
323
|
+
dfc --check src/my_module.py
|
|
324
|
+
|
|
325
|
+
# Check multiple Python files
|
|
326
|
+
dfc file1.py file2.py
|
|
327
|
+
|
|
328
|
+
# Check entire directory recursively
|
|
329
|
+
dfc --check src/
|
|
330
|
+
|
|
331
|
+
# Check with table output format
|
|
332
|
+
dfc --output=table src/
|
|
333
|
+
|
|
334
|
+
# Generate example configuration file
|
|
335
|
+
dfc --example=config > pyproject.toml
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
#### Advanced Configuration
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
# Use custom config file location
|
|
343
|
+
dfc --config=custom_config.toml src/
|
|
344
|
+
|
|
345
|
+
# Exclude specific files using glob patterns
|
|
346
|
+
dfc src/ --exclude "**/test_*.py"
|
|
347
|
+
|
|
348
|
+
# Stop on first failure (CI environments)
|
|
349
|
+
dfc --check src/
|
|
350
|
+
|
|
351
|
+
# Suppress non-error output
|
|
352
|
+
dfc --quiet src/
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
#### Integration with CI/CD
|
|
357
|
+
|
|
358
|
+
```yaml
|
|
359
|
+
# .github/workflows/docs.yml
|
|
360
|
+
name: Documentation Quality
|
|
361
|
+
on: [push, pull_request]
|
|
362
|
+
|
|
363
|
+
jobs:
|
|
364
|
+
docstring-check:
|
|
365
|
+
runs-on: ubuntu-latest
|
|
366
|
+
steps:
|
|
367
|
+
- uses: actions/checkout@v4
|
|
368
|
+
- uses: astral-sh/setup-uv@v3
|
|
369
|
+
- run: uv pip install docstring-format-checker
|
|
370
|
+
- run: dfc --check src/
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
#### Integration with Pre-commit
|
|
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
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
|
|
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
|
+
```
|
|
423
|
+
|
|
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
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
### 🏗️ Architecture
|
|
439
|
+
|
|
440
|
+
The tool follows a clean, modular architecture:
|
|
441
|
+
|
|
442
|
+
- **`core.py`** - `DocstringChecker()` class with AST parsing and validation logic
|
|
443
|
+
- **`config.py`** - Configuration loading and `SectionConfig()` management
|
|
444
|
+
- **`cli.py`** - Typer-based CLI with dual entry points
|
|
445
|
+
- **`utils/exceptions.py`** - Custom exception classes for structured error handling
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
### 🤝 Contribution
|
|
449
|
+
|
|
450
|
+
Check the [CONTRIBUTING.md][github-contributing] file or [Contributing][docs-contributing] page.
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
### 🛠️ Development
|
|
454
|
+
|
|
455
|
+
1. **Clone the repository:**
|
|
456
|
+
|
|
457
|
+
```sh
|
|
458
|
+
git clone https://github.com/data-science-extensions/docstring-format-checker.git
|
|
459
|
+
cd docstring-format-checker
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
2. **Set up development environment:**
|
|
463
|
+
|
|
464
|
+
```sh
|
|
465
|
+
uv sync --all-groups
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
3. **Run tests:**
|
|
469
|
+
|
|
470
|
+
```sh
|
|
471
|
+
uv run pytest --config-file=pyproject.toml --cov-report=term-missing
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
4. **Run CLI locally:**
|
|
475
|
+
|
|
476
|
+
```sh
|
|
477
|
+
uv run dfc --check examples/example_code.py
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
### 🧪 Build and Test
|
|
482
|
+
|
|
483
|
+
To ensure that the package works as expected, ensure that:
|
|
484
|
+
|
|
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%.
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
#### Testing
|
|
493
|
+
|
|
494
|
+
- Run them all together:
|
|
495
|
+
|
|
496
|
+
```sh
|
|
497
|
+
uv run pytest --config-file=pyproject.toml
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
- Or run them individually:
|
|
501
|
+
|
|
502
|
+
- **Tests with Coverage:**
|
|
503
|
+
```sh
|
|
504
|
+
uv run pytest --config-file=pyproject.toml --cov-report=term-missing
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
- **Type Checking:**
|
|
508
|
+
```sh
|
|
509
|
+
uv run mypy src/
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
- **Code Formatting:**
|
|
513
|
+
```sh
|
|
514
|
+
uv run black --check src/
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
- **Linting:**
|
|
518
|
+
```sh
|
|
519
|
+
uv run ruff check src/
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
### 📄 License
|
|
524
|
+
|
|
525
|
+
This project is licensed under the MIT License - see the [LICENSE][github-license] file for details.
|
|
526
|
+
|
|
527
|
+
[github-repo]: https://github.com/data-science-extensions/docstring-format-checker
|
|
528
|
+
[github-contributing]: https://github.com/data-science-extensions/docstring-format-checker/blob/main/CONTRIBUTING.md
|
|
529
|
+
[docs-contributing]: https://data-science-extensions.com/docstring-format-checker/latest/usage/contributing/
|
|
530
|
+
[github-release]: https://github.com/data-science-extensions/docstring-format-checker/releases
|
|
531
|
+
[github-ci]: https://github.com/data-science-extensions/docstring-format-checker/actions/workflows/ci.yml
|
|
532
|
+
[github-cd]: https://github.com/data-science-extensions/docstring-format-checker/actions/workflows/cd.yml
|
|
533
|
+
[github-license]: https://github.com/data-science-extensions/docstring-format-checker/blob/main/LICENSE
|
|
534
|
+
[codecov-repo]: https://codecov.io/gh/data-science-extensions/docstring-format-checker
|
|
535
|
+
[pypi]: https://pypi.org/project/docstring-format-checker
|
|
536
|
+
[docs]: https://data-science-extensions.com/docstring-format-checker
|
|
537
|
+
[pip]: https://pypi.org/project/pip
|
|
538
|
+
[pipenv]: https://github.com/pypa/pipenv
|
|
539
|
+
[poetry]: https://python-poetry.org
|
|
540
|
+
[uv]: https://docs.astral.sh/uv/
|
|
541
|
+
[pep8]: https://peps.python.org/pep-0008/
|
|
542
|
+
[unittest]: https://docs.python.org/3/library/unittest.html
|
|
543
|
+
[codecov]: https://codecov.io/
|
|
544
|
+
[pytest]: https://docs.pytest.org
|
|
545
|
+
[mypy]: http://www.mypy-lang.org/
|
|
546
|
+
[black]: https://black.readthedocs.io/
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
docstring_format_checker/__init__.py,sha256=WEya--CyiUA7zHXvR5PqHCu7nxG92Z5D6iTEZMzWKdc,728
|
|
2
|
+
docstring_format_checker/cli.py,sha256=5VGF117BWfQKCz-N1MzgKh3j3j4dGO3wPtRgcUmRtwg,31397
|
|
3
|
+
docstring_format_checker/config.py,sha256=Bf_4KW69cKKBugDeZxTocsJSNue47r_NgcZCBx59kPg,21006
|
|
4
|
+
docstring_format_checker/core.py,sha256=vl4fH8U1NJn23bSlL8C388kp-i0EOuNHtxERwnILXE0,84528
|
|
5
|
+
docstring_format_checker/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
docstring_format_checker/utils/exceptions.py,sha256=GHe-gAsbXJ5ppB8POEG-09gqJBT2wn6o98LN2kQc2qA,3187
|
|
7
|
+
docstring_format_checker-1.11.4.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
8
|
+
docstring_format_checker-1.11.4.dist-info/entry_points.txt,sha256=B_Kt9ERn1dIX5hBvwKDeZQpXqo1aCbRhsuF3GOm1pCg,134
|
|
9
|
+
docstring_format_checker-1.11.4.dist-info/METADATA,sha256=4yJhvOGAUogKdiyGMUcYWMUUwr8tkTrRpaesqbxxTYU,18152
|
|
10
|
+
docstring_format_checker-1.11.4.dist-info/RECORD,,
|