.PHONY: help install install-dev test coverage lint format clean docs build publish

help:
	@echo "aichem-gloss Makefile Commands:"
	@echo "  make install      - Install package"
	@echo "  make install-dev  - Install with dev dependencies"
	@echo "  make test         - Run tests"
	@echo "  make coverage     - Run tests with coverage report"
	@echo "  make lint         - Run code linting"
	@echo "  make format       - Format code with black"
	@echo "  make docs         - Build documentation"
	@echo "  make clean        - Clean build artifacts"
	@echo "  make build        - Build distribution packages"
	@echo "  make publish      - Publish to PyPI (use with caution)"

install:
	pip install -e .

install-dev:
	pip install -e ".[dev,docs]"

test:
	pytest tests/ -v

coverage:
	pytest tests/ -v --cov=aichem_gloss --cov-report=html --cov-report=term
	@echo "Coverage report generated in htmlcov/index.html"

lint:
	flake8 aichem_gloss/ tests/ --max-line-length=100 --ignore=E203,W503
	@echo "Linting passed!"

format:
	black aichem_gloss/ tests/ examples/ --line-length=100
	@echo "Code formatted!"

docs:
	cd docs && make clean && make html
	@echo "Documentation built in docs/build/html/"

clean:
	rm -rf build/ dist/ *.egg-info
	rm -rf htmlcov/ .coverage .pytest_cache/
	rm -rf docs/build/
	find . -type d -name __pycache__ -exec rm -rf {} +
	find . -type f -name "*.pyc" -delete
	@echo "Cleaned build artifacts!"

build: clean
	python -m build
	twine check dist/*
	@echo "Build complete! Packages in dist/"

publish: build
	@echo "WARNING: This will publish to PyPI!"
	@read -p "Are you sure? [y/N] " -n 1 -r; \
	echo; \
	if [[ $$REPLY =~ ^[Yy]$$ ]]; then \
		twine upload dist/*; \
	fi