-
Notifications
You must be signed in to change notification settings - Fork 139
Expand file tree
/
Copy pathMakefile
More file actions
68 lines (54 loc) · 2.77 KB
/
Copy pathMakefile
File metadata and controls
68 lines (54 loc) · 2.77 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
.PHONY: install test docs-install docs-build docs-serve docs-deploy docs-export docs-set-default upgrade-submodules download-bundled-contexts
PORT ?= 8000
VERSION ?=
GIT_REF ?=
ALIASES ?=
DEFAULT_VERSION ?= latest
DOCS_ALIAS_TYPE ?= copy
PUSH ?=
DOCS_DEPLOY_BRANCH ?= gh-pages
DOCS_DEPLOY_REMOTE ?= origin
DOCS_EXPORT_DIR ?= site-versioned
DOCS_RETRO_WORKTREE ?= .docs-retro-worktree
MIKE_FLAGS ?=
MIKE_PUSH = $(if $(PUSH),--push,)
install:
uv sync --locked
test:
uv run --locked pytest --cov=pyld
docs-install:
uv sync --locked --no-default-groups --group docs --extra cli
docs-build: docs-install
uv run --no-sync mkdocs build --strict
docs-serve: docs-install
uv run --no-sync mkdocs serve --dev-addr 127.0.0.1:$(PORT)
docs-deploy: docs-install
@test -n "$(VERSION)" || (echo "VERSION is required, e.g. VERSION=3.2 make docs-deploy"; exit 1)
@if [ -n "$(GIT_REF)" ]; then \
test ! -e "$(DOCS_RETRO_WORKTREE)" || (echo "$(DOCS_RETRO_WORKTREE) already exists"; exit 1); \
set -e; \
trap 'git worktree remove --force "$(DOCS_RETRO_WORKTREE)"' EXIT; \
git worktree add --detach "$(DOCS_RETRO_WORKTREE)" "$(GIT_REF)"; \
: "Older tags predate Material's mike version selector config, so patch mkdocs.yml."; \
uv run --no-sync python -c 'from pathlib import Path; p = Path("$(DOCS_RETRO_WORKTREE)/mkdocs.yml"); s = p.read_text(); b = "extra:\n version:\n provider: mike\n\n"; p.write_text(s if "provider: mike" in s else s.replace("extra_css:", b + "extra_css:", 1) if "extra_css:" in s else s.rstrip() + "\n\n" + b)'; \
uv pip install --python .venv --editable "$(DOCS_RETRO_WORKTREE)"; \
uv run --no-sync mike deploy --config-file "$(DOCS_RETRO_WORKTREE)/mkdocs.yml" --update-aliases --alias-type=$(DOCS_ALIAS_TYPE) --remote $(DOCS_DEPLOY_REMOTE) --branch $(DOCS_DEPLOY_BRANCH) $(MIKE_PUSH) $(MIKE_FLAGS) $(VERSION) $(ALIASES); \
else \
uv run --no-sync mike deploy --update-aliases --alias-type=$(DOCS_ALIAS_TYPE) --remote $(DOCS_DEPLOY_REMOTE) --branch $(DOCS_DEPLOY_BRANCH) $(MIKE_PUSH) $(MIKE_FLAGS) $(VERSION) $(ALIASES); \
fi
docs-export:
@test ! -e "$(DOCS_EXPORT_DIR)" || (echo "$(DOCS_EXPORT_DIR) already exists"; exit 1)
mkdir "$(DOCS_EXPORT_DIR)"
git archive "$(DOCS_DEPLOY_BRANCH)" | tar -x -C "$(DOCS_EXPORT_DIR)"
docs-set-default: docs-install
uv run --no-sync mike set-default --remote $(DOCS_DEPLOY_REMOTE) --branch $(DOCS_DEPLOY_BRANCH) $(MIKE_PUSH) $(MIKE_FLAGS) $(DEFAULT_VERSION)
upgrade-submodules:
git submodule update --remote --init --recursive
download-bundled-contexts:
uv run --locked python scripts/download_contexts.py
RUFF_TARGET = lib/pyld/*.py lib/pyld/cli/*.py lib/pyld/cli/commands/*.py tests docs_macros.py
lint:
uv run --locked ruff check $(RUFF_TARGET)
fmt:
uv run --locked ruff check --fix $(RUFF_TARGET)
uv run --locked ruff format $(RUFF_TARGET)