.PHONY: help venv install test lint typecheck docs clean

VENV      := .venv
PYTHON    := $(VENV)/bin/python
PIP       := $(VENV)/bin/pip
PYTEST    := $(VENV)/bin/pytest
ROBOT     := $(VENV)/bin/robot
LIBDOC    := $(PYTHON) -m robot.libdoc
RUFF      := $(VENV)/bin/ruff
MYPY      := $(VENV)/bin/mypy

help:  ## Show available commands
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "  \033[36m%-15s\033[0m %s\n", $$1, $$2}'

venv:  ## Create the virtual environment
	python -m venv $(VENV)
	$(PIP) install --upgrade pip

install: venv  ## Install the package with dev dependencies
	$(PIP) install -e ".[dev]"

test: ## Run unit tests with pytest
	$(PYTEST) tests/unit/ -v --tb=short

acceptance: ## Run Robot Framework acceptance tests
	$(ROBOT) --outputdir results tests/acceptance/

lint: ## Lint source code with ruff
	$(RUFF) check src/

typecheck: ## Type-check source code with mypy
	$(MYPY) src/

docs: ## Generate HTML keyword documentation with libdoc
	mkdir -p docs
	$(LIBDOC) MimesisLibrary docs/index.html
	@echo "Documentation generated at docs/index.html"

clean: ## Remove build artifacts and caches
	rm -rf dist/ build/ *.egg-info/ .pytest_cache/ .mypy_cache/ .ruff_cache/
	rm -rf results/ output.xml log.html report.html
	find . -type d -name __pycache__ -exec rm -rf {} +

all: install lint typecheck test docs  ## Run full pipeline
