ytdl-sub/Makefile
Ross Patterson 321556ecf7
[DEV] docs: Sphinx stale cross refs false success (#1319)
* ci(docs): RTD Sphinx warnings false successes

Use the same options on readthedocs.com that we use locally to fail on all warnings,
mostly to better catch stale cross references.

* docs(usage): Yet another stale Sphinx cross ref

I confirmed the previous RTD CI fix in the previous commit by pushing it to a draft PR
before pushing this change and the RTD action failed with the warning this commit
fixes. After pushing this commit, the RTD action succeeded.

* build(docs): Sphinx stale cross refs false success

I figured out why I kept getting warnings for broken Sphinx cross-refs *after* the
changes that caused them have already been merged, changes I know I ran `$ make docs`
for before pushing. The issue is that by default Sphinx only builds changed files for
faster iterations while editing, but it only catches broken cross-refs when it builds
files. So if changing, for example, a section name in one page that is referenced from
another page that you do *not* change, then the warning will be missed until something
changes that other page, such as a pull or rebase.

I considered adding a separate `./Makefile` target for incremental builds
in the inner loop of making changes. But I opted to just remove the `--write-all` CLI
option locally while editing in the inner loop, because the uncommitted change will
remind me to revert it and run a full rebuild before pushing.
2025-08-29 15:59:06 -07:00

80 lines
2.3 KiB
Makefile

# Defensive settings for make:
# https://tech.davis-hansson.com/p/make/
SHELL:=bash
.ONESHELL:
.SHELLFLAGS:=-eu -o pipefail -c
.SILENT:
.DELETE_ON_ERROR:
MAKEFLAGS+=--warn-undefined-variables
MAKEFLAGS+=--no-builtin-rules
export PS1?=$$
# Prefix echoed recipe commands with the recipe line number for debugging:
export PS4?=:$$LINENO+
# Get version related variables
export DATE:=$(shell date +'%Y.%m.%d')
export DATE_COMMIT_COUNT:=$(shell git rev-list --count HEAD --since="$(DATE) 00:00:00")
export COMMIT_HASH:=$(shell git rev-parse --short HEAD)
# Set Local version to YYYY.MM.DD-<hash>
export LOCAL_VERSION="$(DATE)+$(COMMIT_HASH)"
# Set PyPi version to YYYY.MM.DD or YYYY.MM.DD.postN if N > 0
ifeq ("$(DATE_COMMIT_COUNT)", "0")
export PYPI_VERSION="$(DATE)"
else
export PYPI_VERSION="$(DATE).post$(DATE_COMMIT_COUNT)"
endif
# Finished with `$(shell)`, echo recipe commands going forward
.SHELLFLAGS+= -x
### Top-level targets:
.PHONY: all
all: check_lint docs docker docker_ubuntu docker_gui
lint:
python3 -m isort .
python3 -m black .
python3 -m pylint src
check_lint:
isort . --check-only --diff \
&& black . --check \
&& pylint src/
wheel: clean
$(shell echo "__pypi_version__ = \"$(PYPI_VERSION)\"" > src/ytdl_sub/__init__.py)
$(shell echo "__local_version__ = \"$(LOCAL_VERSION)\"" >> src/ytdl_sub/__init__.py)
cat src/ytdl_sub/__init__.py
pip3 install build
python3 -m build
docker_stage: wheel
cp dist/*.whl docker/root/
cp -R examples docker/root/defaults/
docker: docker_stage
sudo docker build --progress=plain --no-cache -t ytdl-sub:local docker/
docker_ubuntu: docker_stage
sudo docker build --progress=plain --no-cache -t ytdl-sub-ubuntu:local -f docker/Dockerfile.ubuntu docker/
docker_gui: docker_stage
sudo docker build --progress=plain --no-cache -t ytdl-sub-gui:local -f docker/Dockerfile.gui docker/
executable: clean
pyinstaller ytdl-sub.spec
mv dist/ytdl-sub dist/ytdl-sub${EXEC_SUFFIX}
docs:
REGENERATE_DOCS=1 pytest tests/unit/docgen/test_docgen.py
sphinx-build --write-all --fail-on-warning --nitpicky -b html \
"./docs/source/" "./docs/build/"
clean:
rm -rf \
.pytest_cache/ \
build/ \
dist/ \
src/ytdl_sub.egg-info/ \
docs/build/ \
.coverage \
docker/root/*.whl \
docker/root/defaults/examples \
coverage.xml
.PHONY: lint check_lint wheel docker_stage docker docs clean