From d02b33fa22aab90d816267e50f0defceae95ba6e Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Fri, 11 Sep 2026 12:21:04 +0300 Subject: [PATCH 1/2] Add colour to status progress percentage --- sphinx/util/display.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/sphinx/util/display.py b/sphinx/util/display.py index e134f8caf7e..8e8db0f892a 100644 --- a/sphinx/util/display.py +++ b/sphinx/util/display.py @@ -2,7 +2,15 @@ import functools -from sphinx._cli.util.colour import bold, terminal_supports_colour +from sphinx._cli.util.colour import ( + bold, + brown, + darkgreen, + green, + red, + terminal_supports_colour, + yellow, +) from sphinx.locale import __ from sphinx.util import logging @@ -23,6 +31,18 @@ def display_chunk(chunk: Any) -> str: return str(chunk) +def _progress_colour(percent: int) -> Callable[[str], str]: + if percent >= 100: + return green + if percent >= 75: + return darkgreen + if percent >= 50: + return yellow + if percent >= 25: + return brown + return red + + def status_iterator[T]( iterable: Iterable[T], summary: str, @@ -44,7 +64,9 @@ def status_iterator[T]( if single_line: # clear the entire line ('Erase in Line') logger.info('\x1b[2K', nonl=True) - logger.info(f'{bold_summary}[{i / length: >4.0%}] ', nonl=True) # NoQA: G004 + percent = round(100 * i / length) + percentage = _progress_colour(percent)(f'[{percent: >3}%] ') + logger.info(bold_summary + percentage, nonl=True) # NoQA: G003 # Emit the string representation of ``item`` logger.info(stringify_func(item), nonl=True, color=color) # If in single-line mode, emit a carriage return to move the cursor From cf152eb72804083b49919278d7ca6383bfdfd12f Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Tue, 27 Oct 2026 22:48:36 +0200 Subject: [PATCH 2/2] Change scale to grey, blue, turquoise, teal, green --- sphinx/util/display.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/sphinx/util/display.py b/sphinx/util/display.py index e7d12a34e3e..31ba3eac547 100644 --- a/sphinx/util/display.py +++ b/sphinx/util/display.py @@ -3,13 +3,13 @@ import functools from sphinx._cli.util.colour import ( + blue, bold, - brown, - darkgreen, + darkgray, green, - red, + teal, terminal_supports_colour, - yellow, + turquoise, ) from sphinx.locale import __ from sphinx.util import logging @@ -31,16 +31,19 @@ def display_chunk(chunk: Any) -> str: return str(chunk) -def _progress_colour(percent: int) -> Callable[[str], str]: - if percent >= 100: +def _progress_colour(i: int, length: int) -> Callable[[str], str]: + # A cool grey-blue-cyan ramp that ends in green once complete. + # Red and yellow are avoided as they suggest warnings or errors. + if i >= length: return green - if percent >= 75: - return darkgreen - if percent >= 50: - return yellow - if percent >= 25: - return brown - return red + fraction = i / length + if fraction >= 0.75: + return teal + if fraction >= 0.5: + return turquoise + if fraction >= 0.25: + return blue + return darkgray def status_iterator[T]( @@ -64,8 +67,7 @@ def status_iterator[T]( if single_line: # clear the entire line ('Erase in Line') logger.info('\x1b[2K', nonl=True) - percent = round(100 * i / length) - percentage = _progress_colour(percent)(f'[{percent: >3}%] ') + percentage = _progress_colour(i, length)(f'[{i / length: >4.0%}] ') logger.info(bold_summary + percentage, nonl=True) # ruff: ignore[logging-string-concat] # Emit the string representation of ``item`` logger.info(stringify_func(item), nonl=True, color=color)