jsonschema_diff.color.abstraction

This module defines LineHighlighter, a thin typing.Protocol that specifies the minimal contract required by the colour pipeline implemented in :pyfile:`base.py`.

Implementors are expected to decorate rich.text.Text objects in place; therefore methods must not alter the underlying string content – only styling metadata.

Classes

LineHighlighter

Protocol for single-line high-lighters.

Module Contents

class LineHighlighter[source]

Protocol for single-line high-lighters.

Concrete implementations may also override colorize_lines() for bulk operations, but colorize_line() is the only mandatory method.

abstractmethod colorize_line(line: Text) Text[source]

Stylise one line in-place and return it.

Parameters:

line – A single rich.text.Text instance to be colour-styled.

Return type:

The same Text object, now containing style spans.

Raises:

NotImplementedError – Always here; concrete subclasses must override this method.

colorize_lines(
lines: Sequence[Text],
) List[Text][source]

Vectorised helper that stylises a sequence of lines.

The naïve fallback simply delegates to colorize_line().

Parameters:

lines – Ordered collection of rich.text.Text objects.

Return type:

The original objects, now styled in place.