From a8d580075e8608ba49315e136e5310c798edd5d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sat, 30 Dec 2023 17:39:22 +0100 Subject: [PATCH] Fix ANSI control sequence support detection (#11708) --- CHANGES.rst | 3 +++ sphinx/util/display.py | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index f0872e6dc..a77553902 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -47,6 +47,9 @@ Bugs fixed package (triggered if using ``fontenc`` with ``T2A`` option and document language is not a Cyrillic one). Patch by Jean-François B. +* #11675: Fix rendering of progression bars in environments that do not support + ANSI control sequences. + Patch by Bénédikt Tran. Testing ------- diff --git a/sphinx/util/display.py b/sphinx/util/display.py index 199119cfa..967c80573 100644 --- a/sphinx/util/display.py +++ b/sphinx/util/display.py @@ -5,7 +5,7 @@ from typing import Any, Callable, TypeVar from sphinx.locale import __ from sphinx.util import logging -from sphinx.util.console import bold # type: ignore[attr-defined] +from sphinx.util.console import bold, color_terminal # type: ignore[attr-defined] if False: from collections.abc import Iterable, Iterator @@ -33,7 +33,8 @@ def status_iterator( verbosity: int = 0, stringify_func: Callable[[Any], str] = display_chunk, ) -> Iterator[T]: - single_line = verbosity < 1 + # printing on a single line requires ANSI control sequences + single_line = verbosity < 1 and color_terminal() bold_summary = bold(summary) if length == 0: logger.info(bold_summary, nonl=True)