|
1 |
| -# pydoclint Project Conventions |
| 1 | +# CLAUDE.md |
2 | 2 |
|
3 |
| -## Code Style |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with |
| 4 | +code in this repository. |
| 5 | + |
| 6 | +## pydoclint Project Conventions |
| 7 | + |
| 8 | +### Code Style |
4 | 9 |
|
5 | 10 | - Use camelCase for function and variable names (not snake_case)
|
6 | 11 |
|
7 |
| -## Branch Naming |
| 12 | +### Branch Naming |
8 | 13 |
|
9 | 14 | - Format: `yyyy-mm-dd-What-this-branch-does`
|
10 | 15 |
|
11 |
| -## Commit Messages & PR Titles |
| 16 | +### Commit Messages & PR Titles |
12 | 17 |
|
13 | 18 | - Use action verbs (imperative mood), not past tense
|
14 | 19 | - Good: "Add feature", "Fix bug"
|
15 | 20 | - Bad: "Added feature", "Fixed bug"
|
| 21 | + |
| 22 | +## Development Commands |
| 23 | + |
| 24 | +### Testing |
| 25 | + |
| 26 | +- `pytest --tb=long .` - Run all tests with detailed traceback |
| 27 | +- `tox` - Run full test suite across multiple Python versions |
| 28 | +- `tox -e py311` - Run tests on specific Python version (py39, py310, py311, |
| 29 | + py312, py313) |
| 30 | + |
| 31 | +### Code Quality |
| 32 | + |
| 33 | +- `mypy pydoclint/` - Type checking |
| 34 | +- `muff format --diff --config=muff.toml pydoclint tests` - Format checking |
| 35 | + (use `--diff` to avoid accidental formatting) |
| 36 | +- `flake8 .` - Basic linting |
| 37 | +- `pydoclint --config=pyproject.toml .` - Self-check using pydoclint |
| 38 | +- `pre-commit run -a` - Run all pre-commit hooks |
| 39 | + |
| 40 | +### Specialized Tox Commands |
| 41 | + |
| 42 | +- `tox -e mypy` - Type checking only |
| 43 | +- `tox -e muff` - Format checking only |
| 44 | +- `tox -e check-self` - Run pydoclint on itself |
| 45 | +- `tox -e flake8-basic` - Basic flake8 checks |
| 46 | +- `tox -e flake8-misc` - Additional flake8 plugins |
| 47 | +- `tox -e flake8-docstrings` - Docstring style checks |
| 48 | +- `tox -e pre-commit` - Pre-commit hooks (skips muff formatter) |
| 49 | + |
| 50 | +### Running a Single Test |
| 51 | + |
| 52 | +Use pytest with specific test file or test function: |
| 53 | + |
| 54 | +```bash |
| 55 | +pytest tests/test_main.py |
| 56 | +pytest tests/test_main.py::test_function_name |
| 57 | +``` |
| 58 | + |
| 59 | +## Architecture Overview |
| 60 | + |
| 61 | +Pydoclint is a Python docstring linter that checks docstring sections against |
| 62 | +function signatures. The core architecture consists of: |
| 63 | + |
| 64 | +### Main Components |
| 65 | + |
| 66 | +- **main.py**: CLI entry point using Click, handles command-line options and |
| 67 | + orchestrates linting |
| 68 | +- **visitor.py**: AST visitor that traverses Python code and applies docstring |
| 69 | + checks |
| 70 | +- **flake8_entry.py**: Plugin interface for flake8 integration |
| 71 | +- **parse_config.py**: Configuration parsing from pyproject.toml and other |
| 72 | + sources |
| 73 | +- **baseline.py**: Baseline functionality for gradual adoption |
| 74 | + |
| 75 | +### Utils Package Structure |
| 76 | + |
| 77 | +- **arg.py/argList.py**: Function argument representation and handling |
| 78 | +- **doc.py**: Docstring parsing and representation |
| 79 | +- **return_arg.py/yield_arg.py**: Return/yield argument handling |
| 80 | +- **violation.py**: Violation representation and reporting |
| 81 | +- **astTypes.py**: AST type definitions and utilities |
| 82 | +- **generic.py**: Common utility functions |
| 83 | +- **method_type.py**: Method type detection (regular, static, class, property) |
| 84 | +- **parse_docstring.py**: Core docstring parsing for numpy/google/sphinx styles |
| 85 | +- **return_yield_raise.py**: Analysis of return/yield/raise statements in |
| 86 | + function bodies |
| 87 | +- **visitor_helper.py**: Helper functions for the main visitor |
| 88 | + |
| 89 | +### Supported Docstring Styles |
| 90 | + |
| 91 | +- **Numpy**: numpydoc format |
| 92 | +- **Google**: Google-style docstrings |
| 93 | +- **Sphinx**: Sphinx/reStructuredText format |
| 94 | + |
| 95 | +### Key Features |
| 96 | + |
| 97 | +- Fast AST-based analysis (thousands of times faster than darglint) |
| 98 | +- Supports type hint checking against docstring parameter types |
| 99 | +- Class attribute documentation checking |
| 100 | +- Baseline mode for gradual adoption in existing codebases |
| 101 | +- Both standalone CLI and flake8 plugin modes |
| 102 | + |
| 103 | +### Test Structure |
| 104 | + |
| 105 | +- `tests/data/` contains test cases organized by docstring style (google, |
| 106 | + numpy, sphinx, edge_cases) |
| 107 | +- Tests use real Python files with expected violations rather than string-based |
| 108 | + tests |
0 commit comments