diff --git a/Makefile b/Makefile index 3f3963296..38b476628 100644 --- a/Makefile +++ b/Makefile @@ -14,12 +14,12 @@ PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp \ - devhelp epub latex latexpdf text man changes linkcheck doctest check \ - serve + devhelp epub latex latexpdf text man changes linkcheck doctest htmlview check help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" + @echo " htmlview to open the index page built by the html target in your browser" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @@ -36,7 +36,6 @@ help: @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" @echo " check to run a check for frequent markup errors" - @echo " serve to serve devguide on the localhost (8000)" clean: -rm -rf $(BUILDDIR)/* @@ -139,8 +138,12 @@ doctest: venv @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." +htmlview: html + $(PYTHON) -c "import os, webbrowser; webbrowser.open('file://' + os.path.realpath('_build/html/index.html'))" + check: $(PYTHON) tools/rstlint.py -i tools -i venv -serve: html - tools/serve.py _build/html +serve: + @echo "The 'serve' target was removed, use 'htmlview' instead" \ + "(see https://github.com/python/cpython/issues/80510)" diff --git a/make.bat b/make.bat index aeb35f313..cba6cb9d5 100644 --- a/make.bat +++ b/make.bat @@ -17,13 +17,13 @@ if NOT "%PAPER%" == "" ( ) if "%1" == "check" goto check -if "%1" == "serve" goto serve if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files + echo. htmlview to open the index page built by the html target in your browser echo. dirhtml to make HTML files named index.html in directories echo. singlehtml to make a single large HTML file echo. pickle to make pickle files @@ -39,7 +39,6 @@ if "%1" == "help" ( echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled echo. check to check for stylistic and formal issues using rstlint - echo. serve to serve devguide on the localhost ^(8000^) goto end ) @@ -49,7 +48,7 @@ if "%1" == "clean" ( goto end ) -rem Targets other than "clean", "check", "serve", "help", or "" need the +rem Targets other than "clean", "check", "help", or "" need the rem Sphinx build command, which the user may define via SPHINXBUILD. if not defined SPHINXBUILD ( @@ -72,6 +71,17 @@ if "%1" == "html" ( goto end ) +if "%1" == "htmlview" ( + cmd /C %this% html + + if EXIST "%BUILDDIR%\html\index.html" ( + echo.Opening "%BUILDDIR%\html\index.html" in the default web browser... + start "" "%BUILDDIR%\html\index.html" + ) + + goto end +) + if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml if errorlevel 1 exit /b 1 @@ -196,7 +206,8 @@ cmd /C %PYTHON% tools\rstlint.py -i tools -i venv goto end :serve -cmd /C %PYTHON% tools\serve.py %BUILDDIR%\html + echo.The serve target was removed, use htmlview instead ^ +(see https://github.com/python/cpython/issues/80510) goto end :end diff --git a/tools/serve.py b/tools/serve.py deleted file mode 100755 index 98b1e5d46..000000000 --- a/tools/serve.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python3 -''' -Small wsgiref based web server. Takes a path to serve from and an -optional port number (defaults to 8000), then tries to serve files. -Mime types are guessed from the file names, 404 errors are raised -if the file is not found. Used for the make serve target in Doc. -''' -import sys -import os -import mimetypes -from wsgiref import simple_server, util - - -def app(environ, respond): - - fn = os.path.join(path, environ['PATH_INFO'][1:]) - if '.' not in fn.split(os.path.sep)[-1]: - fn = os.path.join(fn, 'index.html') - type = mimetypes.guess_type(fn)[0] - - if os.path.exists(fn): - respond('200 OK', [('Content-Type', type)]) - return util.FileWrapper(open(fn, "rb")) - else: - respond('404 Not Found', [('Content-Type', 'text/plain')]) - return [b'not found'] - - -if __name__ == '__main__': - path = sys.argv[1] - port = int(sys.argv[2]) if len(sys.argv) > 2 else 8000 - httpd = simple_server.make_server('', port, app) - print("Serving {} on http://localhost:{}, control-C to stop".format(path, port)) - try: - httpd.serve_forever() - except KeyboardInterrupt: - print("\b\bShutting down.")