Fix ANSI control sequence support detection (#11708)

This commit is contained in:
Bénédikt Tran 2023-12-30 17:39:22 +01:00 committed by GitHub
parent 23c9cb4e78
commit a8d580075e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -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
-------

View File

@ -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)