Contributing¶
Contributions are welcome! This guide covers everything you need to get started.
Development setup¶
# Clone the repository
git clone https://github.com/MathiasPaulenko/behave-format.git
cd behave-format
# Install in development mode with all dev dependencies
pip install -e ".[dev]"
# Verify installation
behave-format --version
pytest tests/ -v
Project structure¶
behave-format/
├── behave_format/ # Source code
│ ├── config/ # Settings
│ ├── pipeline/ # Formatting pipeline
│ ├── printer/ # Text generation
│ └── cli/ # CLI
├── tests/ # Test suite
│ ├── golden/ # Golden file tests
│ ├── unit/ # Unit tests
│ └── performance/ # Performance tests
├── docs/ # Documentation
├── pyproject.toml # Project config
└── mkdocs.yml # Docs config
Running tests¶
# Run all tests
pytest tests/ -v
# Run with coverage
pytest tests/ --cov=behave_format --cov-report=term-missing
# Run only unit tests
pytest tests/unit/ -v
# Run only golden file tests
pytest tests/golden/ -v
# Run performance tests
pytest tests/performance/ -v
Linting and formatting¶
# Check linting
ruff check behave_format/ tests/
# Check formatting
ruff format --check behave_format/ tests/
# Auto-fix linting issues
ruff check --fix behave_format/ tests/
# Auto-format
ruff format behave_format/ tests/
Type checking¶
Building documentation¶
Before submitting a PR¶
- Fork the repository and create a feature branch
-
Run all checks:
-
Add tests for any new functionality
- Update documentation if needed
- Ensure idempotency —
format(format(x)) == format(x)must always hold - Open a Pull Request with a clear description
Adding formatting rules¶
- Add normalization logic to
pipeline/normalize.py - Add sorting logic to
pipeline/sort.pyif needed - Update the appropriate printer in
printer/ - Add golden file tests in
tests/golden/ - Add idempotency tests — verify
format(format(x)) == format(x) - Update docs in
guides/formatting_rules.md
Golden file test pattern¶
def test_my_rule():
input_text = """@smoke @auth
Feature: Test
"""
expected = """@auth @smoke
Feature: Test
"""
feature = load_feature_from_text(input_text)
format_feature(feature, Settings())
result = print_feature(feature, indent=2)
assert result == expected.strip()
Release process¶
Releases are automated via GitHub Actions:
- Update
__version__inbehave_format/__init__.py - Update
CHANGELOG.md - Commit and push to
main - Create and push a tag:
git tag v1.0.2 && git push origin v1.0.2 - The release workflow builds, tests, and publishes to PyPI automatically
Code style¶
- Follow PEP 8 (enforced by Ruff)
- Use type hints on all public functions
- Write docstrings in Google or NumPy format
- Keep functions small and focused
- Prefer composition over inheritance
- Use
pathlib.Pathfor file operations
Reporting bugs¶
When reporting a bug, please include:
- The
.featurefile that triggers the bug (or a minimal reproduction) - The expected output
- The actual output
- The behave-format version (
behave-format --version) - The Python version (
python --version)