# tenets Development Makefile
# Simplifies common development tasks
.PHONY: help install dev install-light install-ml install-viz test lint format clean build docs docs-serve docs-deploy docs-build release viz
# Default target
help:
@echo "tenets Development Commands:"
@echo ""
@echo "Installation:"
@echo " make install - Install tenets in production mode"
@echo " make dev - Install tenets in development mode with all extras"
@echo " make install-light - Install with light NLP features (RAKE, TF-IDF)"
@echo " make install-ml - Install with ML features (ranking, summarization)"
@echo " make install-viz - Install with visualization features"
@echo ""
@echo "Testing & Quality:"
@echo " make test - Run all tests"
@echo " make test-fast - Run tests excluding slow ones"
@echo " make test-ranking - Run ranking tests"
@echo " make test-summary - Run summarization tests"
@echo " make lint - Run all linters"
@echo " make format - Auto-format code"
@echo ""
@echo "Documentation:"
@echo " make docs - Build and serve docs locally (http://localhost:8000)"
@echo " make docs-build - Build docs to site/ directory"
@echo " make docs-serve - Serve docs with live reload"
@echo " make docs-deploy - Deploy docs to GitHub Pages (requires permissions)"
@echo ""
@echo "Visualization:"
@echo " make viz-deps - Visualize project dependencies"
@echo " make viz-complex - Visualize code complexity"
@echo ""
@echo "Build & Release:"
@echo " make build - Build distribution packages"
@echo " make clean - Remove build artifacts"
@echo " make release - Create a new release (interactive)"
# Install production dependencies
install:
pip install --upgrade pip
pip install -e .
# Install development environment
dev:
pip install --upgrade pip
pip install -e ".[all,dev,test]"
pip install mkdocs mkdocs-material mkdocs-material-extensions
pip install pymdown-extensions mkdocs-minify-plugin
pre-commit install
pre-commit install --hook-type commit-msg
pre-commit install --hook-type push
@echo "✓ Development environment ready!"
# Install with light NLP features (RAKE, TF-IDF, etc.)
install-light:
pip install --upgrade pip
pip install -e ".[light]"
@echo "✓ Light NLP features installed (RAKE keyword extraction, TF-IDF ranking)"
# Install with ML features
install-ml:
pip install --upgrade pip
pip install -e ".[ml]"
@echo "✓ ML features installed (advanced ranking & summarization)"
# Install with visualization features
install-viz:
pip install --upgrade pip
pip install -e ".[viz]"
@echo "✓ Visualization features installed"
# Run all tests
test:
pytest -v --cov=tenets --cov-report=term-missing --cov-report=html
# Run fast tests only
test-fast:
pytest -v -m "not slow" --cov=tenets
# Run ranking tests
test-ranking:
pytest -v tests/test_ranking/ --cov=tenets.core.ranking
# Run summarization tests
test-summary:
pytest -v tests/test_summarizer/ --cov=tenets.core.summarizer
# Run visualization tests
test-viz:
pytest -v tests/test_viz/ --cov=tenets.viz
# Run specific test file
test-file:
@read -p "Test file path: " filepath; \
pytest -v $$filepath
# Run all linters
lint:
@echo "Running black..."
black --check --diff .
@echo "\nRunning isort..."
isort --check-only --diff .
@echo "\nRunning ruff..."
ruff check .
@echo "\nRunning mypy..."
mypy tenets --strict || true
@echo "\nRunning bandit..."
bandit -r tenets -ll
@echo "\nRunning safety..."
safety check || true
@echo "\n✓ All linting checks complete!"
# Auto-format code
format:
@echo "Running autoflake..."
autoflake --in-place --remove-all-unused-imports --recursive tenets tests
@echo "Running isort..."
isort .
@echo "Running black..."
black .
@echo "Running ruff with fixes..."
ruff check --fix .
@echo "\n✓ Code formatting complete!"
# Clean build artifacts
clean:
rm -rf build/
rm -rf dist/
rm -rf site/
rm -rf *.egg-info
rm -rf .coverage
rm -rf htmlcov/
rm -rf .pytest_cache/
rm -rf .mypy_cache/
rm -rf .ruff_cache/
rm -rf .tenets/ # Clean tenets cache
find . -type d -name __pycache__ -exec rm -rf {} +
find . -type f -name "*.pyc" -delete
find . -type f -name "*.pyo" -delete
@echo "✓ Cleaned all build artifacts!"
# Build distribution packages
build: clean
python -m build
twine check dist/*
@echo "\n✓ Build complete! Packages in dist/"
# Documentation commands
docs: docs-serve
# Build documentation to site/ directory
docs-build:
@echo "Building documentation..."
mkdocs build --strict
@echo "\n✓ Documentation built in site/"
@echo "Open site/index.html in your browser to view"
# Serve documentation locally with live reload
docs-serve:
@echo "Starting documentation server..."
@echo "Documentation will be available at http://localhost:8000"
@echo "Press Ctrl+C to stop"
mkdocs serve --dev-addr localhost:8000 --livereload
# Serve documentation in dev mode (no API generation, faster for styling/content updates)
docs-dev:
@echo "Starting documentation server in DEV MODE (no API generation)..."
@echo "Documentation will be available at http://localhost:8000"
@echo "Press Ctrl+C to stop"
@echo "NOTE: API docs will not be generated/updated in this mode"
mkdocs serve --dev-addr localhost:8000 --livereload --dirtyreload
# Deploy documentation to GitHub Pages
docs-deploy:
@echo "Deploying documentation to GitHub Pages..."
@echo "This will push to the gh-pages branch"
@read -p "Continue? [y/N] " confirm; \
if [ "$$confirm" = "y" ]; then \
mkdocs gh-deploy --force --message "Deploy docs from Makefile"; \
echo "\n✓ Documentation deployed to https://tenets.dev/docs"; \
else \
echo "Deployment cancelled"; \
fi
# Install documentation dependencies only
docs-deps:
pip install mkdocs mkdocs-material mkdocs-material-extensions
pip install pymdown-extensions mkdocs-minify-plugin
@echo "✓ Documentation dependencies installed!"
# Check documentation for issues
docs-check:
mkdocs build --strict 2>&1 | grep -E "WARNING|ERROR" || echo "✓ No documentation issues found!"
# Visualization: show project dependencies
viz-deps:
@echo "Generating dependency graph..."
tenets viz deps . --output deps.html --format html
@echo "✓ Dependency graph saved to deps.html"
# Visualization: show code complexity
viz-complex:
@echo "Generating complexity heatmap..."
tenets viz complexity . --output complexity.html --threshold 10
@echo "✓ Complexity heatmap saved to complexity.html"
# Run pre-commit on all files
pre-commit:
pre-commit run --all-files
# Create a new release (interactive)
release:
@echo "Creating a new release..."
@echo "Current version: $$(grep version pyproject.toml | head -1 | cut -d'"' -f2)"
@echo "\nThis will:"
@echo "1. Run all tests"
@echo "2. Update version numbers"
@echo "3. Update CHANGELOG.md"
@echo "4. Create a git commit and tag"
@echo "5. Push to GitHub (triggering release workflow)"
@echo ""
@read -p "Continue? [y/N] " confirm; \
if [ "$$confirm" = "y" ]; then \
make test && \
cz bump && \
git push && \
git push --tags; \
fi
# Install git hooks
install-hooks:
pre-commit install --install-hooks
@echo "✓ Git hooks installed!"
# Update dependencies
update-deps:
pip install --upgrade pip pip-tools
pip-compile --upgrade pyproject.toml
@echo "✓ Dependencies updated!"
# Run security checks
security:
bandit -r tenets -f json -o security-report.json
safety check --json --output safety-report.json || true
@echo "✓ Security reports generated!"
# Profile code performance
profile:
@read -p "Script to profile: " script; \
python -m cProfile -o profile.stats $$script
python -m pstats profile.stats
# Generate coverage badge
coverage-badge:
coverage-badge -o assets/coverage.svg -f
@echo "✓ Coverage badge generated!"
# Quick commit with commitizen
commit:
cz commit
# Check commit history
check-commits:
cz check --rev-range origin/master..HEAD
# Show project statistics
stats:
@echo "Project Statistics:"
@echo "==================="
@echo "Lines of code:"
@find tenets -name "*.py" -type f -exec wc -l {} + | tail -1
@echo "\nNumber of Python files:"
@find tenets -name "*.py" -type f | wc -l
@echo "\nNumber of tests:"
@find tests -name "test_*.py" -type f -exec grep -E "def test_" {} + | wc -l || echo "0"
@echo "\nTODO items:"
@grep -r "TODO" tenets tests --include="*.py" | wc -l || echo "0"
@echo "\nRanking strategies:"
@ls -1 tenets/core/ranking/strategies.py | wc -l || echo "4"
@echo "\nSummarization strategies:"
@ls -1 tenets/core/summarizer/strategies.py | wc -l || echo "5"
# Create example configuration
example-config:
@cp .tenets.example.yml .tenets.yml
@echo "✓ Created .tenets.yml from example"
@echo "Edit .tenets.yml to customize your configuration"