|
1 | | -# Minimal makefile for Sphinx documentation |
| 1 | +# Minimal mkdocs makefile |
2 | 2 |
|
3 | | -# You can set these variables from the command line, and also |
4 | | -# from the environment for the first two. |
5 | | -SPHINXOPTS ?= |
6 | | -SPHINXBUILD ?= sphinx-build |
7 | | -SOURCEDIR = source |
8 | | -BUILDDIR = build |
| 3 | +PYTHON := python3 |
| 4 | +MKDOCS_CMD := mkdocs |
| 5 | +MKDOCS_CONF := ../mkdocs.yml |
9 | 6 |
|
10 | | -EXAMPLES_SRC = ../examples |
11 | | -EXAMPLES_DST = $(SOURCEDIR)/doc |
| 7 | +.PHONY: help install serve build clean |
12 | 8 |
|
13 | | -.PHONY: help Makefile clean update-examples html |
14 | | - |
15 | | -# Default target |
16 | 9 | help: |
17 | | - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
| 10 | + @echo "Available targets:" |
| 11 | + @echo " install Install dependencies globally" |
| 12 | + @echo " serve Serve docs locally" |
| 13 | + @echo " build Build static site" |
| 14 | + @echo " clean Remove build artifacts" |
18 | 15 |
|
19 | | -# Clean build and copied example files |
20 | | -clean: |
21 | | - @$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
22 | | - rm -rf $(EXAMPLES_DST) |
| 16 | +install: |
| 17 | + pip install -e "../[dev]" |
23 | 18 |
|
24 | | -# Copies .md files from ../examples/ to source/doc/, and updates docs/examples.md |
25 | | -update-examples: |
26 | | - rm -rf $(EXAMPLES_DST) |
27 | | - mkdir -p $(EXAMPLES_DST) |
28 | | - DOCS_ROOT=$$(pwd); \ |
29 | | - cd $(EXAMPLES_SRC) && find . -name '*.md' -type f -exec sh -c ' \ |
30 | | - DOCS_ROOT="'"$$DOCS_ROOT"'"; \ |
31 | | - EXAMPLES_DST="'"$(EXAMPLES_DST)"'"; \ |
32 | | - for f; do \ |
33 | | - mkdir -p "$$DOCS_ROOT/$$EXAMPLES_DST/$$(dirname "$$f")"; \ |
34 | | - cp "$$f" "$$DOCS_ROOT/$$EXAMPLES_DST/$$f"; \ |
35 | | - done' sh {} + |
36 | | - @echo "Generating source/examples.md..." |
37 | | - @./scripts/copy-example-docs.sh |
| 19 | +serve: |
| 20 | + $(MKDOCS_CMD) serve --livereload -f $(MKDOCS_CONF) |
38 | 21 |
|
39 | | -# Build docs and optionally serve locally |
40 | | -html: clean update-examples |
41 | | - @$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
42 | | - @if [ -z "$$CI" ]; then \ |
43 | | - echo "Starting local HTTP server at http://localhost:8000"; \ |
44 | | - python3 -m http.server --directory $(BUILDDIR)/html; \ |
45 | | - fi |
| 22 | +build: |
| 23 | + $(MKDOCS_CMD) build -f $(MKDOCS_CONF) |
46 | 24 |
|
47 | | -# Catch-all target: route all unknown targets to Sphinx using the new |
48 | | -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). |
49 | | -%: Makefile |
50 | | - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
| 25 | +clean: |
| 26 | + rm -rf site/ .cache/ |
0 commit comments