From 2a700cf8e551ac44aebe938640b673f99af1cf9f Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 12 Mar 2022 14:30:35 +0200 Subject: [PATCH] Enable FORCE_COLOR and NO_COLOR for terminal colouring --- sphinx/util/console.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sphinx/util/console.py b/sphinx/util/console.py index 48b566283..f851ea9bb 100644 --- a/sphinx/util/console.py +++ b/sphinx/util/console.py @@ -57,9 +57,13 @@ def term_width_line(text: str) -> str: def color_terminal() -> bool: + if 'NO_COLOR' in os.environ: + return False if sys.platform == 'win32' and colorama is not None: colorama.init() return True + if 'FORCE_COLOR' in os.environ: + return True if not hasattr(sys.stdout, 'isatty'): return False if not sys.stdout.isatty():