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:
|
overlay_context
|
The extra context from the overlay
TYPE:
|
pattern_context
|
The extra context from the pattern
TYPE:
|
| 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
- re-render the pattern’s extra_context, now that questions are answered
Contract: overlay extra_context values are rendered once, before questions are asked, so
they must not reference question answers. Pattern extra_context values are rendered twice
(before and after questions) so that they may reference question answers.
| PARAMETER | DESCRIPTION |
|---|---|
overlay
|
The overlay configuration.
TYPE:
|
running_context
|
The current running context used for rendering defaults, answer mappings, and when conditions.
TYPE:
|
question_ui
|
A callable that takes question information and returns the result from the user interface.
TYPE:
|
| 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. |
render_pattern_context_after_questions
¶
render_pattern_context_after_questions(
context: MutableMapping, pattern_context: MutableMapping
) -> dict
Re-render the pattern’s extra_context now that questions have been answered.
Pattern extra_context values may be Jinja expressions referencing question answers (e.g.
package_path = "{{ repo_name }}/{{ package_name }}"), which don’t exist yet when
merge_contexts first renders them in process_overlay. This re-render pass makes those
values resolve correctly. Overlay extra_context is intentionally excluded here: it is rendered
only once, before questions, and must not depend on answers.
| PARAMETER | DESCRIPTION |
|---|---|
context
|
The running context, including question answers, to render against and update.
TYPE:
|
pattern_context
|
The pattern’s extra_context mapping.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict
|
The context with pattern extra_context re-rendered. |