forked from timbury/wire-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
108 lines (89 loc) · 2.77 KB
/
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
SHELL = bash
.DEFAULT_GOAL := docs
MKFILE_DIR = $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
DOCKER_USER ?= quay.io/wire
DOCKER_IMAGE = alpine-sphinx
DOCKER_TAG ?= latest
# You can set these variables (with a ?=) from the command line, and also
# from the environment.
SPHINXOPTS ?= -q
SPHINXBUILD ?= sphinx-build
SOURCEDIR = $(MKFILE_DIR)/src
BUILDDIR = $(MKFILE_DIR)/build
# note: if you're using direnv/nix, this will be set to USE_POETRY=0 automatically in .envrc
USE_POETRY ?= 1
ifeq ($(OS), darwin)
OPEN := open
else
OPEN := xdg-open
endif
.PHONY: Makefile
.DEFAULT: docs
.PHONY: docs
docs:
docker run --rm -v $$(pwd):/mnt $(DOCKER_USER)/$(DOCKER_IMAGE):$(DOCKER_TAG) make clean html
.PHONY: docs-pdf
docs-pdf:
docker run --rm -v $$(pwd):/mnt $(DOCKER_USER)/$(DOCKER_IMAGE):$(DOCKER_TAG) make clean pdf
.PHONY: docs-all
docs-all:
docker run --rm -v $$(pwd):/mnt $(DOCKER_USER)/$(DOCKER_IMAGE):$(DOCKER_TAG) make clean html pdf
.PHONY: clean
clean:
rm -rf "$(BUILDDIR)"
# Only build part of the documentation
# See 'exclude_patterns' in source/conf.py
docs-administrate:
docker run --rm -e SPHINXOPTS='-t administrate' -v $$(pwd):/mnt $(DOCKER_USER)/$(DOCKER_IMAGE):$(DOCKER_TAG) make clean html
cd build && zip -r administration-wire-$$(date +"%Y-%m-%d").zip html
.PHONY: exec
exec:
docker run -it -v $(MKFILE_DIR):/mnt $(DOCKER_USER)/$(DOCKER_IMAGE):$(DOCKER_TAG)
.PHONY: docker
docker:
docker build -t $(DOCKER_USER)/$(DOCKER_IMAGE):$(DOCKER_TAG) $(MKFILE_DIR)
.PHONY: docker-push
docker-push:
docker push $(DOCKER_USER)/$(DOCKER_IMAGE):$(DOCKER_TAG)
.PHONY: push
push:
ifeq ($(USE_POETRY), 1)
source $$HOME/.poetry/env && \
poetry run aws s3 sync $(BUILDDIR)/html s3://origin-docs.wire.com/
else
aws s3 sync $(BUILDDIR)/html s3://origin-docs.wire.com/
endif
.PHONY: dev-run
dev-run: clean
ifeq ($(USE_POETRY), 1)
source $$HOME/.poetry/env && \
poetry run sphinx-autobuild \
--port 3000 \
--host 127.0.0.1 \
-b html \
$(SPHINXOPTS) \
"$(SOURCEDIR)" "$(BUILDDIR)"
else
sphinx-autobuild \
--port 3000 \
--host 127.0.0.1 \
-b html \
$(SPHINXOPTS) \
"$(SOURCEDIR)" "$(BUILDDIR)"
endif
.PHONY: dev-pdf
dev-pdf: pdf
$(OPEN) build/pdf/wire_federation.pdf 2>&1 > /dev/null &
find src/ | entr make pdf
.PHONY: help
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS)
# Catch-all target: route all unknown targets to Sphinx. This "converts" unknown targets into sub-commands (or more precicly
# into `buildername`) of the $(SPHINXBUILD) CLI (see https://www.gnu.org/software/make/manual/html_node/Last-Resort.html).
%:
ifeq ($(USE_POETRY), 1)
source $$HOME/.poetry/env && \
poetry run $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS)
else
$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS)
endif