|
1 |
| -# Minimal makefile for Sphinx documentation |
| 1 | +# Copyright 2025 Google LLC |
2 | 2 | #
|
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +######## Configuration ######## |
3 | 16 |
|
4 |
| -# You can set these variables from the command line, and also |
5 |
| -# from the environment for the first two. |
6 |
| -SPHINXOPTS ?= |
7 |
| -SPHINXBUILD ?= sphinx-build |
8 |
| -SOURCEDIR = . |
9 |
| -BUILDDIR = _build |
| 17 | +# Before we go any further, test if certain programs are available. |
| 18 | +PROGRAMS_NEEDED = sphinx-build sphinx-autobuild |
| 19 | +TEST := $(foreach p,$(PROGRAMS_NEEDED),\ |
| 20 | + $(if $(shell which $(p)),_,$(error Cannot find program "$(p)"))) |
| 21 | + |
| 22 | +# The first two can be overridden via env vars. |
| 23 | +SPHINXOPTS ?= |
| 24 | +SPHINXBUILD ?= sphinx-build |
| 25 | +SPHINXAUTO = sphinx-autobuild |
| 26 | +SPHINXAUTOOPTS = --open-browser -j auto |
| 27 | +SOURCEDIR = . |
| 28 | +BUILDDIR = _build |
| 29 | + |
| 30 | +.PHONY: help Makefile |
| 31 | + |
| 32 | +######## Targets ######## |
10 | 33 |
|
11 | 34 | # Put it first so that "make" without argument is like "make help".
|
12 | 35 | help:
|
13 | 36 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
14 | 37 |
|
15 |
| -.PHONY: help Makefile |
| 38 | +auto autobuild live livehtml: |
| 39 | + @$(SPHINXAUTO) "$(SOURCEDIR)" "$(BUILDDIR)"/html $(SPHINXOPTS) $(SPHINXAUTOOPTS) $(O) |
| 40 | + |
| 41 | +# The next one is for working on a theme, when it's best to disable incremental builds using "-a". |
| 42 | +# The build times are much slower, but CSS and template changes are picked up, and that's critical. |
| 43 | +# C.f. https://github.com/sphinx-doc/sphinx-autobuild#working-on-a-sphinx-html-theme |
| 44 | +auto-dev: |
| 45 | + @$(SPHINXAUTO) -a "$(SOURCEDIR)" "$(BUILDDIR)"/html $(SPHINXOPTS) $(SPHINXAUTOOPTS) $(O) |
16 | 46 |
|
17 | 47 | # Catch-all target: route all unknown targets to Sphinx using the new
|
18 | 48 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
|
0 commit comments