From 6090cf16931157dc3a3bd760d943fcb1bad73bbb Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 31 Jul 2024 12:27:13 +0300 Subject: [PATCH 1/3] Add Makefile --- Makefile | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7282905 --- /dev/null +++ b/Makefile @@ -0,0 +1,93 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +PYTHON = python3 +VENVDIR = ./.venv +SPHINXBUILD = $(VENVDIR)/bin/sphinx-build +SPHINXOPTS = --fail-on-warning --keep-going +BUILDDIR = _build +BUILDER = html +JOBS = auto +SPHINXLINT = $(VENVDIR)/bin/sphinx-lint + +# Internal variables. +ALLSPHINXOPTS = --builder $(BUILDER) \ + --doctree-dir $(BUILDDIR)/doctrees \ + --jobs $(JOBS) \ + $(SPHINXOPTS) \ + docs $(BUILDDIR)/$(BUILDER) + +.PHONY: help +help: + @echo "Please use \`make ' where is one of" + @echo " venv to create a venv with necessary tools" + @echo " html to make standalone HTML files" + @echo " htmlview to open the index page built by the html target in your browser" + @echo " htmllive to rebuild and reload HTML files in your browser" + @echo " clean to remove the venv and build files" + @echo " linkcheck to check all external links for integrity" + @echo " lint to lint all the files" + +.PHONY: clean +clean: clean-venv + -rm -rf $(BUILDDIR)/* + +.PHONY: clean-venv +clean-venv: + rm -rf $(VENVDIR) + +.PHONY: venv +venv: + @if [ -d $(VENVDIR) ] ; then \ + echo "venv already exists."; \ + echo "To recreate it, remove it first with \`make clean-venv'."; \ + else \ + $(MAKE) ensure-venv; \ + fi + +.PHONY: ensure-venv +ensure-venv: + @if [ ! -d $(VENVDIR) ] ; then \ + echo "Creating venv in $(VENVDIR)"; \ + if uv --version > /dev/null; then \ + uv venv $(VENVDIR); \ + VIRTUAL_ENV=$(VENVDIR) uv pip install -r requirements.txt; \ + else \ + $(PYTHON) -m venv $(VENVDIR); \ + $(VENVDIR)/bin/python3 -m pip install --upgrade pip; \ + $(VENVDIR)/bin/python3 -m pip install -r requirements.txt; \ + fi; \ + echo "The venv has been created in the $(VENVDIR) directory"; \ + fi + +.PHONY: html +html: ensure-venv + $(SPHINXBUILD) $(ALLSPHINXOPTS) + +.PHONY: linkcheck +linkcheck: BUILDER = linkcheck +linkcheck: html + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/$(BUILDER)/output.txt." + +.PHONY: htmlview +htmlview: html + $(PYTHON) -c "import os, webbrowser; webbrowser.open('file://' + os.path.realpath('_build/html/index.html'))" + +.PHONY: htmllive +htmllive: SPHINXBUILD = $(VENVDIR)/bin/sphinx-autobuild +# Arbitrarily selected ephemeral port between 49152–65535 +# to avoid conflicts with other processes: +htmllive: SPHINXOPTS = --re-ignore="/\.idea/|/venv/" --open-browser --delay 0 --port 55303 +htmllive: html + +.PHONY: lint +lint: venv + if uv --version > /dev/null; then \ + $(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || VIRTUAL_ENV=$(VENVDIR) uv pip install pre-commit; \ + else \ + $(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install pre-commit; \ + fi; + $(VENVDIR)/bin/python3 -m pre_commit run --all-files From 7236defad821f97a3bc3c87eebf4e1efb911609e Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 31 Jul 2024 12:30:12 +0300 Subject: [PATCH 2/3] Git ignore Sphinx _build output dir --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index b6e4761..39940ec 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,6 @@ dmypy.json # Pyre type checker .pyre/ + +# Sphinx docs +_build From d409872f20b7aa06f492972daf8c589a5a2eac7b Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 31 Jul 2024 16:18:44 +0300 Subject: [PATCH 3/3] Delete docs/Makefile --- docs/Makefile | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 docs/Makefile diff --git a/docs/Makefile b/docs/Makefile deleted file mode 100644 index 6939568..0000000 --- a/docs/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = python -msphinx -SPHINXPROJ = TeamCompass -SOURCEDIR = . -BUILDDIR = _build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)