# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS    ?=
SPHINXBUILD   ?= sphinx-build
SOURCEDIR     = .
BUILDDIR      = _build

# Put it first so that "make" without argument is like "make help".
help:
	@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option.  $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

# --------------------------------
# This part is specific to pylint.
#---------------------------------

# Set PYLINT_SPHINX_FATAL_WARNINGS= on the command line to restore the default.
PYLINT_SPHINX_FATAL_WARNINGS = -W --keep-going

# Do not use O, we abuse it for internal purposes.
O = -d $(BUILDDIR)/doctrees -T $(PYLINT_SPHINX_FATAL_WARNINGS) -n

.PHONY clean: remove-generated-messages
remove-generated-messages:
	rm -rf user_guide/messages/convention user_guide/messages/error \
	  user_guide/messages/fatal user_guide/messages/information user_guide/messages/refactor \
	  user_guide/messages/warning

# Generated by exts/*.py but kept in the VCS for easier review of changes:
.PHONY: distclean
distclean: clean
	rm -f user_guide/checkers/extensions.rst user_guide/checkers/features.rst \
	  user_guide/configuration/all-options.rst user_guide/messages/messages_overview.rst

# Set PIP=true on the command line to skip installation of dependencies.
PIP = pip

.PHONY html: install-dependencies
install-dependencies:
	@echo "Install dependencies"
	cd ../ && $(PIP) install -r doc/requirements.txt
