mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Enable FORCE_COLOR and NO_COLOR for terminal colouring
This commit is contained in:
parent
b3812f72a9
commit
2a700cf8e5
@ -57,9 +57,13 @@ def term_width_line(text: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def color_terminal() -> bool:
|
def color_terminal() -> bool:
|
||||||
|
if 'NO_COLOR' in os.environ:
|
||||||
|
return False
|
||||||
if sys.platform == 'win32' and colorama is not None:
|
if sys.platform == 'win32' and colorama is not None:
|
||||||
colorama.init()
|
colorama.init()
|
||||||
return True
|
return True
|
||||||
|
if 'FORCE_COLOR' in os.environ:
|
||||||
|
return True
|
||||||
if not hasattr(sys.stdout, 'isatty'):
|
if not hasattr(sys.stdout, 'isatty'):
|
||||||
return False
|
return False
|
||||||
if not sys.stdout.isatty():
|
if not sys.stdout.isatty():
|
||||||
|
Loading…
Reference in New Issue
Block a user