jsonschema_diff.color¶
Convenience re-exports for the colour sub-package.
End-users can simply write:
from jsonschema_diff.color import HighlighterPipeline, LineHighlighter
Submodules¶
Classes¶
Protocol for single-line high-lighters. |
|
Chain of |
Package Contents¶
- class LineHighlighter[source]¶
Protocol for single-line high-lighters.
Concrete implementations may also override
colorize_lines()for bulk operations, butcolorize_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.Textinstance 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],
Vectorised helper that stylises a sequence of lines.
The naïve fallback simply delegates to
colorize_line().- Parameters:
lines – Ordered collection of
rich.text.Textobjects.- Return type:
The original objects, now styled in place.
- class HighlighterPipeline(
- stages: Iterable[LineHighlighter],
Chain of
LineHighlighter()stages.- Parameters:
stages – Iterable of
LineHighlighterinstances. The iterable is immediately materialised into a list so the pipeline can be reused.
Note
Each input line is passed through every stage in order.
If a stage exposes a bulk
colorize_lines()method it is preferred over per-line iteration for performance.
- stages: list[LineHighlighter]¶