Skip to content

Print warnings/errors at the end of the build #13056

Open
@asmeurer

Description

@asmeurer

In the SymPy docs, we've been using this custom Makefile code:

html:
	$(MAKE) -s _html || $(MAKE) -s printwarnings

# Force colors on CI. Set NO_COLOR=1 on the command line to disable this.
_html: export FORCE_COLOR = 1
_html: $(BUILDDIR)/html/pics/*.png
_html: SPHINXOPTS += -W --keep-going
_html: $(BUILDDIR)/logo/sympy-notailtext-favicon.ico
	mkdir -p $(SOURCEDIR)/.static
	mkdir -p $(BUILDDIR)/html
	mkdir -p $(BUILDDIR)/doctrees
	mkdir -p $(SOURCEDIR)/modules
	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(SPHINXSAVEWARNINGS) $(SOURCEDIR) $(BUILDDIR)/html
	@echo
	@echo "Docs build finished. The HTML pages are in $(BUILDDIR)/html."

# Print the warnings again at the end of the build, to make them easier to find
printwarnings:
	@printf "\033[0;31mThe docs build failed with the following errors:\033[0m\n"
	@cat $(WARNINGSFILE)
	exit 1

This makes it so that when there is an warning/error in the build, it is printed again at the very end. This is very useful for CI builds, where the logs can be quite long and it's difficult to find whatever error or warning caused a build to fail.

Would it be possible for Sphinx to just always do this, so that this little bit of code is unnecessary?

(by the way, the "force color output on CI" thing is another thing that would be useful if I didn't have to manually enable it. I don't know if there's a better thing Sphinx can be doing here. I can open a separate issue for this if you want)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions