numpy

Форк
0
/
Makefile 
213 строк · 7.8 Кб
1
# Makefile for Sphinx documentation
2
#
3

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).
6

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
9

10
PYVER:=$(shell python3 -c 'from sys import version_info as v; print("{0}.{1}".format(v[0], v[1]))')
11
PYTHON = python$(PYVER)
12

13
# You can set these variables from the command line.
14
SPHINXOPTS    ?= -W
15
SPHINXBUILD   ?= LANG=C sphinx-build
16
PAPER         ?=
17
DOXYGEN       ?= doxygen
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')
22

23
FILES=
24

25
# Internal variables.
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)) \
29
                  $(SPHINXOPTS) source
30

31
.PHONY: help clean html web htmlhelp latex changes linkcheck \
32
	dist dist-build gitwash-update version-check html-build latex-build \
33
	merge-doc show docenv
34

35
#------------------------------------------------------------------------------
36

37
help:
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"
50

51
clean:
52
	-rm -rf build/*
53
	find . -name generated -type d -prune -exec rm -rf "{}" ";"
54

55
gitwash-update:
56
	rm -rf source/dev/gitwash
57
	install -d source/dev/gitwash
58
	python $(GITWASH)/gitwash_dumper.py source/dev NumPy \
59
	    --repo-name=numpy \
60
	    --github-user=numpy
61
	cat source/dev/gitwash_links.txt >> source/dev/gitwash/git_links.inc
62

63
#------------------------------------------------------------------------------
64
# Automated generation of all documents
65
#------------------------------------------------------------------------------
66

67
# Build the current numpy version, and extract docs from it.
68
# We have to be careful of some issues:
69
#
70
# - Everything must be done using the same Python version
71
#
72

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)
76

77
version-check:
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)"'
83
	@exit 1
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) ..."'
87
	@exit 1
88
else
89
	# for testing
90
	# @echo installed numpy $(NUMPYVER) matches git version $(GITVER); exit 1
91
endif
92

93

94
dist: build/dist.tar.gz
95

96
build/dist.tar.gz: real-dist
97

98
real-dist: html-build
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
104

105
merge-doc: build/dist.tar.gz
106
ifeq "$(TAG)" ""
107
	echo tag "$(TAG)" not of the form 1.18;
108
	exit 1;
109
endif
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; \
113
	fi;
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
122
	@echo " "
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\"
130

131

132
#------------------------------------------------------------------------------
133
# Basic Sphinx generation rules for different formats
134
#------------------------------------------------------------------------------
135

136
generate: build/generate-stamp
137
build/generate-stamp: $(wildcard source/reference/*.rst)
138
	mkdir -p build
139
	touch build/generate-stamp
140

141
html: version-check html-build
142
html-build: generate
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."
147
else
148
	$(DOXYGEN) build/doxygen/Doxyfile
149
endif
150
	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html $(FILES)
151
	$(PYTHON) postprocess.py html build/html/*.html
152
	@echo
153
	@echo "Build finished. The HTML pages are in build/html."
154

155
htmlhelp: generate version-check
156
	mkdir -p build/htmlhelp build/doctrees
157
	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp $(FILES)
158
	@echo
159
	@echo "Build finished; now you can run HTML Help Workshop with the" \
160
	      ".hhp project file in build/htmlhelp."
161

162
htmlhelp-build: htmlhelp build/htmlhelp/numpy.chm
163
%.chm: %.hhp
164
	-hhc.exe $^
165

166
qthelp: generate version-check
167
	mkdir -p build/qthelp build/doctrees
168
	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) build/qthelp $(FILES)
169

170
latex: version-check latex-build
171
latex-build: generate
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
176
	@echo
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."
180

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"
185

186
changes: generate version-check
187
	mkdir -p build/changes build/doctrees
188
	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes $(FILES)
189
	@echo
190
	@echo "The overview file is in build/changes."
191

192
linkcheck: generate version-check
193
	mkdir -p build/linkcheck build/doctrees
194
	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck $(FILES)
195
	@echo
196
	@echo "Link check complete; look for any errors in the above output " \
197
	      "or in build/linkcheck/output.txt."
198
texinfo:
199
	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) build/texinfo
200
	@echo
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)."
204

205
info:
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."
210

211

212
show:
213
	@python -c "import webbrowser; webbrowser.open_new_tab('file://$(PWD)/build/html/index.html')"
214

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.