From 8260bae1221b50954a0001199e06ba9e462eaa19 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Sun, 23 Apr 2023 16:48:18 -0400 Subject: [PATCH 1/5] Replace doc Makefile, make.bat, and make.sh with make.py --- CONTRIBUTING.md | 22 +++- doc/Makefile | 192 ---------------------------- doc/make.bat | 263 -------------------------------------- doc/make.py | 330 ++++++++++++++++++++++++++++++++++++++++++++++++ doc/make.sh | 1 - pyproject.toml | 83 ++++++++++++ 6 files changed, 434 insertions(+), 457 deletions(-) delete mode 100644 doc/Makefile delete mode 100644 doc/make.bat create mode 100644 doc/make.py delete mode 100755 doc/make.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1d79d340f..7337dbaad 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -81,9 +81,29 @@ Change into the doc directory: cd doc ``` +Run the doc build to build the web page files, and host a webserver to preview: +```commandline +python ./make.py serve +``` + +You can now open [http://localhost:8000](http://localhost:8000) in your browser to preview the docs. + +The `build/html` directory will contain the generated website files. When you change source files, +it will automatically regenerate, and browser tabs will automatically refresh to show your updates. + +If you suspect the automatic rebuilds are failing to detect changes, you can +run a simpler one-time build using the following instructions. + +#### One-time build + +Change into the doc directory: +```commandline +cd doc +``` + Run the doc build to build the web page files: ```commandline -make html +python ./make.py html ``` The `build/html` directory will contain the generated website files. diff --git a/doc/Makefile b/doc/Makefile deleted file mode 100644 index 94a6ed19b..000000000 --- a/doc/Makefile +++ /dev/null @@ -1,192 +0,0 @@ -# Makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -PAPER = -BUILDDIR = build - -# User-friendly check for sphinx-build -ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) -$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) -endif - -# Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . -# the i18n builder cannot share the environment and doctrees with the others -I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . - -.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext - -help: - @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @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" - @echo " json to make JSON files" - @echo " htmlhelp to make HTML files and a HTML help project" - @echo " qthelp to make HTML files and a qthelp project" - @echo " applehelp to make an Apple Help Book" - @echo " devhelp to make HTML files and a Devhelp project" - @echo " epub to make an epub" - @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" - @echo " latexpdf to make LaTeX files and run them through pdflatex" - @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" - @echo " text to make text files" - @echo " man to make manual pages" - @echo " texinfo to make Texinfo files" - @echo " info to make Texinfo files and run them through makeinfo" - @echo " gettext to make PO message catalogs" - @echo " changes to make an overview of all changed/added/deprecated items" - @echo " xml to make Docutils-native XML files" - @echo " pseudoxml to make pseudoxml-XML files for display purposes" - @echo " linkcheck to check all external links for integrity" - @echo " doctest to run all doctests embedded in the documentation (if enabled)" - @echo " coverage to run coverage check of the documentation (if enabled)" - -clean: - rm -rf $(BUILDDIR)/* - -html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." - -dirhtml: - $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." - -singlehtml: - $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml - @echo - @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." - -pickle: - $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle - @echo - @echo "Build finished; now you can process the pickle files." - -json: - $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json - @echo - @echo "Build finished; now you can process the JSON files." - -htmlhelp: - $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp - @echo - @echo "Build finished; now you can run HTML Help Workshop with the" \ - ".hhp project file in $(BUILDDIR)/htmlhelp." - -qthelp: - $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp - @echo - @echo "Build finished; now you can run "qcollectiongenerator" with the" \ - ".qhcp project file in $(BUILDDIR)/qthelp, like this:" - @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Arcade.qhcp" - @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Arcade.qhc" - -applehelp: - $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp - @echo - @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." - @echo "N.B. You won't be able to view it unless you put it in" \ - "~/Library/Documentation/Help or install it in your application" \ - "bundle." - -devhelp: - $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp - @echo - @echo "Build finished." - @echo "To view the help file:" - @echo "# mkdir -p $$HOME/.local/share/devhelp/Arcade" - @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Arcade" - @echo "# devhelp" - -epub: - $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub - @echo - @echo "Build finished. The epub file is in $(BUILDDIR)/epub." - -latex: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo - @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." - @echo "Run \`make' in that directory to run these through (pdf)latex" \ - "(use \`make latexpdf' here to do that automatically)." - -latexpdf: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through pdflatex..." - $(MAKE) -C $(BUILDDIR)/latex all-pdf - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -latexpdfja: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through platex and dvipdfmx..." - $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -text: - $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text - @echo - @echo "Build finished. The text files are in $(BUILDDIR)/text." - -man: - $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man - @echo - @echo "Build finished. The manual pages are in $(BUILDDIR)/man." - -texinfo: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo - @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." - @echo "Run \`make' in that directory to run these through makeinfo" \ - "(use \`make info' here to do that automatically)." - -info: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo "Running Texinfo files through makeinfo..." - make -C $(BUILDDIR)/texinfo info - @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." - -gettext: - $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale - @echo - @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." - -changes: - $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes - @echo - @echo "The overview file is in $(BUILDDIR)/changes." - -linkcheck: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck - @echo - @echo "Link check complete; look for any errors in the above output " \ - "or in $(BUILDDIR)/linkcheck/output.txt." - -doctest: - $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest - @echo "Testing of doctests in the sources finished, look at the " \ - "results in $(BUILDDIR)/doctest/output.txt." - -coverage: - $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage - @echo "Testing of coverage in the sources finished, look at the " \ - "results in $(BUILDDIR)/coverage/python.txt." - -xml: - $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml - @echo - @echo "Build finished. The XML files are in $(BUILDDIR)/xml." - -pseudoxml: - $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml - @echo - @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." diff --git a/doc/make.bat b/doc/make.bat deleted file mode 100644 index cc40102a6..000000000 --- a/doc/make.bat +++ /dev/null @@ -1,263 +0,0 @@ -@ECHO OFF - -REM Command file for Sphinx documentation - -set SPHINXBUILD=sphinx-build -set BUILDDIR=build -set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . -echo "Options " %ALLSPHINXOPTS% -set I18NSPHINXOPTS=%SPHINXOPTS% . -if NOT "%PAPER%" == "" ( - set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% - set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% -) - -if "%1" == "" goto help - -if "%1" == "help" ( - :help - echo.Please use `make ^` where ^ is one of - echo. html to make standalone HTML files - 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 - echo. json to make JSON files - echo. htmlhelp to make HTML files and a HTML help project - echo. qthelp to make HTML files and a qthelp project - echo. devhelp to make HTML files and a Devhelp project - echo. epub to make an epub - echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter - echo. text to make text files - echo. man to make manual pages - echo. texinfo to make Texinfo files - echo. gettext to make PO message catalogs - echo. changes to make an overview over all changed/added/deprecated items - echo. xml to make Docutils-native XML files - echo. pseudoxml to make pseudoxml-XML files for display purposes - echo. linkcheck to check all external links for integrity - echo. doctest to run all doctests embedded in the documentation if enabled - echo. coverage to run coverage check of the documentation if enabled - goto end -) - -if "%1" == "clean" ( - for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i - del /q /s %BUILDDIR%\* - goto end -) - - -REM Check if sphinx-build is available and fallback to Python version if any -%SPHINXBUILD% 2> nul -if errorlevel 9009 goto sphinx_python -goto sphinx_ok - -:sphinx_python - -set SPHINXBUILD=python -m sphinx.__init__ -%SPHINXBUILD% 2> nul -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -:sphinx_ok - - -if "%1" == "html" ( - echo %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html - %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/html. - goto end -) - -if "%1" == "dirhtml" ( - %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. - goto end -) - -if "%1" == "singlehtml" ( - %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. - goto end -) - -if "%1" == "pickle" ( - %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can process the pickle files. - goto end -) - -if "%1" == "json" ( - %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can process the JSON files. - goto end -) - -if "%1" == "htmlhelp" ( - %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can run HTML Help Workshop with the ^ -.hhp project file in %BUILDDIR%/htmlhelp. - goto end -) - -if "%1" == "qthelp" ( - %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can run "qcollectiongenerator" with the ^ -.qhcp project file in %BUILDDIR%/qthelp, like this: - echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Arcade.qhcp - echo.To view the help file: - echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Arcade.ghc - goto end -) - -if "%1" == "devhelp" ( - %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. - goto end -) - -if "%1" == "epub" ( - %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The epub file is in %BUILDDIR%/epub. - goto end -) - -if "%1" == "latex" ( - %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. - goto end -) - -if "%1" == "latexpdf" ( - %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex - cd %BUILDDIR%/latex - make all-pdf - cd %~dp0 - echo. - echo.Build finished; the PDF files are in %BUILDDIR%/latex. - goto end -) - -if "%1" == "latexpdfja" ( - %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex - cd %BUILDDIR%/latex - make all-pdf-ja - cd %~dp0 - echo. - echo.Build finished; the PDF files are in %BUILDDIR%/latex. - goto end -) - -if "%1" == "text" ( - %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The text files are in %BUILDDIR%/text. - goto end -) - -if "%1" == "man" ( - %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The manual pages are in %BUILDDIR%/man. - goto end -) - -if "%1" == "texinfo" ( - %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. - goto end -) - -if "%1" == "gettext" ( - %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The message catalogs are in %BUILDDIR%/locale. - goto end -) - -if "%1" == "changes" ( - %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes - if errorlevel 1 exit /b 1 - echo. - echo.The overview file is in %BUILDDIR%/changes. - goto end -) - -if "%1" == "linkcheck" ( - %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck - if errorlevel 1 exit /b 1 - echo. - echo.Link check complete; look for any errors in the above output ^ -or in %BUILDDIR%/linkcheck/output.txt. - goto end -) - -if "%1" == "doctest" ( - %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest - if errorlevel 1 exit /b 1 - echo. - echo.Testing of doctests in the sources finished, look at the ^ -results in %BUILDDIR%/doctest/output.txt. - goto end -) - -if "%1" == "coverage" ( - %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage - if errorlevel 1 exit /b 1 - echo. - echo.Testing of coverage in the sources finished, look at the ^ -results in %BUILDDIR%/coverage/python.txt. - goto end -) - -if "%1" == "xml" ( - %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The XML files are in %BUILDDIR%/xml. - goto end -) - -if "%1" == "pseudoxml" ( - %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. - goto end -) - -:end diff --git a/doc/make.py b/doc/make.py new file mode 100644 index 000000000..0efbb0a97 --- /dev/null +++ b/doc/make.py @@ -0,0 +1,330 @@ +""" +Build script for documentation +""" +from glob import glob +import os +from shutil import which, rmtree +import subprocess +from pathlib import Path + +SPHINXOPTS = [] +SPHINXBUILD = "sphinx-build" +SPHINXAUTOBUILD = "sphinx-autobuild" +PAPER = None +BUILDDIR = "build" + +# Internal variables. +PAPEROPTS = {} +PAPEROPTS[None] = [] +PAPEROPTS['a4'] = ['-D', 'latex_paper_size=a4'] +PAPEROPTS['letter'] = ['-D', 'latex_paper_size=letter'] +ALLSPHINXOPTS = ['-d', f'{BUILDDIR}/doctrees', *PAPEROPTS[PAPER], *SPHINXOPTS, '.'] +SPHINXAUTOBUILDOPTS = ['--watch', '../arcade'] +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = [*PAPEROPTS[PAPER], *SPHINXOPTS, '.'] + +os.chdir(Path(__file__).parent.resolve()) + +# User-friendly check for dependencies and binaries +binaries = ['sphinx-build', 'sphinx-autobuild'] +libraries = ['typer'] +for binary in binaries: + not_found = [binary for binary in binaries if which(binary) is None] + if not_found: + print("Command-line tools not found: " + ', '.join(not_found)) + print("Did you forget to install them with `pip`? See CONTRIBUTING.md file for instructions.") + exit(1) +for library in libraries: + def find(library): + try: + __import__(library) + return True + except: pass + not_found = [library for library in libraries if not find(library)] + if not_found: + print("Python dependencies not found: " + ', '.join(not_found)) + print("Did you forget to install them with `pip`? See CONTRIBUTING.md file for instructions.") + exit(1) + + + +import typer +app = typer.Typer() + +def run(args: str | list[str]): + result = subprocess.run(args) + if result.returncode != 0: + exit(result.returncode) + +@app.command() +def clean(): + """ + Delete built website files. + """ + if os.path.exists(BUILDDIR): + for item in Path(BUILDDIR).glob('*'): + os.remove(item) if os.path.isfile(item) else rmtree(item) + +@app.command() +def html(): + """ + to make standalone HTML files + """ + run([SPHINXBUILD, "-b", "html", *ALLSPHINXOPTS, f"{BUILDDIR}/html"]) + print() + print("Build finished. The HTML pages are in $(BUILDDIR)/html.") + + +@app.command() +def serve(): + """ + Build and serve standalone HTML files, with automatic rebuilds and live reload. + """ + run([SPHINXAUTOBUILD, *SPHINXAUTOBUILDOPTS, '-b', 'html', *ALLSPHINXOPTS, f'{BUILDDIR}/html']) + + +@app.command() +def dirhtml(): + """ + to make HTML files named index.html in directories + """ + run([SPHINXBUILD, "-b", "dirhtml", *ALLSPHINXOPTS, f"{BUILDDIR}/dirhtml"]) + print() + print("Build finished. The HTML pages are in $(BUILDDIR)/dirhtml.") + + +@app.command() +def singlehtml(): + """ + to make a single large HTML file + """ + run([SPHINXBUILD, "-b", "singlehtml", *ALLSPHINXOPTS, f"{BUILDDIR}/singlehtml"]) + print() + print("Build finished. The HTML page is in $(BUILDDIR)/singlehtml.") + + +@app.command() +def pickle(): + """ + to make pickle files + """ + run([SPHINXBUILD, "-b", "pickle", *ALLSPHINXOPTS, f"{BUILDDIR}/pickle"]) + print() + print("Build finished; now you can process the pickle files.") + + +@app.command() +def json(): + """ + to make JSON files + """ + run([SPHINXBUILD, "-b", "json", *ALLSPHINXOPTS, f"{BUILDDIR}/json"]) + print() + print("Build finished; now you can process the JSON files.") + + +@app.command() +def htmlhelp(): + """ + to make HTML files and a HTML help project + """ + run([SPHINXBUILD, "-b", "htmlhelp", *ALLSPHINXOPTS, f"{BUILDDIR}/htmlhelp"]) + print() + print("Build finished; now you can run HTML Help Workshop with the" + + ".hhp project file in $(BUILDDIR)/htmlhelp.") + + +@app.command() +def qthelp(): + """ + to make HTML files and a qthelp project + """ + run([SPHINXBUILD, "-b", "qthelp", *ALLSPHINXOPTS, f"{BUILDDIR}/qthelp"]) + print() + print('Build finished; now you can run "qcollectiongenerator" with the' + + ".qhcp project file in $(BUILDDIR)/qthelp, like this:") + print("# qcollectiongenerator $(BUILDDIR)/qthelp/Arcade.qhcp") + print("To view the help file:") + print("# assistant -collectionFile $(BUILDDIR)/qthelp/Arcade.qhc") + + +@app.command() +def applehelp(): + """ + to make an Apple Help Book + """ + run([SPHINXBUILD, "-b", "applehelp", *ALLSPHINXOPTS, f"{BUILDDIR}/applehelp"]) + print() + print("Build finished. The help book is in $(BUILDDIR)/applehelp.") + print("N.B. You won't be able to view it unless you put it in" + + "~/Library/Documentation/Help or install it in your application" + + "bundle.") + + +@app.command() +def devhelp(): + """ + to make HTML files and a Devhelp project + """ + run([SPHINXBUILD, "-b", "devhelp", *ALLSPHINXOPTS, f"{BUILDDIR}/devhelp"]) + print() + print("Build finished.") + print("To view the help file:") + print("# mkdir -p $$HOME/.local/share/devhelp/Arcade") + print("# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Arcade") + print("# devhelp") + + +@app.command() +def epub(): + """ + to make an epub + """ + run([SPHINXBUILD, "-b", "epub", *ALLSPHINXOPTS, f"{BUILDDIR}/epub"]) + print() + print("Build finished. The epub file is in $(BUILDDIR)/epub.") + + +@app.command() +def latex(): + """ + to make LaTeX files, you can set PAPER=a4 or PAPER=letter + """ + run([SPHINXBUILD, "-b", "latex", *ALLSPHINXOPTS, f"{BUILDDIR}/latex"]) + print() + print("Build finished; the LaTeX files are in $(BUILDDIR)/latex.") + print("Run \`make' in that directory to run these through (pdf)latex" + + "(use \`make latexpdf' here to do that automatically).") + + +@app.command() +def latexpdf(): + """ + to make LaTeX files and run them through pdflatex + """ + run([SPHINXBUILD, "-b", "latex", *ALLSPHINXOPTS, f"{BUILDDIR}/latex"]) + print("Running LaTeX files through pdflatex...") + run(['make', '-C', f'{BUILDDIR}/latex', 'all-pdf']) + print("pdflatex finished; the PDF files are in $(BUILDDIR)/latex.") + + +@app.command() +def latexpdfja(): + """ + to make LaTeX files and run them through platex/dvipdfmx + """ + run([SPHINXBUILD, "-b", "latex", *ALLSPHINXOPTS, f"{BUILDDIR}/latex"]) + print("Running LaTeX files through platex and dvipdfmx...") + run(['make', '-C', f'{BUILDDIR}/latex', 'all-pdf-ja']) + print("pdflatex finished; the PDF files are in $(BUILDDIR)/latex.") + + +@app.command() +def text(): + """ + to make text files + """ + run([SPHINXBUILD, "-b", "text", *ALLSPHINXOPTS, f"{BUILDDIR}/text"]) + print() + print("Build finished. The text files are in $(BUILDDIR)/text.") + + +@app.command() +def man(): + """ + to make manual pages + """ + run([SPHINXBUILD, "-b", "man", *ALLSPHINXOPTS, f"{BUILDDIR}/man"]) + print() + print("Build finished. The manual pages are in $(BUILDDIR)/man.") + + +@app.command() +def texinfo(): + """ + to make Texinfo files + """ + run([SPHINXBUILD, "-b", "texinfo", *ALLSPHINXOPTS, f"{BUILDDIR}/texinfo"]) + print() + print("Build finished. The Texinfo files are in $(BUILDDIR)/texinfo.") + print("Run \`make' in that directory to run these through makeinfo" + + "(use \`make info' here to do that automatically).") + + +@app.command() +def info(): + """ + to make Texinfo files and run them through makeinfo + """ + run([SPHINXBUILD, "-b", "texinfo", *ALLSPHINXOPTS, f"{BUILDDIR}/texinfo"]) + print("Running Texinfo files through makeinfo...") + run(['make', '-C', f'{BUILDDIR}/texinfo', 'info']) + print("makeinfo finished; the Info files are in $(BUILDDIR)/texinfo.") + + +@app.command() +def gettext(): + """ + to make PO message catalogs + """ + run([SPHINXBUILD, "-b", "gettext", *I18NSPHINXOPTS, f"{BUILDDIR}/locale"]) + print() + print("Build finished. The message catalogs are in $(BUILDDIR)/locale.") + + +@app.command() +def changes(): + """ + to make an overview of all changed/added/deprecated items + """ + run([SPHINXBUILD, "-b", "changes", *ALLSPHINXOPTS, f"{BUILDDIR}/changes"]) + print() + print("The overview file is in $(BUILDDIR)/changes.") + + +@app.command() +def linkcheck(): + """ + to check all external links for integrity + """ + run([SPHINXBUILD, "-b", "linkcheck", *ALLSPHINXOPTS, f"{BUILDDIR}/linkcheck"]) + print() + print("Link check complete; look for any errors in the above output " + + "or in $(BUILDDIR)/linkcheck/output.txt.") + + +@app.command() +def doctest(): + """ + to run all doctests embedded in the documentation (if enabled) + """ + run([SPHINXBUILD, "-b", "doctest", *ALLSPHINXOPTS, f"{BUILDDIR}/doctest"]) + print("Testing of doctests in the sources finished, look at the " + + "results in $(BUILDDIR)/doctest/output.txt.") + + +@app.command() +def coverage(): + """ + to run coverage check of the documentation (if enabled) + """ + run([SPHINXBUILD, "-b", "coverage", *ALLSPHINXOPTS, f"{BUILDDIR}/coverage"]) + print("Testing of coverage in the sources finished, look at the " + + "results in $(BUILDDIR)/coverage/python.txt.") + + +@app.command() +def xml(): + run([SPHINXBUILD, "-b", "xml", *ALLSPHINXOPTS, f"{BUILDDIR}/xml"]) + print() + print("Build finished. The XML files are in $(BUILDDIR)/xml.") + + +@app.command() +def pseudoxml(): + run([SPHINXBUILD, "-b", "pseudoxml", *ALLSPHINXOPTS, f"{BUILDDIR}/pseudoxml"]) + print() + print("Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml.") + +if __name__ == "__main__": + app() \ No newline at end of file diff --git a/doc/make.sh b/doc/make.sh deleted file mode 100755 index ff7738b14..000000000 --- a/doc/make.sh +++ /dev/null @@ -1 +0,0 @@ -sphinx-build -b html -d build/doctrees . build/html diff --git a/pyproject.toml b/pyproject.toml index ec98ccf92..d1e773d5c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,86 @@ +[project] +name = "arcade" +description = "Arcade Game Development Library" +readme = "README.rst" +authors = [ + {name="Paul Vincent Craven", email="paul@cravenfamily.com"} +] +license = {file = "license.rst"} +requires-python = ">=3.8" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Software Development :: Libraries :: Python Modules" +] +dependencies = [ + "pyglet>=2.0.3,<2.1", + "pillow~=9.4.0", + "pymunk~=6.4.0", + "pytiled-parser~=2.2.0" +] +dynamic = ["version"] + +[project.urls] +Homepage = "https://api.arcade.academy" +Documentation = "https://api.arcade.academy/" +Examples = "https://api.arcade.academy/en/latest/examples/index.html" +Issues = "https://github.com/pythonarcade/arcade/issues" +Source = "https://github.com/pythonarcade/arcade" +Book = "https://learn.arcade.academy" + +[project.optional-dependencies] +dev = [ + "pytest", + "mypy", + "ruff", + "coverage", + "coveralls", + "pytest-mock", + "pytest-cov", + "pygments==2.14.0", + "docutils==0.19", + "furo", + "pyyaml==6.0", + "sphinx==6.1.3", + "sphinx-autobuild==2021.3.14", + "sphinx-copybutton==0.5.1", + # Intentionally kept at 2.3 until this bugfix is published: https://github.com/jdillard/sphinx-sitemap/pull/62 + "sphinx-sitemap==2.3.0", + "typer==0.7.0", + "wheel", +] + +docs = [ + "pygments==2.14.0", + "docutils==0.19", + "furo", + "pyyaml==6.0", + "sphinx==6.1.3", + "sphinx-copybutton==0.5.1", + "sphinx-sitemap==2.5.0", + "wheel", +] + +[project.scripts] +arcade = "arcade.management:execute_from_command_line" + +[project.entry-points.pyinstaller40] +hook-dirs = "arcade.__pyinstaller:get_hook_dirs" + +[tool.setuptools.packages.find] +include = ["arcade", "arcade.*"] + +[tool.setuptools.dynamic] +version = {attr = "arcade.version.VERSION"} + [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" From 9f1a1a6c0f088196d91d233df473b6efad081da2 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sun, 23 Apr 2023 23:37:50 -0400 Subject: [PATCH 2/5] Fix arg typing issue in run signature on Python <= 3.9 --- doc/make.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/make.py b/doc/make.py index 0efbb0a97..e323534bd 100644 --- a/doc/make.py +++ b/doc/make.py @@ -6,6 +6,7 @@ from shutil import which, rmtree import subprocess from pathlib import Path +from typing import Union, List SPHINXOPTS = [] SPHINXBUILD = "sphinx-build" @@ -51,11 +52,13 @@ def find(library): import typer app = typer.Typer() -def run(args: str | list[str]): + +def run(args: Union[str, List[str]]) -> None: result = subprocess.run(args) if result.returncode != 0: exit(result.returncode) + @app.command() def clean(): """ From 430501ba35929839b84080dccf3a62281b6ffede Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sun, 23 Apr 2023 23:46:03 -0400 Subject: [PATCH 3/5] Improve spacing / comments --- doc/make.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/make.py b/doc/make.py index e323534bd..fc4a250fb 100644 --- a/doc/make.py +++ b/doc/make.py @@ -8,12 +8,15 @@ from pathlib import Path from typing import Union, List + +# General sphinx state / options SPHINXOPTS = [] SPHINXBUILD = "sphinx-build" SPHINXAUTOBUILD = "sphinx-autobuild" PAPER = None BUILDDIR = "build" + # Internal variables. PAPEROPTS = {} PAPEROPTS[None] = [] @@ -21,11 +24,16 @@ PAPEROPTS['letter'] = ['-D', 'latex_paper_size=letter'] ALLSPHINXOPTS = ['-d', f'{BUILDDIR}/doctrees', *PAPEROPTS[PAPER], *SPHINXOPTS, '.'] SPHINXAUTOBUILDOPTS = ['--watch', '../arcade'] -# the i18n builder cannot share the environment and doctrees with the others + +# Important: the i18n builder cannot share the environment and doctrees with the others +# This allows for internationalization / localization of doc. I18NSPHINXOPTS = [*PAPEROPTS[PAPER], *SPHINXOPTS, '.'] + +# Change dirs into root arcade project folder os.chdir(Path(__file__).parent.resolve()) + # User-friendly check for dependencies and binaries binaries = ['sphinx-build', 'sphinx-autobuild'] libraries = ['typer'] @@ -46,7 +54,6 @@ def find(library): print("Python dependencies not found: " + ', '.join(not_found)) print("Did you forget to install them with `pip`? See CONTRIBUTING.md file for instructions.") exit(1) - import typer @@ -329,5 +336,6 @@ def pseudoxml(): print() print("Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml.") + if __name__ == "__main__": - app() \ No newline at end of file + app() From 0b6039dc6aadcc8afe6f0004353238b033997629 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sun, 23 Apr 2023 23:46:33 -0400 Subject: [PATCH 4/5] Remove unused glob import --- doc/make.py | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/make.py b/doc/make.py index fc4a250fb..e8a18357e 100644 --- a/doc/make.py +++ b/doc/make.py @@ -1,7 +1,6 @@ """ Build script for documentation """ -from glob import glob import os from shutil import which, rmtree import subprocess From 446973101d97f7a0cc65ad14a359a63e0fd0e631 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sun, 23 Apr 2023 23:54:35 -0400 Subject: [PATCH 5/5] Update paper size variable names for clarity --- doc/make.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/make.py b/doc/make.py index e8a18357e..26bd1654e 100644 --- a/doc/make.py +++ b/doc/make.py @@ -12,21 +12,21 @@ SPHINXOPTS = [] SPHINXBUILD = "sphinx-build" SPHINXAUTOBUILD = "sphinx-autobuild" -PAPER = None +PAPER_SIZE = None BUILDDIR = "build" # Internal variables. -PAPEROPTS = {} -PAPEROPTS[None] = [] -PAPEROPTS['a4'] = ['-D', 'latex_paper_size=a4'] -PAPEROPTS['letter'] = ['-D', 'latex_paper_size=letter'] -ALLSPHINXOPTS = ['-d', f'{BUILDDIR}/doctrees', *PAPEROPTS[PAPER], *SPHINXOPTS, '.'] +PAPER_SIZE_OPTS = {} +PAPER_SIZE_OPTS[None] = [] +PAPER_SIZE_OPTS['a4'] = ['-D', 'latex_paper_size=a4'] +PAPER_SIZE_OPTS['letter'] = ['-D', 'latex_paper_size=letter'] +ALLSPHINXOPTS = ['-d', f'{BUILDDIR}/doctrees', *PAPER_SIZE_OPTS[PAPER_SIZE], *SPHINXOPTS, '.'] SPHINXAUTOBUILDOPTS = ['--watch', '../arcade'] # Important: the i18n builder cannot share the environment and doctrees with the others # This allows for internationalization / localization of doc. -I18NSPHINXOPTS = [*PAPEROPTS[PAPER], *SPHINXOPTS, '.'] +I18NSPHINXOPTS = [*PAPER_SIZE_OPTS[PAPER_SIZE], *SPHINXOPTS, '.'] # Change dirs into root arcade project folder @@ -197,7 +197,7 @@ def epub(): @app.command() def latex(): """ - to make LaTeX files, you can set PAPER=a4 or PAPER=letter + to make LaTeX files, you can set PAPER_SIZE=a4 or PAPER_SIZE=letter """ run([SPHINXBUILD, "-b", "latex", *ALLSPHINXOPTS, f"{BUILDDIR}/latex"]) print()