summaryrefslogtreecommitdiff
path: root/sphinx/util/console.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/util/console.py')
-rw-r--r--sphinx/util/console.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/sphinx/util/console.py b/sphinx/util/console.py
index 48b566283..abdbf4219 100644
--- a/sphinx/util/console.py
+++ b/sphinx/util/console.py
@@ -1,12 +1,4 @@
-"""
- sphinx.util.console
- ~~~~~~~~~~~~~~~~~~~
-
- Format colored console output.
-
- :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
- :license: BSD, see LICENSE for details.
-"""
+"""Format colored console output."""
import os
import re
@@ -57,9 +49,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():