This guide will help you set up a development environment for contributing to StructKit.
- Python 3.8 or higher
- Git
- Virtual environment tool (venv, virtualenv, or conda)
git clone https://github.com/httpdss/structkit.git
cd structpython3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate# Install runtime dependencies
pip install -r requirements.txt
# Install development dependencies
pip install -r requirements.dev.txt
# Install the package in development mode
pip install -e .structkit --help# Run all tests
pytest
# Run tests with coverage
pytest --cov=structkit
# Run specific test file
pytest tests/test_specific.pyThis project uses several tools to maintain code quality:
# Format code with black
black .
# Sort imports
isort .
# Lint with flake8
flake8 .
# Type checking with mypy
mypy structkit/Install pre-commit hooks to automatically run quality checks:
pre-commit installThis will run formatting, linting, and tests before each commit.
struct/
├── structkit/ # Main Python package
│ ├── commands/ # CLI command implementations
│ ├── contribs/ # Built-in structure templates
│ └── ...
├── tests/ # Test files
├── docs/ # Documentation
├── example/ # Example configurations
├── scripts/ # Utility scripts
└── requirements*.txt # Dependencies
Commands are defined in structkit/commands/. Each command should:
- Inherit from a base command class
- Include proper argument parsing
- Have comprehensive tests
- Include documentation
Example:
# structkit/commands/my_command.py
from .base import BaseCommand
class MyCommand(BaseCommand):
def add_arguments(self, parser):
parser.add_argument('--option', help='My option')
def handle(self, args):
# Implementation here
passNew structure templates go in structkit/contribs/. Each template should:
- Have a clear directory structure
- Provide good documentation
- Include example usage
All new functionality must include tests:
# tests/test_my_feature.py
import pytest
from structkit.my_feature import MyFeature
def test_my_feature():
feature = MyFeature()
result = feature.do_something()
assert result == expected_value- Add or update relevant documentation in
docs/ - Add examples if applicable
Run unit tests to verify individual components:
pytest tests/unit/Run integration tests to verify end-to-end functionality:
pytest tests/integration/structkit --log=DEBUG generate my-config.yaml ./outputAdd breakpoints in your code:
import pdb; pdb.set_trace()structkit --log=DEBUG generate my-config.yaml ./output- Follow PEP 8
- Use type hints where appropriate
- Write docstrings for public functions
- Keep functions small and focused
Use conventional commit format:
feat: add new template variable filter
fix: resolve issue with file permissions
docs: update installation guide
test: add tests for mappings functionality
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes
- Write tests
- Update documentation
- Submit a pull request
All pull requests must:
- Pass all tests
- Include appropriate documentation
- Follow code style guidelines
- Have a clear description of changes
Import errors: Make sure you've installed the package in development mode:
pip install -e .Test failures: Ensure all dependencies are installed:
pip install -r requirements.dev.txtPermission errors: Check file permissions and ensure you're in the right directory.
- Check existing issues on GitHub
- Join our Discord community
- Read the documentation thoroughly
- Ask questions in discussions