jsonschema_diff.core.tools.render

Attributes

Classes

RenderTool

Small helper utilities used by the rendering subsystem.

Module Contents

type PATH_MAKER_IGNORE_RULES_TYPE = Sequence[str][source]
class RenderTool[source]

Small helper utilities used by the rendering subsystem.

static make_tab(
config: jsonschema_diff.core.config.Config,
tab_level: int,
) str[source]

Return indentation string.

Parameters:
  • config (Config) – Application config that owns the TAB constant.

  • tab_level (int) – Indentation depth.

Returns:

config.TAB repeated tab_level times.

Return type:

str

static make_prefix(
status: jsonschema_diff.core.abstraction.Statuses,
) str[source]

Convert a Statuses enum value to its printable form.

Parameters:

status (Statuses) – Validation status.

Returns:

status.value as plain text.

Return type:

str

static make_path(
schema_path: Sequence[Any],
json_path: Sequence[Any],
ignore: PATH_MAKER_IGNORE_RULES_TYPE = ('properties',),
) str[source]

Compose a human‑readable path by synchronising two parallel paths.

The function walks through schema_path (tokens from JSON Schema) and json_path (real path in the JSON instance) and emits a short textual representation such as ["items"][0].extra.

Parameters:
  • schema_path (Sequence[Any]) – Tokens encountered while traversing the schema.

  • json_path (Sequence[Any]) – Path tokens from the actual JSON document.

  • ignore (Sequence[str], default ("properties",)) – Schema‑only service tokens to skip.

Returns:

  • str – Compact path string.

  • Algorithm

  • ———

  • i — index in *schema_path, j — index in json_path.*

  • 1. If *schema_path[i] is in ignore and differs from* – json_path[j] → skip it.

  • 2. If tokens are equal → emit as property/index and advance both.

    1. Otherwise the token exists only in schema → emit as .token and – advance i.

  • 4. After the schema is exhausted, append remaining elements ofjson_path.

  • Integer‑like tokens are rendered as [n]; everything else as

  • ["key"].