Development Setup¶
Guide for setting up a development environment for project-guide.
Prerequisites¶
- Python 3.11 or higher
- Git
- pip or pipx
Clone the Repository¶
Set Up Virtual Environment¶
Using venv¶
Using pyenv¶
Install Development Dependencies¶
This installs: - The package in editable mode - Development dependencies (pytest, pytest-cov, ruff, mypy) - Documentation dependencies (mkdocs-material)
Verify Installation¶
# Check package is installed
project-guide --version
# Run tests
pytest
# Check linting
ruff check .
# Check types
mypy project_guide
Development Workflow¶
1. Create a Branch¶
2. Make Changes¶
Edit files in project_guide/ or tests/
3. Run Tests¶
# Run all tests
pytest
# Run with coverage
pytest --cov=project_guide
# Run specific test file
pytest tests/test_cli.py
# Run specific test
pytest tests/test_cli.py::test_init_command
4. Check Code Quality¶
5. Update Documentation¶
If you changed user-facing functionality:
# Edit documentation
vim docs/site/user-guide/commands.md
# Build and preview
mkdocs serve
# Open http://127.0.0.1:8000
6. Commit Changes¶
Project Structure¶
Main Package¶
project_guide/
├── __init__.py # Package initialization
├── __main__.py # CLI entry point
├── cli.py # CLI commands implementation
├── config.py # Configuration model
├── metadata.py # Metadata loading and validation
├── render.py # Jinja2 template rendering
├── sync.py # File synchronization logic
├── exceptions.py # Custom exception classes
├── version.py # Version information
└── templates/ # Bundled templates
└── project-guide/ # Project guide templates
├── .metadata.yml # Mode and artifact definitions
├── README.md # Template README
├── developer/ # Developer guide templates
└── templates/ # Jinja2 templates
├── modes/ # Mode templates (*.md)
├── artifacts/ # Artifact templates (*.md)
└── go.md # Go template
Tests¶
tests/
├── __init__.py
├── test_cli.py # CLI command tests (~60 tests)
├── test_sync.py # Sync logic tests (~22 tests)
├── test_integration.py # Integration tests (~6 tests)
├── test_render.py # Render tests (~20 tests)
├── test_metadata.py # Metadata tests (~9 tests)
├── test_config.py # Configuration tests (~7 tests)
└── test_purge.py # Purge command tests (~5 tests)
Documentation¶
docs/
└── site/ # MkDocs documentation
├── getting-started.md
├── user-guide/
├── developer-guide/
└── about/
Running Tests¶
Basic Test Run¶
With Coverage Report¶
Verbose Output¶
Stop on First Failure¶
Run Specific Tests¶
# By file
pytest tests/test_cli.py
# By test name
pytest tests/test_cli.py::test_init_command
# By pattern
pytest -k "test_init"
Code Quality Tools¶
Ruff (Linter and Formatter)¶
# Check for issues
ruff check .
# Fix auto-fixable issues
ruff check --fix .
# Format code
ruff format .
Mypy (Type Checker)¶
Building Documentation¶
Local Development¶
Build Static Site¶
# Build to site/ directory
mkdocs build
# Build with strict mode (fail on warnings)
mkdocs build --strict
Debugging¶
Using pdb¶
Add breakpoint in code:
Run tests:
Using pytest debugging¶
Verbose CLI Output¶
Common Tasks¶
Add a New Command¶
- Add command function in
project_guide/cli.py - Add tests in
tests/test_cli.py - Update documentation in
docs/site/user-guide/commands.md - Run tests and linters
Add a New Mode¶
- Create a mode template in
project_guide/templates/project-guide/templates/modes/ - Add the mode to
.metadata.ymlinproject_guide/templates/project-guide/ - Test rendering with
project-guide initand select the new mode - Verify the parametrized test in
test_render.pypicks up the new mode - Document changes in
CHANGELOG.md
Update a Template¶
- Edit the template in
project_guide/templates/project-guide/templates/ - Test with
project-guide initfollowed by mode selection to verify rendering - Update version in
project_guide/version.pyif needed - Document changes in
CHANGELOG.md
Add a New Artifact¶
- Create an artifact template in
project_guide/templates/project-guide/templates/artifacts/ - Add the artifact to
.metadata.yml - Add tests for the new artifact
- Update documentation
Troubleshooting¶
Import Errors¶
Ensure package is installed in editable mode:
Test Failures¶
Check if dependencies are up to date:
Type Check Errors¶
Ignore specific errors if needed:
Next Steps¶
- Contributing Guide - Contribution guidelines
- Testing Guide - Detailed testing information