Skip to content

Commit 542d25c

Browse files
committed
Add 'make htmlview' to open index page
1 parent 7703042 commit 542d25c

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ doc html:
2121
python3 -c "import PIL" > /dev/null 2>&1 || python3 -m pip install .
2222
$(MAKE) -C docs html
2323

24+
.PHONY: htmlview
25+
htmlview:
26+
python3 -c "import PIL" > /dev/null 2>&1 || python3 -m pip install .
27+
$(MAKE) -C docs htmlview
28+
2429
.PHONY: doccheck
2530
doccheck:
2631
$(MAKE) doc
@@ -40,6 +45,7 @@ help:
4045
@echo " doc make HTML docs"
4146
@echo " docserve run an HTTP server on the docs directory"
4247
@echo " html to make standalone HTML files"
48+
@echo " htmlview to open the index page built by the html target in your browser"
4349
@echo " inplace make inplace extension"
4450
@echo " install make and install"
4551
@echo " install-coverage make and install with C coverage"

docs/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
1919
help:
2020
@echo "Please use \`make <target>' where <target> is one of"
2121
@echo " html to make standalone HTML files"
22+
@echo " htmlview to open the index page built by the html target in your browser"
2223
@echo " serve to start a local server for viewing docs"
2324
@echo " livehtml to start a local server for viewing docs and auto-reload on change"
2425
@echo " dirhtml to make HTML files named index.html in directories"
@@ -196,6 +197,10 @@ doctest:
196197
@echo "Testing of doctests in the sources finished, look at the " \
197198
"results in $(BUILDDIR)/doctest/output.txt."
198199

200+
.PHONY: htmlview
201+
htmlview: html
202+
$(PYTHON) -c "import os, webbrowser; webbrowser.open('file://' + os.path.realpath('$(BUILDDIR)/html/index.html'))"
203+
199204
.PHONY: livehtml
200205
livehtml: html
201206
livereload $(BUILDDIR)/html -p 33233

docs/make.bat

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ if "%1" == "help" (
1919
:help
2020
echo.Please use `make ^<target^>` where ^<target^> is one of
2121
echo. html to make standalone HTML files
22+
echo. htmlview to open the index page built by the html target in your browser
2223
echo. dirhtml to make HTML files named index.html in directories
2324
echo. singlehtml to make a single large HTML file
2425
echo. pickle to make pickle files
@@ -52,6 +53,17 @@ if "%1" == "html" (
5253
goto end
5354
)
5455

56+
if "%1" == "htmlview" (
57+
cmd /C %this% html
58+
59+
if EXIST "%BUILDDIR%\html\index.html" (
60+
echo.Opening "%BUILDDIR%\html\index.html" in the default web browser...
61+
start "" "%BUILDDIR%\html\index.html"
62+
)
63+
64+
goto end
65+
)
66+
5567
if "%1" == "dirhtml" (
5668
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
5769
if errorlevel 1 exit /b 1

0 commit comments

Comments
 (0)