summaryrefslogtreecommitdiff
path: root/sphinx/util/console.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2022-03-19 22:58:15 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2022-03-19 22:58:15 +0900
commitaa1bc83c2ac9357b39048b555c3fdb0efff3449c (patch)
treec1149670ca18b5f9820505322d5b0a5832395ea4 /sphinx/util/console.py
parent759a526b12213c59d6ae4c8f66682f4328b764f4 (diff)
parent017ef6118b4fe588140266ad6ff2393cbddd9137 (diff)
downloadsphinx-git-aa1bc83c2ac9357b39048b555c3fdb0efff3449c.tar.gz
Merge branch '4.x'
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():