# Makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS    ?= -T -E -d _build/doctrees -D language=en -W --keep-going -n
EXCLUDENB     ?= -D exclude_patterns="notebooks/*","pre_executed/*","_build","**.ipynb_checkpoints","archived_notebooks/*"
SPHINXBUILD   ?= sphinx-build
SOURCEDIR     = .
BUILDDIR      = ../_readthedocs/

.PHONY: help clean Makefile no-nb no-notebooks preview

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

# Build all Sphinx docs locally, except the notebooks
no-nb no-notebooks:
	@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(EXCLUDENB) $(O)

# Cleans up files generated by the build process
clean:
	rm -rf "_build/doctrees"
	rm -rf "autoapi"
	rm -rf "$(BUILDDIR)"

# 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)

preview:
	open $(BUILDDIR)/html/index.html

