-
Notifications
You must be signed in to change notification settings - Fork 20
/
doc.Makefile
73 lines (66 loc) · 2.9 KB
/
doc.Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Makefile for Sphinx documentation
# Top-level directory of all the ReST source files
GH_SOURCE_DIR = doc
# Repository branch that contains the source
GH_SOURCE_BRANCH = main
# Repository branch that contains the rendered HTML
GH_PUBLISH_BRANCH = gh-pages
# Repository that contains the rendered HTML
GH_UPSTREAM_URL = git@github.com:svalinn/ALARA
# Makefile for building documentation (may be standard may need to be custom)
DOC_MAKEFILE = doc.Makefile
# Directory that contains the rendered HTML
BUILDDIR = gh-build
# Sphinx executable
SPHINXBUILD = sphinx-build
# Sphinx options
SPHINXOPTS =
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(GH_SOURCE_DIR)
help:
@echo "Please use \"make <target\" where <target> is one of"
@echo " html to build HTML in directory \"$(BUILDDIR)\" for testing"
@echo " clean to cleanup HTML build in directory \"$(BUILDDIR)\" after testing"
@echo " publish final build and push from \"$(GH_SOURCE_BRANCH)\" branch to \"$(GH_PUBLISH_BRANCH)\" branch"
clean:
-rm -rf $(BUILDDIR)
html:
$(SPHINXBUILD) -nvW -b html $(ALLSPHINXOPTS) $(BUILDDIR)
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)."
check_ready_for_publish:
$(eval CURRENT_BRANCH = $(shell git rev-parse --abbrev-ref --symbolic-full-name @{u}))
@if [ $(CURRENT_BRANCH) != origin/$(GH_SOURCE_BRANCH) ]; then \
echo "On branch \"$(CURRENT_BRANCH)\"; must be on branch \"origin/$(GH_SOURCE_BRANCH)\". Cannot publish."; \
exit 1; \
fi
$(eval CURRENT_URL = $(shell git config --get remote.origin.url))
@if [ $(CURRENT_URL) != $(GH_UPSTREAM_URL) ]; then \
echo "The origin remote points to \"$(CURRENT_URL)\"; must point to \"$(GH_UPSTREAM_URL)\". Cannot publish."; \
exit 1; \
fi
$(eval EXTRA_COMMITS = $(shell git rev-list $(CURRENT_BRANCH)...origin/$(GH_SOURCE_BRANCH)))
@if [ "$(EXTRA_COMMITS)" != "" ]; then \
echo "Current branch \"$(CURRENT_BRANCH)\" is not up-to-date with \"origin/$(GH_SOURCE_BRANCH)\". Cannot publish."; \
exit 1; \
fi
$(eval UNSTAGED_CHANGES = $(shell git status --porcelain))
@if [ "$(UNSTAGED_CHANGES)" != "" ]; then \
echo "There are changes not staged for commit. Cannot publish."; \
exit 1; \
fi
# don't invoke checks for the time being - not sure they are always valid - definitely not documented
# publish: check_ready_for_publish
publish:
git checkout $(GH_PUBLISH_BRANCH) && \
rm -rf * && \
git checkout $(GH_SOURCE_BRANCH) -- $(GH_SOURCE_DIR) ${DOC_MAKEFILE} && \
git reset HEAD && \
make -f ${DOC_MAKEFILE} clean && \
make -f ${DOC_MAKEFILE} html && \
rsync -a $(BUILDDIR)/* . && \
rsync -a $(BUILDDIR)/.* . && \
rm -rf $(GH_SOURCE_DIR) $(BUILDDIR) && \
git add . && \
git commit -m "Generated $(GH_PUBLISH_BRANCH) for `git log $(GH_SOURCE_BRANCH) -1 --pretty=short --abbrev-commit`" && \
git push $(GH_UPSTREAM_URL) $(GH_PUBLISH_BRANCH) && \
git checkout $(GH_SOURCE_BRANCH)