Skip to content

overlays

Compile the context from all the overlays.

Classes

Functions

merge_contexts

merge_contexts(
    initial_context: MutableMapping,
    overlay_context: MutableMapping,
    pattern_context: MutableMapping,
) -> dict

Merge contexts together and render the values.

The overlay context values will override the pattern context values.

PARAMETER DESCRIPTION
initial_context

The initial context to be updated

TYPE: MutableMapping

overlay_context

The extra context from the overlay

TYPE: MutableMapping

pattern_context

The extra context from the pattern

TYPE: MutableMapping

RETURNS DESCRIPTION
dict

The merged and rendered context

process_overlay

process_overlay(
    overlay: Overlay,
    running_context: dict[str, Any],
    question_ui: Callable,
) -> dict[str, Any]

Get the context from an overlay.

  • update overlay pattern’s extra_context with overlay’s extra_context
  • render extra_context with running_context
  • update running_context with extra_context
  • for each question in pattern - set response to the result of answer_question - update running context with response
PARAMETER DESCRIPTION
overlay

The overlay configuration.

TYPE: Overlay

running_context

The current running context used for rendering defaults, answer mappings, and when conditions.

TYPE: dict[str, Any]

question_ui

A callable that takes question information and returns the result from the user interface.

TYPE: Callable

RETURNS DESCRIPTION
dict[str, Any]

A new running context that is the combination of the initial running context, the extra contexts

dict[str, Any]

from the overlay and pattern, and the answers to the questions.