1
# Makefile for Sphinx documentation
4
# PYVER needs to be major.minor, just "3" doesn't work - it will result in
5
# issues with the amendments to PYTHONPATH and install paths (see DIST_VARS).
7
# Use explicit "version_info" indexing since make cannot handle colon characters, and
8
# evaluate it now to allow easier debugging when printing the variable
10
PYVER:=$(shell python3 -c 'from sys import version_info as v; print("{0}.{1}".format(v[0], v[1]))')
11
PYTHON = python$(PYVER)
13
# You can set these variables from the command line.
15
SPHINXBUILD ?= LANG=C sphinx-build
18
# For merging a documentation archive into a git checkout of numpy/doc
19
# Turn a tag like v1.18.0 into 1.18
20
# Use sed -n -e 's/pattern/match/p' to return a blank value if no match
21
TAG ?= $(shell git describe --tag | sed -n -e's,v\([1-9]\.[0-9]*\)\.[0-9].*,\1,p')
26
PAPEROPT_a4 = -D latex_paper_size=a4
27
PAPEROPT_letter = -D latex_paper_size=letter
28
ALLSPHINXOPTS = -T --keep-going -d build/doctrees $(PAPEROPT_$(PAPER)) \
31
.PHONY: help clean html web htmlhelp latex changes linkcheck \
32
dist dist-build gitwash-update version-check html-build latex-build \
35
#------------------------------------------------------------------------------
38
@echo "Please use \`make <target>' where <target> is one of"
39
@echo " clean to remove generated doc files and start fresh"
40
@echo " docenv make a virtual environment in which to build docs"
41
@echo " html to make standalone HTML files"
42
@echo " htmlhelp to make HTML files and a HTML help project"
43
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
44
@echo " changes to make an overview over all changed/added/deprecated items"
45
@echo " linkcheck to check all external links for integrity"
46
@echo " dist PYVER=... to make a distribution-ready tree"
47
@echo " gitwash-update GITWASH=path/to/gitwash update gitwash developer docs"
48
@echo " merge-doc TAG=... to clone numpy/doc and archive documentation into it"
49
@echo " show to show the html output in a browser"
53
find . -name generated -type d -prune -exec rm -rf "{}" ";"
56
rm -rf source/dev/gitwash
57
install -d source/dev/gitwash
58
python $(GITWASH)/gitwash_dumper.py source/dev NumPy \
61
cat source/dev/gitwash_links.txt >> source/dev/gitwash/git_links.inc
63
#------------------------------------------------------------------------------
64
# Automated generation of all documents
65
#------------------------------------------------------------------------------
67
# Build the current numpy version, and extract docs from it.
68
# We have to be careful of some issues:
70
# - Everything must be done using the same Python version
73
#SPHINXBUILD="LANG=C sphinx-build"
74
NUMPYVER:=$(shell $(PYTHON) -c "import numpy; print(numpy.version.git_revision[:7])" 2>/dev/null)
75
GITVER ?= $(shell (cd ..; set -o pipefail && git rev-parse HEAD 2>/dev/null | cut -c1-7) || echo Unknown)
78
ifeq "$(GITVER)" "Unknown"
79
# @echo sdist build with unlabeled sources
80
else ifeq ("", "$(NUMPYVER)")
81
@echo numpy not found, cannot build documentation without successful \"import numpy\"
82
@echo Try overriding the makefile PYTHON variable with '"make PYTHON=python $(MAKECMDGOALS)"'
84
else ifneq ($(NUMPYVER),$(GITVER))
85
@echo installed numpy $(NUMPYVER) != current repo git version \'$(GITVER)\'
86
@echo use '"make dist"' or '"GITVER=$(NUMPYVER) make $(MAKECMDGOALS) ..."'
90
# @echo installed numpy $(NUMPYVER) matches git version $(GITVER); exit 1
94
dist: build/dist.tar.gz
96
build/dist.tar.gz: real-dist
99
cp -r build/html build/dist
100
cd build/html && zip -9r ../dist/numpy-html.zip .
101
cd build/dist && tar czf ../dist.tar.gz *
102
chmod ug=rwX,o=rX -R build/dist
103
find build/dist -type d -print0 | xargs -0r chmod g+s
105
merge-doc: build/dist.tar.gz
107
echo tag "$(TAG)" not of the form 1.18;
110
@# Only clone if the directory does not exist
111
@if ! test -d build/merge; then \
112
git clone https://github.com/numpy/doc build/merge; \
114
@# Remove any old content and copy in the new, add it to git
115
-rm -rf build/merge/$(TAG)/*
116
-mkdir -p build/merge/$(TAG)
117
@# -C changes working directory
118
tar -C build/merge/$(TAG) -xf build/dist.tar.gz
119
git -C build/merge add $(TAG)
120
@# For now, the user must do this. If it is onerous, automate it and change
121
@# the instructions in doc/RELEASE_WALKTHROUGH.rst
123
@echo New documentation archive added to ./build/merge.
124
@echo Now add/modify the appropriate section after
125
@echo " <!-- insert here -->"
126
@echo in build/merge/index.html,
127
@echo change _static/versions.json,
128
@echo and run \"python3 update.py\"
129
@echo then \"git commit\", \"git push\"
132
#------------------------------------------------------------------------------
133
# Basic Sphinx generation rules for different formats
134
#------------------------------------------------------------------------------
136
generate: build/generate-stamp
137
build/generate-stamp: $(wildcard source/reference/*.rst)
139
touch build/generate-stamp
141
html: version-check html-build
143
mkdir -p build/html build/doctrees
144
$(PYTHON) preprocess.py
145
ifeq (, $(shell which $(DOXYGEN)))
146
@echo "Unable to find 'Doxygen:$(DOXYGEN)', skip generating C/C++ API from comment blocks."
148
$(DOXYGEN) build/doxygen/Doxyfile
150
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html $(FILES)
151
$(PYTHON) postprocess.py html build/html/*.html
153
@echo "Build finished. The HTML pages are in build/html."
155
htmlhelp: generate version-check
156
mkdir -p build/htmlhelp build/doctrees
157
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp $(FILES)
159
@echo "Build finished; now you can run HTML Help Workshop with the" \
160
".hhp project file in build/htmlhelp."
162
htmlhelp-build: htmlhelp build/htmlhelp/numpy.chm
166
qthelp: generate version-check
167
mkdir -p build/qthelp build/doctrees
168
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) build/qthelp $(FILES)
170
latex: version-check latex-build
172
mkdir -p build/latex build/doctrees
173
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex $(FILES)
174
$(PYTHON) postprocess.py tex build/latex/*.tex
175
perl -pi -e 's/LATEXOPTS =/LATEXOPTS ?= --halt-on-error/' build/latex/Makefile
177
@echo "Build finished; the LaTeX files are in build/latex."
178
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
179
"run these through (pdf)latex."
181
coverage: build version-check
182
mkdir -p build/coverage build/doctrees
183
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) build/coverage $(FILES)
184
@echo "Coverage finished; see c.txt and python.txt in build/coverage"
186
changes: generate version-check
187
mkdir -p build/changes build/doctrees
188
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes $(FILES)
190
@echo "The overview file is in build/changes."
192
linkcheck: generate version-check
193
mkdir -p build/linkcheck build/doctrees
194
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck $(FILES)
196
@echo "Link check complete; look for any errors in the above output " \
197
"or in build/linkcheck/output.txt."
199
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) build/texinfo
201
@echo "Build finished. The Texinfo files are in build/texinfo."
202
@echo "Run \`make' in that directory to run these through makeinfo" \
203
"(use \`make info' here to do that automatically)."
206
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) build/texinfo
207
@echo "Running Texinfo files through makeinfo..."
208
make -C build/texinfo info
209
@echo "makeinfo finished; the Info files are in build/texinfo."
213
@python -c "import webbrowser; webbrowser.open_new_tab('file://$(PWD)/build/html/index.html')"