-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
74 lines (59 loc) · 2.45 KB
/
Makefile
File metadata and controls
74 lines (59 loc) · 2.45 KB
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
# Minimal makefile for Sphinx documentation
#
# CONTAINER_TOOL defines the container tool to be used for building images.
# Be aware that the target commands are only tested with Docker which is
# scaffolded by default. However, you might want to replace it to use other
# tools. (i.e. podman)
CONTAINER_TOOL ?= docker
REGISTRY ?= slinky.slurm.net
DOCS_IMAGE ?= $(REGISTRY)/sphinx
# Setting SHELL to bash allows bash commands to be executed by recipes.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
##@ General
# Default target: summarize this Makefile (variables are not expanded in awk output).
help: ## Show targets, overridable variables, and local HTML output location
@echo 'Slinky docs — common targets:'
@echo ''
@awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z0-9][a-zA-Z0-9_-]*:.*?##/ { printf " %-22s %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
@echo ''
@echo 'Override on the command line, for example: make REGISTRY=my.registry run-docs'
@echo ' CONTAINER_TOOL=$(CONTAINER_TOOL)'
@echo ' REGISTRY=$(REGISTRY)'
@echo ' DOCS_IMAGE=$(DOCS_IMAGE)'
@echo ' LOCALBIN=$(LOCALBIN)'
@echo ' LOCALBUILD=$(LOCALBUILD)'
@echo ''
@echo 'Local HTML (after sphinx-build): $(LOCALBUILD)/html/index.html'
.PHONY: help Makefile
##@ Build
.PHONY: all
all: run-docs
.PHONY: build-docs
build-docs: ## Build the container image used to develop the docs
$(CONTAINER_TOOL) build -t $(DOCS_IMAGE) .
.PHONY: run-docs
run-docs: build-docs ## Run the container image for docs development
$(CONTAINER_TOOL) run --rm --network host -v ./docs:/docs:z $(DOCS_IMAGE) sphinx-autobuild --port 8000 /docs /build/html
## Location to locally build documentation
LOCALBUILD ?= $(shell pwd)/build-docs
$(LOCALBUILD):
mkdir -p $(LOCALBUILD)
.PHONY: sphinx-build
sphinx-build: sphinx-install $(LOCALBIN) $(LOCALBUILD) ## Build HTML under LOCALBUILD using a local Python venv
source $(LOCALBIN)/sphinx-venv/bin/activate ;\
sphinx-build -M html docs $(LOCALBUILD) ;\
deactivate ;\
.PHONY: sphinx-install
sphinx-install: sphinx-venv ## Install requirements.txt into the Sphinx venv
source $(LOCALBIN)/sphinx-venv/bin/activate ;\
pip install -r requirements.txt ;\
deactivate ;\
.PHONY: sphinx-venv
sphinx-venv: $(LOCALBIN) ## Create LOCALBIN/sphinx-venv for local doc builds
python3 -m venv $(LOCALBIN)/sphinx-venv