Modules🔗
Overview🔗
These are the modules used in the docstring-format-checker package:
Module | Description |
---|---|
Core | The core module contains the main DocstringChecker class responsible for parsing Python files with AST, extracting docstrings from functions/classes/methods, and validating them against configured section requirements. |
Configuration | The config module handles loading and validating configuration from TOML files. It supports automatic discovery of pyproject.toml files and defines section validation rules through the SectionConfig dataclass. |
CLI | The cli module provides the command-line interface using Typer. It supports both docstring-format-checker and dfc entry points with subcommands for checking files/directories and generating configuration examples. |
Exceptions | The exceptions module defines custom exception classes for structured error handling, including DocstringError for validation failures, InvalidFileError for non-Python files, and DirectoryNotFoundError for path validation. |
Key Features🔗
- AST-based parsing: Uses Python's AST module for robust code analysis
- Configurable validation: TOML-based configuration with 4 section types:
free_text
,list_name
,list_type
,list_name_and_type
- Hierarchical config discovery: Automatically finds configuration in
pyproject.toml
files - Rich output formatting: Uses Rich library for colored console output and error tables
- Dual CLI entry points: Available as both
docstring-format-checker
anddfc
- Comprehensive error handling: Custom exceptions for different failure scenarios
Section Types🔗
The checker supports four types of docstring sections:
free_text
: Admonition-style sections like summary, details, exampleslist_name
: Simple name listslist_type
: Type-only lists for raises, yields sectionslist_name_and_type
: Name and type lists for parameters, returns sections
Testing🔗
This package maintains 100% test coverage with comprehensive testing against:
- Unit tests: Complete test coverage for all modules and functions
- Integration tests: CLI and end-to-end workflow testing
- Configuration tests: TOML parsing and validation testing
- Error handling tests: Exception scenarios and edge cases
- AST parsing tests: Python code analysis and docstring extraction
Tests are run in matrix against:
- Python Versions:
3.10
3.11
3.12
3.13
- Operating Systems:
ubuntu-latest
windows-latest
macos-latest