# Minimal makefile for Sphinx documentation
#
# Initial set up
#   git clone git@github.com:langmm/canopy_factory.git $(REPODIR)
#   cd $(REPODIR)
#   git checkout --orphan gh-pages
#   git rm -r --cached .
#   git commit --allow-empty -m "Initial empty gh-pages branch"
#   git push origin gh-pages

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS    ?=
SPHINXBUILD   ?= sphinx-build
SPHINXPROJ    = canopy_factory
SOURCEDIR     = source
BUILDDIR      = build
REPODIR       = ../../canopy_factory_docs

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

.PHONY: help Makefile

.PHONY: clean ghpages
ghpages: autodoc
	cp -a $(BUILDDIR)/html/. $(REPODIR)/
	cd $(REPODIR) ; git pull ; git add . ; git commit -m "rebuilt docs" ; git push origin gh-pages

.PHONY: autodoc
autodoc: sphinx
	# mv $(SOURCEDIR)/yggdrasil.rst $(SOURCEDIR)/yggdrasil.inc
	make html

.PHONY: sphinx
sphinx:
	sphinx-apidoc -fT -o $(SOURCEDIR)/ ../canopy_factory


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