context.build_context

context.build_context(spec, name)

The regeneration bundle of one unit, as Markdown.

The bundle is everything a generator needs and nothing it must not copy: the architecture (allowed dependencies, conventions, open choices, pace policy), the unit’s purpose and intent, the decisions behind it, the public contract without implementation bodies, the source of its durable evaluations and the list of its consumers. A regenerated file is accepted when pytest -m regen and the unit’s ordinary tests pass and spotregen check stays clean.

Parameters

Name Type Description Default
spec RegenSpec The loaded spec. required
name str Dotted module name, or its unique suffix. required

Returns

Name Type Description
str str The Markdown bundle.

Examples

from pathlib import Path
from tempfile import TemporaryDirectory

from spotregen import build_context, load_spec, make_sample_repo

with TemporaryDirectory() as tmp:
    spec = load_spec(make_sample_repo(Path(tmp) / "demo"))
    bundle = build_context(spec, "core.calc")
    print(bundle.splitlines()[0])
    print("def add(a: int, b: int) -> int:" in bundle, "return a + b" in bundle)
# Regeneration bundle: samplepkg.core.calc
True False