Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable FORCE_COLOR and NO_COLOR for terminal colouring #10260

Merged
merged 3 commits into from Mar 16, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions sphinx/util/console.py
Expand Up @@ -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():
Expand Down