-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Change Makefile to use poetry + work on windows (with the exceptio…
…n of the publish target)
- Loading branch information
Showing
2 changed files
with
39 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/_site/ | ||
/site/ | ||
/_ext/__pycache__/ | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,48 @@ | ||
# Makefile for Sphinx documentation | ||
GNUMAKEFLAGS := --no-builtins --no-builtin-variables | ||
.SUFFIXES: | ||
|
||
# You can set these variables from the command line. | ||
SPHINXOPTS = | ||
SPHINXBUILD = sphinx-build | ||
BUILDDIR = _site | ||
ifeq ($(OS),Windows_NT) | ||
--which := where | ||
--null := nul | ||
RM := rmdir /s /q | ||
else | ||
--which := which | ||
--null ?= /dev/null | ||
RM := rm -rf | ||
endif | ||
|
||
POETRY ?= $(shell $(--which) poetry 2> $(--null)) | ||
|
||
# User-friendly check for sphinx-build | ||
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) | ||
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) | ||
ifeq (${POETRY},) | ||
$(error Could not find the `poetry` command. \ | ||
Please make sure you have installed poetry, and that it is on your system's PATH environment variable. \ | ||
If you don't have poetry installed, please visit https://python-poetry.org for instructions on its installation.) | ||
endif | ||
|
||
.PHONY: clean all | ||
venv ?= $(shell $(POETRY) env info --path 2> $(--null)) | ||
|
||
all: | ||
$(SPHINXBUILD) -b html $(SPHINXOPTS) . $(BUILDDIR) | ||
@echo | ||
@echo "Build finished. The HTML pages are in '$(BUILDDIR)'." | ||
srcdir := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) | ||
|
||
clean: | ||
rm -rf $(BUILDDIR)/* | ||
build.flags += $(if $(BUILDER),-b $(BUILDER),-b html) | ||
build.flags += $(if $(NOCOLOR),,--color) | ||
build.flags += $(if $(SPHINXOPTS),$(SPHINXOPTS)) | ||
|
||
SRCDIR ?= $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) | ||
OUTDIR ?= $(join $(SRCDIR),_site) | ||
|
||
.PHONY: all setup cache-clean clean | ||
|
||
all: $(if $(venv),,setup) | ||
$(POETRY) run sphinx-build ${build.flags} "${SRCDIR}" "${OUTDIR}" | ||
|
||
cache-clean: | ||
rm -rf $(BUILDDIR)/.doctrees | ||
$(RM) "$(join $(OUTDIR),.doctrees)" | ||
|
||
clean: | ||
$(RM) "$(OUTDIR)" | ||
|
||
setup: | ||
$(POETRY) install | ||
|
||
publish: clean all | ||
./publish.sh |