Skip to content

Commit 1ba8565

Browse files
committed
Merge pull request #104524 from wheatear-dev/disable-colors-doc-option
Support a `NO_COLOR` environment variable in `doc_status.py`
2 parents d032c11 + d7a9a9a commit 1ba8565

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

doc/tools/doc_status.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../"))
1212

13-
from misc.utility.color import STDOUT_COLOR, Ansi, toggle_color
13+
from misc.utility.color import NO_COLOR, STDOUT_COLOR, Ansi, toggle_color
1414

1515
################################################################################
1616
# Config #
@@ -114,6 +114,8 @@ def validate_tag(elem: ET.Element, tag: str) -> None:
114114

115115

116116
def color(color: str, string: str) -> str:
117+
if NO_COLOR:
118+
return string
117119
color_format = "".join([str(x) for x in colors[color]])
118120
return f"{color_format}{string}{Ansi.RESET}"
119121

misc/utility/color.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# to a file, it won't contain color codes. Colors are always enabled on continuous integration.
1010

1111
IS_CI: Final[bool] = bool(os.environ.get("CI"))
12+
NO_COLOR: Final[bool] = bool(os.environ.get("NO_COLOR"))
1213
STDOUT_TTY: Final[bool] = bool(sys.stdout.isatty())
1314
STDERR_TTY: Final[bool] = bool(sys.stderr.isatty())
1415

0 commit comments

Comments
 (0)