Skip to content

Commit

Permalink
Add BUILDDIR var to doc/Makefile; have tox use it
Browse files Browse the repository at this point in the history
This adds BUILDDIR as a variable in the documentation generation
makefile that, along SPHINXOPTS, SPHINXBUILD, and PAPER, defaults
to the usual best value but can be set when invoking make.

The main use for choosing a different build output directory is to
test building without overwriting or otherwise interfering with any
files from a build one may really want to use. tox.ini is thus
modified to pass a path pointing inside its temporary directory as
BUILDDIR, so the "html" tox environment now makes no changes
outside the .tox directory. This is thus suitable for being run
automatically, so the "html" environment is now in the envlist.
  • Loading branch information
EliahKagan committed Oct 3, 2023
1 parent 6de86a8 commit f094909
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
43 changes: 22 additions & 21 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#

# You can set these variables from the command line.
BUILDDIR = build
SPHINXOPTS = -W
SPHINXBUILD = sphinx-build
PAPER =

# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source

.PHONY: help clean html web pickle htmlhelp latex changes linkcheck

Expand All @@ -24,52 +25,52 @@ help:
@echo " linkcheck to check all external links for integrity"

clean:
-rm -rf build/*
-rm -rf $(BUILDDIR)/*

html:
mkdir -p build/html build/doctrees
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html
mkdir -p $(BUILDDIR)/html $(BUILDDIR)/doctrees
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in build/html."
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

pickle:
mkdir -p build/pickle build/doctrees
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle
mkdir -p $(BUILDDIR)/pickle $(BUILDDIR)/doctrees
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."

web: pickle

json:
mkdir -p build/json build/doctrees
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) build/json
mkdir -p $(BUILDDIR)/json $(BUILDDIR)/doctrees
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."

htmlhelp:
mkdir -p build/htmlhelp build/doctrees
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp
mkdir -p $(BUILDDIR)/htmlhelp $(BUILDDIR)/doctrees
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in build/htmlhelp."
".hhp project file in $(BUILDDIR)/htmlhelp."

latex:
mkdir -p build/latex build/doctrees
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex
mkdir -p $(BUILDDIR)/latex $(BUILDDIR)/doctrees
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in build/latex."
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
"run these through (pdf)latex."

changes:
mkdir -p build/changes build/doctrees
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes
mkdir -p $(BUILDDIR)/changes $(BUILDDIR)/doctrees
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in build/changes."
@echo "The overview file is in $(BUILDDIR)/changes."

linkcheck:
mkdir -p build/linkcheck build/doctrees
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck
mkdir -p $(BUILDDIR)/linkcheck $(BUILDDIR)/doctrees
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in build/linkcheck/output.txt."
"or in $(BUILDDIR)/linkcheck/output.txt."
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
requires = tox>=4
env_list = py{37,38,39,310,311,312}, lint, mypy
env_list = py{37,38,39,310,311,312}, lint, mypy, html

[testenv]
description = Run unit tests
Expand All @@ -22,11 +22,11 @@ base_python = py39
commands = mypy -p git
ignore_outcome = true

# Run "tox -e html" for this. It is deliberately excluded from env_list, as
# unlike the other environments, this one writes outside the .tox/ directory.
[testenv:html]
description = Build HTML documentation
base_python = py39
deps = -r doc/requirements.txt
allowlist_externals = make
commands = make -C doc html
commands =
make BUILDDIR={env_tmp_dir}/doc/build -C doc clean
make BUILDDIR={env_tmp_dir}/doc/build -C doc html

0 comments on commit f094909

Please sign in to comment.