context.public_contract

context.public_contract(spec, name)

The public contract of a unit: module docstring, signatures and docstrings, no bodies.

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 Python source of the contract stubs.

Examples

from pathlib import Path
from tempfile import TemporaryDirectory

from spotregen import load_spec, make_sample_repo, public_contract

with TemporaryDirectory() as tmp:
    spec = load_spec(make_sample_repo(Path(tmp) / "demo"))
    print(public_contract(spec, "core.calc"))
"""Calculator."""


def add(a: int, b: int) -> int:
    """Add two numbers."""
    ...