CLI Interaction Guide๐
Interface directly with the docstring-format-checker (or dfc) to standardise your project's documentation. Access a detailed walkthrough of all command-line operations, designed to help new developers master the tool's capabilities.
๐ ๏ธ The dfc Command๐
Interact with the tool primarily through the dfc command. Treat this as an alias for the longer docstring-format-checker command, providing a more concise interface for frequent use.
๐ Basic Syntax๐
Follow the general structure of a dfc command:
dfc [OPTIONS] [PATHS]...
Target one or more paths, such as specific Python files or entire directories.
Full Help Command (--help / -h)๐
dfc --help
_ _ _ __ _ _ _
__| | ___ ___ ___| |_ _ __(_)_ __ __ _ / _| ___ _ __ _ __ ___ __ _| |_ ___| |__ ___ ___| | _____ _ __
/ _` |/ _ \ / __/ __| __| '__| | '_ \ / _` |_____| |_ / _ \| '__| '_ ` _ \ / _` | __|____ / __| '_ \ / _ \/ __| |/ / _ \ '__|
| (_| | (_) | (__\__ \ |_| | | | | | | (_| |_____| _| (_) | | | | | | | | (_| | ||_____| (__| | | | __/ (__| < __/ |
\__,_|\___/ \___|___/\__|_| |_|_| |_|\__, | |_| \___/|_| |_| |_| |_|\__,_|\__| \___|_| |_|\___|\___|_|\_\___|_|
|___/
Usage: dfc [OPTIONS] [PATHS]... COMMAND [ARGS]...
A CLI tool to check and validate Python docstring formatting and completeness.
โญโ Arguments โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ paths [PATHS]... Path(s) to Python file(s) or directory(s) for DFC to check โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ Options โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --config -f TEXT Path to configuration file (TOML format) โ
โ --exclude -x TEXT Glob patterns to exclude (can be used multiple times) โ
โ --output -o TEXT Output format: 'table' or 'list' [default: list] โ
โ --check -c Throw error (exit 1) if any issues are found โ
โ --quiet -q Only output pass/fail confirmation, suppress errors unless failing โ
โ --example -e TEXT Show examples: 'config' for configuration example, 'usage' for usage examples โ
โ --version -v Show version and exit โ
โ --help -h Show this message and exit โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ Usage Examples โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ Execute the below commands in any terminal after installing the package. โ
โ โ
โ dfc myfile.py # Check a single Python file (list output) โ
โ dfc myfile.py other_file.py # Check multiple Python files โ
โ dfc src/ # Check all Python files in src/ directory โ
โ dfc -x src/app/__init__.py src/ # Check all Python files in src/ directory, excluding one init file โ
โ dfc --output=table myfile.py # Check with table output format โ
โ dfc -o list myfile.py # Check with list output format (default) โ
โ dfc --check myfile.py # Check and exit with error if issues found โ
โ dfc --quiet myfile.py # Check quietly, only show pass/fail โ
โ dfc --quiet --check myfile.py # Check quietly and exit with error if issues found โ
โ dfc . --exclude '*/tests/*' # Check current directory, excluding tests โ
โ dfc . -c custom.toml # Use custom configuration file โ
โ dfc --example=config # Show example configuration โ
โ dfc -e usage # Show usage examples (this help) โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ Configuration Example โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ Place the below config in your `pyproject.toml` file. โ
โ โ
โ [tool.dfc] โ
โ # or [tool.docstring-format-checker] โ
โ allow_undefined_sections = false โ
โ require_docstrings = true โ
โ check_private = true โ
โ validate_param_types = true โ
โ optional_style = "validate" # "silent", "validate", or "strict" โ
โ sections = [ โ
โ { order = 1, name = "summary", type = "free_text", required = true, admonition = "note", prefix = "!!!" }, โ
โ { order = 2, name = "details", type = "free_text", required = false, admonition = "abstract", prefix = "???+" }, โ
โ { order = 3, name = "params", type = "list_name_and_type", required = false }, โ
โ { order = 4, name = "raises", type = "list_type", required = false }, โ
โ { order = 5, name = "returns", type = "list_name_and_type", required = false }, โ
โ { order = 6, name = "yields", type = "list_type", required = false }, โ
โ { order = 7, name = "examples", type = "free_text", required = false, admonition = "example", prefix = "???+" }, โ
โ { order = 8, name = "notes", type = "free_text", required = false, admonition = "note", prefix = "???" }, โ
โ ] โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
๐ Target Paths๐
Determine which parts of your codebase dfc should examine.
๐ Single Files๐
Check an individual file by providing its path:
dfc sample.py
๐ Directories๐
Check all Python files within a directory (including subdirectories) by providing the folder path:
dfc src/
๐๏ธ Multiple Targets๐
Combine multiple files and directories in a single command:
dfc module1.py src/utils/
โ๏ธ Core Options๐
Customise the behaviour of dfc and its search location for settings.
๐ Configuration File (--config / -f)๐
Direct dfc to look for a [tool.dfc] section in your pyproject.toml. Use this option to point to a specific TOML file instead.
dfc --config=custom_config.toml src/
๐ซ Exclusion Patterns (--exclude / -x)๐
Ignore specific files or directories using glob patterns. This is particularly useful for skipping third-party libraries, virtual environments, or test suites.
dfc . --exclude='*/tests/*' --exclude 'setup.py'
Note
Provide the --exclude flag multiple times to specify several patterns.
๐จ Output Format (--output / -o)๐
Standardise the appearance of error reports. Choose between a detailed list (default) or a structured table.
๐ Render as a list๐
dfc --output=list sample.py
sample.py
Line 1 - function 'calculate_area':
- Missing required section: 'summary'
- Missing required section: 'params'
๐ Render as a table๐
dfc --output=table sample.py
โโโโโโโโโโโโโณโโโโโโโณโโโโโโโโโโโโโโโโโณโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ File โ Line โ Item โ Type โ Error โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ sample.py โ 1 โ calculate_area โ function โ - Missing required section: 'summary' โ
โโโโโโโโโโโโโดโโโโโโโดโโโโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ก๏ธ Execution Controls๐
Manage the interaction between dfc and other tools or scripts.
๐ Check Mode (--check / -c)๐
Ensure that dfc returns a non-zero exit code if any issues are found. Integrate dfc into Continuous Integration (CI) pipelines or git hooks with this flag.
dfc --check src/
๐ Quiet Mode (--quiet / -q)๐
Suppress all detailed error messages. Report only a high-level summary if errors occur, or nothing at all if the check passes.
dfc --quiet --check src/
๐ Helper Commands๐
Access built-in documentation and version information directly from the terminal.
๐ก Show Examples (--example / -e)๐
View pre-configured templates to help you get started quickly.
--example config: Display a comprehensive TOML configuration template.--example usage: Display common CLI usage patterns.
dfc --example=config
๐ข Version Information (--version / -v)๐
Check which version of docstring-format-checker is currently installed.
dfc --version
โ Help Message (--help / -h)๐
Display a full summary of all available arguments, options, and usage examples.
dfc --help
๐ Guided Walkthrough๐
Follow these steps to explore the most important features of the dfc CLI.
๐๏ธ 1. Create a workspace๐
Prepare a small environment with a few sample files to test the tool. Create a directory named dfc_walkthrough and add the following files:
def calculate_area(width: int, height: int) -> int:
"""
!!! note "Summary"
Calculate the area of a rectangle.
Params:
width (int): The width of the rectangle.
height (int): The height of the rectangle.
Returns:
(int): The calculated area.
"""
return width * height
def calculate_perimeter(width: int, height: int) -> int:
"""
!!! note "Summary"
Calculate the perimeter of a rectangle.
Params:
width (int): The width of the rectangle.
height (int): The height of the rectangle.
Returns:
(int): The calculated perimeter.
"""
return 2 * (width + height)
def calculate_area(width: int, height: int) -> int:
"""
Calculate the area of a rectangle.
Args:
width (int): The width of the rectangle.
height (int): The height of the rectangle.
Returns:
(int): The calculated area.
"""
return width * height
def calculate_perimeter(width: int, height: int) -> int:
"""
Calculate the perimeter of a rectangle.
Parameters:
width (int): The width of the rectangle.
height (int): The height of the rectangle.
Returns:
(int): The calculated perimeter.
"""
return 2 * (width + height)
๐ 2. Identify issues๐
Run a standard check on the bad_code.py file to see the inconsistency reports from dfc.
dfc bad_code.py
Expect dfc to identify missing summary admonitions and incorrectly named sections like Args (which should be Params by default).
๐ 3. Utilise the table view๐
Switch to the table format to get a more structured overview of the errors. Read multiple issues with ease using this layout.
dfc --output=table bad_code.py
๐ 4. Check an entire directory๐
Instruct dfc to scan the whole directory. Find all .py files and report on each one automatically.
dfc .
View results for both good_code.py (which should pass) and bad_code.py in the output.
๐ค 5. Standardise for CI๐
Prepare your commands for a CI environment. Use the --quiet and --check flags to ensure that the process fails if documentation is insufficient, without cluttering the logs.
dfc --quiet --check .
Observe no output upon a successful check. Receive a concise summary if errors are present:
Found 6 error(s) in 2 functions over 1 file
โ ๏ธ Watch Out๐
Keep these nuances in mind to avoid common pitfalls:
๐ Shell Pattern Matching๐
Different shells (like bash, zsh, or fish) handle glob patterns (like *) differently. Always surround your exclusion patterns with quotes to ensure they are passed correctly to dfc.
- Correct:
dfc --exclude '*/tests/*' . - Incorrect:
dfc --exclude */tests/* .
๐ Argument Order๐
Move flags to the start of the command if errors occur (a common requirement for Typer-based tools):
- Recommended:
dfc --output=table src/ - Sometimes Unreliable:
dfc src/ --output=table