ifeq ($(IS_SVN), 0)
	ARCADIA_DIR := $(shell find "$$(svn info | grep "Working Copy Root" | cut -f2 -d: | tr -d ' ')" -maxdepth 3 -type f -name .arcadia.root | xargs dirname)
else
	ARCADIA_DIR := $(shell arc root)
endif

YA := $(ARCADIA_DIR)/ya

help: ## Display this help screen
	echo "Known targets:"
	grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
		| awk 'BEGIN {FS = ":.*?## "}; {printf "    \033[36m%-10s\033[0m %s\n", $$1, $$2}'

docs.tar.gz:
	$(YA) make

target/index.yml: docs.tar.gz
	rm -fr $(@D)
	mkdir $(@D)
	tar -xf $< -C $(@D)

build: target/index.yml ## Build documentation static site

web: build ## Build documentation and run local web server
	echo "Go to http://localhost:8080/ru/"
	cd target && python3 -m http.server 8080

clean: ## Clean all temporary files
	rm -fr docs.tar.gz preprocessed.tar.gz target/

.PHONY: help build web clean

ifndef VERBOSE
.SILENT:
endif
