commit: b9265f39d2bc8260719be68584d05a7ab4498d01
Author: Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Thu Nov 27 13:49:21 2025 +0000
Commit: Brian Harring <ferringb <AT> gmail <DOT> com>
CommitDate: Thu Nov 27 15:05:46 2025 +0000
URL:
https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=b9265f39
chore: make debugging sphinx failures less of PITA
When an extension fails, there is a tmp file written, which
always gets overlooked.
Just wire it in so that it's automatically cat'd.
Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
Makefile | 7 +++++--
doc/build.sh | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index d8c79962..4673a9a1 100644
--- a/Makefile
+++ b/Makefile
@@ -3,15 +3,18 @@ SPHINX_BUILD ?= $(PYTHON) -m sphinx.cmd.build
.PHONY: man html
man html:
- $(SPHINX_BUILD) -a -b $@ doc build/sphinx/$@
+ doc/build.sh $@ "$$(pwd)/build/sphinx/$@"
+
+html: man
.PHONY: sdist wheel
sdist wheel:
$(PYTHON) -m build --$@
+
.PHONY: clean
clean:
- $(RM) -r build/sphinx doc/api doc/generated dist
+ $(RM) -r build doc/api doc/generated dist
$(MAKE) -C data/lib/pkgcore/ebd clean
.PHONY: format
diff --git a/doc/build.sh b/doc/build.sh
new file mode 100755
index 00000000..5199737b
--- /dev/null
+++ b/doc/build.sh
@@ -0,0 +1,39 @@
+#!/bin/bash -e
+base=$(dirname "$(dirname "$(readlink -f "$0")")")
+
+if [ ${#} -ne 2 ]; then
+ echo "requires 2 arguments; the sphinx mode, and where to put the output."
+ exit 1;
+fi
+mode="$1"
+output="$2"
+
+
+
+# the point of this script is to capture sphinx output for extension
+# failures, and also dump that log automatically.
+
+# force US; sphinx errors are localized, and we're abusing grep.
+export LANG=en_US.UTF-8
+
+# capture stderr
+t=$(mktemp)
+if python -m sphinx.cmd.build -a -b "$mode" "$base/doc" "$output" 2>$t; then
+ exit $?
+fi
+
+# extract the traceback path
+dump=$(grep -A1 'traceback has been saved in' "$t" | tail -n1)
+cat < "$t"
+echo
+if [ -z "$dump" ]; then
+ echo "FAILED auto extracting the traceback file. you'll have to do it
manually"
+else
+ echo
+ echo "contents of $dump"
+ echo
+ cat < "$dump"
+ rm "$t"
+fi
+
+exit 2
\ No newline at end of file