2022-12-15 07:07:53 +01:00
|
|
|
buildargs := -b dirhtml -aE source
|
2022-06-24 01:43:34 +00:00
|
|
|
|
2023-01-02 04:16:55 +01:00
|
|
|
.PHONY: cleanbuild clean serve serve_versions versions versions_git versions_index
|
2022-12-15 07:07:53 +01:00
|
|
|
.NOTINTERMEDIATE:
|
2023-01-02 04:16:55 +01:00
|
|
|
.PRECIOUS: versions/index.html versions/%/index.html checkouts/%/docs/html/index.html archived/%.tar.gz
|
2022-12-15 07:07:53 +01:00
|
|
|
|
|
|
|
BRANCHES := main dev
|
|
|
|
TAGS := $(shell git tag)
|
|
|
|
FILTERTED_TAGS := $(foreach tag,$(TAGS),$(shell if [[ -n "$$(git log --max-count=1 --oneline "$(tag)" -- .)" ]]; then echo "$(tag)"; fi))
|
|
|
|
VERSIONS := $(BRANCHES) $(FILTERTED_TAGS)
|
2022-06-24 01:43:34 +00:00
|
|
|
|
|
|
|
cleanbuild:
|
2022-12-15 07:07:53 +01:00
|
|
|
@$(MAKE) clean
|
|
|
|
@$(MAKE) html
|
2022-06-24 01:43:34 +00:00
|
|
|
|
|
|
|
clean:
|
2022-12-15 07:07:53 +01:00
|
|
|
rm -rf html source/cli .buildinfo .doctrees versions checkouts
|
2022-06-24 01:43:34 +00:00
|
|
|
|
|
|
|
html:
|
2022-12-15 07:07:53 +01:00
|
|
|
sphinx-build $(SPHINXARGS) $(buildargs) html
|
2022-06-24 01:43:34 +00:00
|
|
|
|
|
|
|
serve: html
|
2022-12-15 07:07:53 +01:00
|
|
|
cd html && python -m http.server 9999
|
|
|
|
|
|
|
|
checkouts/%/docs/html/index.html:
|
|
|
|
@mkdir -p checkouts
|
|
|
|
@# use backslashed multi-line cmd because otherwise variables will be lost
|
|
|
|
@branch="$$(echo "$(@D)" | sed 's|^checkouts/||g;s|/docs/html$$||g')" && \
|
|
|
|
ref="$$branch" && \
|
|
|
|
if ! git log --max-count=1 --oneline "$$branch" >/dev/null 2>/dev/null ; then \
|
|
|
|
commit="$$(git ls-remote origin refs/{tags,heads}/"$$branch" | cut -f 1)" ; \
|
|
|
|
[[ -n "$$commit" ]] && echo "found commit $$commit for $$branch" >&2 && \
|
|
|
|
ref="$$commit" && git branch -f "$$branch" "$$ref" ; \
|
|
|
|
fi && \
|
|
|
|
[[ -n "$$(git log --max-count=1 --oneline "$$ref" -- .)" ]] || \
|
|
|
|
(echo "ERROR: branch '$$branch' seems to have no docs/ dir, checked ref '$$ref'" >&2 && exit 1) && \
|
|
|
|
checkout="checkouts/$$branch" && \
|
|
|
|
ver="$$(echo "$$branch" | sed 's|^v\([0-9]\)|\1|g')" && \
|
|
|
|
set -x && \
|
|
|
|
([[ -e "$$checkout/.git" ]] || git clone .. "$$checkout" ) && \
|
|
|
|
(! [[ -e "$$checkout/docs/source/conf.py" ]] || echo "version = '$$ver'" >> "$$checkout/docs/source/conf.py") && \
|
|
|
|
$(MAKE) -C "$$checkout/docs" SPHINXARGS="-D version=$$ver"
|
|
|
|
|
2023-01-02 04:16:55 +01:00
|
|
|
archived/%.tar.gz: checkouts/%/docs/html/index.html
|
|
|
|
mkdir -p archived
|
|
|
|
tar -C "checkouts/$*/docs/html" -czf "$@" .
|
|
|
|
|
|
|
|
versions/%/index.html: archived/%.tar.gz
|
|
|
|
@mkdir -p "$(@D)"
|
|
|
|
@echo "working on version '$*'"
|
|
|
|
tar -xf "archived/$*.tar.gz" -C "$(@D)"
|
|
|
|
@# ensure index file exists and update its timestamp for Make's dependency detection
|
|
|
|
[[ -e "$(@)" ]] && touch "$(@)"
|
2022-12-15 07:07:53 +01:00
|
|
|
|
|
|
|
versions/versions.css: versjon/versions.css
|
|
|
|
@mkdir -p versions
|
|
|
|
cp versjon/versions.css versions/
|
|
|
|
|
|
|
|
versions_git:
|
|
|
|
@$(MAKE) $(patsubst %, versions/%/index.html, $(VERSIONS))
|
|
|
|
|
2023-01-02 04:16:55 +01:00
|
|
|
versions/index.html: $(sort $(wildcard versions/*/index.html))
|
2022-12-15 07:07:53 +01:00
|
|
|
rm -rf versions/stable
|
|
|
|
@cd versions && set -x && versjon --stable-version main --user_templates ../versjon
|
2023-01-02 04:16:55 +01:00
|
|
|
@# ensure the global index.html exists and is newer than each version's index.html
|
|
|
|
[[ -e "$(@)" ]] && touch "$(@)"
|
2022-12-15 07:07:53 +01:00
|
|
|
|
|
|
|
versions: versions_git versions/versions.css
|
|
|
|
@$(MAKE) versions/index.html
|
|
|
|
|
2023-01-02 04:16:55 +01:00
|
|
|
serve_versions: versions/index.html
|
2022-12-15 07:07:53 +01:00
|
|
|
cd versions && python -m http.server 9888
|