Skip to content

Commit d4217e5

Browse files
authored
[3.11] Docs: Add make htmllive to rebuild and reload HTML files in your browser (GH-111900) (#112023)
Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent b64afbc commit d4217e5

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

Doc/Makefile

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,14 @@ PAPEROPT_letter = -D latex_elements.papersize=letterpaper
2222
ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees $(PAPEROPT_$(PAPER)) -j $(JOBS) \
2323
$(SPHINXOPTS) $(SPHINXERRORHANDLING) . build/$(BUILDER) $(SOURCES)
2424

25-
.PHONY: help build html htmlhelp latex text texinfo changes linkcheck \
26-
suspicious coverage doctest pydoc-topics htmlview clean dist check serve \
27-
autobuild-dev autobuild-stable venv
28-
25+
.PHONY: help
2926
help:
3027
@echo "Please use \`make <target>' where <target> is one of"
3128
@echo " clean to remove build files"
3229
@echo " venv to create a venv with necessary tools"
3330
@echo " html to make standalone HTML files"
3431
@echo " htmlview to open the index page built by the html target in your browser"
32+
@echo " htmllive to rebuild and reload HTML files in your browser"
3533
@echo " htmlhelp to make HTML files and a HTML help project"
3634
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
3735
@echo " text to make plain text files"
@@ -46,6 +44,7 @@ help:
4644
@echo " suspicious to check for suspicious markup in output text"
4745
@echo " check to run a check for frequent markup errors"
4846

47+
.PHONY: build
4948
build:
5049
-mkdir -p build
5150
# Look first for a Misc/NEWS file (building from a source release tarball
@@ -72,45 +71,54 @@ build:
7271
$(SPHINXBUILD) $(ALLSPHINXOPTS)
7372
@echo
7473

74+
.PHONY: html
7575
html: BUILDER = html
7676
html: build
7777
@echo "Build finished. The HTML pages are in build/html."
7878

79+
.PHONY: htmlhelp
7980
htmlhelp: BUILDER = htmlhelp
8081
htmlhelp: build
8182
@echo "Build finished; now you can run HTML Help Workshop with the" \
8283
"build/htmlhelp/pydoc.hhp project file."
8384

85+
.PHONY: latex
8486
latex: BUILDER = latex
8587
latex: build
8688
@echo "Build finished; the LaTeX files are in build/latex."
8789
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
8890
"run these through (pdf)latex."
8991

92+
.PHONY: text
9093
text: BUILDER = text
9194
text: build
9295
@echo "Build finished; the text files are in build/text."
9396

97+
.PHONY: texinfo
9498
texinfo: BUILDER = texinfo
9599
texinfo: build
96100
@echo "Build finished; the python.texi file is in build/texinfo."
97101
@echo "Run \`make info' in that directory to run it through makeinfo."
98102

103+
.PHONY: epub
99104
epub: BUILDER = epub
100105
epub: build
101106
@echo "Build finished; the epub files are in build/epub."
102107

108+
.PHONY: changes
103109
changes: BUILDER = changes
104110
changes: build
105111
@echo "The overview file is in build/changes."
106112

113+
.PHONY: linkcheck
107114
linkcheck: BUILDER = linkcheck
108115
linkcheck:
109116
@$(MAKE) build BUILDER=$(BUILDER) || { \
110117
echo "Link check complete; look for any errors in the above output" \
111118
"or in build/$(BUILDER)/output.txt"; \
112119
false; }
113120

121+
.PHONY: suspicious
114122
suspicious: BUILDER = suspicious
115123
suspicious:
116124
@$(MAKE) build BUILDER=$(BUILDER) || { \
@@ -123,31 +131,43 @@ suspicious:
123131
@echo "⚠ make check"
124132
@echo "⚠ instead."
125133

134+
.PHONY: coverage
126135
coverage: BUILDER = coverage
127136
coverage: build
128137
@echo "Coverage finished; see c.txt and python.txt in build/coverage"
129138

139+
.PHONY: doctest
130140
doctest: BUILDER = doctest
131141
doctest:
132142
@$(MAKE) build BUILDER=$(BUILDER) || { \
133143
echo "Testing of doctests in the sources finished, look at the" \
134144
"results in build/doctest/output.txt"; \
135145
false; }
136146

147+
.PHONY: pydoc-topics
137148
pydoc-topics: BUILDER = pydoc-topics
138149
pydoc-topics: build
139150
@echo "Building finished; now run this:" \
140151
"cp build/pydoc-topics/topics.py ../Lib/pydoc_data/topics.py"
141152

153+
.PHONY: htmlview
142154
htmlview: html
143155
$(PYTHON) -c "import os, webbrowser; webbrowser.open('file://' + os.path.realpath('build/html/index.html'))"
144156

157+
.PHONY: htmllive
158+
htmllive: SPHINXBUILD = $(VENVDIR)/bin/sphinx-autobuild
159+
htmllive: SPHINXOPTS = --re-ignore="/venv/"
160+
htmllive: html
161+
162+
.PHONY: clean
145163
clean: clean-venv
146164
-rm -rf build/*
147165

166+
.PHONY: clean-venv
148167
clean-venv:
149168
rm -rf $(VENVDIR)
150169

170+
.PHONY: venv
151171
venv:
152172
@if [ -d $(VENVDIR) ] ; then \
153173
echo "venv already exists."; \
@@ -159,6 +179,7 @@ venv:
159179
echo "The venv has been created in the $(VENVDIR) directory"; \
160180
fi
161181

182+
.PHONY: dist
162183
dist:
163184
rm -rf dist
164185
mkdir -p dist
@@ -213,10 +234,12 @@ dist:
213234
rm -r dist/python-$(DISTVERSION)-docs-texinfo
214235
rm dist/python-$(DISTVERSION)-docs-texinfo.tar
215236

237+
.PHONY: check
216238
check: venv
217239
$(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install pre-commit
218240
$(VENVDIR)/bin/python3 -m pre_commit run --all-files
219241

242+
.PHONY: serve
220243
serve:
221244
@echo "The serve target was removed, use htmlview instead (see bpo-36329)"
222245

@@ -228,22 +251,26 @@ serve:
228251
# output files)
229252

230253
# for development releases: always build
254+
.PHONY: autobuild-dev
231255
autobuild-dev:
232256
make dist SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1'
233257

234258
# for quick rebuilds (HTML only)
259+
.PHONY: autobuild-dev-html
235260
autobuild-dev-html:
236261
make html SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1'
237262

238263
# for stable releases: only build if not in pre-release stage (alpha, beta)
239264
# release candidate downloads are okay, since the stable tree can be in that stage
265+
.PHONY: autobuild-stable
240266
autobuild-stable:
241267
@case $(DISTVERSION) in *[ab]*) \
242268
echo "Not building; $(DISTVERSION) is not a release version."; \
243269
exit 1;; \
244270
esac
245271
@make autobuild-dev
246272

273+
.PHONY: autobuild-stable-html
247274
autobuild-stable-html:
248275
@case $(DISTVERSION) in *[ab]*) \
249276
echo "Not building; $(DISTVERSION) is not a release version."; \

Doc/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ sphinx==4.5.0
1010

1111
blurb
1212

13+
sphinx-autobuild
1314
sphinxext-opengraph>=0.7.1
1415

1516
# The theme used by the documentation is stored separately, so we need

0 commit comments

Comments
 (0)