diff options
author | Hugo van Kemenade <hugovk@users.noreply.github.com> | 2022-03-12 15:30:35 +0300 |
---|---|---|
committer | Hugo van Kemenade <hugovk@users.noreply.github.com> | 2022-03-12 15:30:35 +0300 |
commit | 2a700cf8e551ac44aebe938640b673f99af1cf9f (patch) | |
tree | 79ff981572b32460d56917a5c42858b88156a9a0 | |
parent | b3812f72a98b01bae4b1158761082edc46cfa87f (diff) |
Enable FORCE_COLOR and NO_COLOR for terminal colouring
-rw-r--r-- | sphinx/util/console.py | 4 |
1 files changed, 4 insertions, 0 deletions
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(): |