Skip to main content

explain.example_text

explain.example_text(kind)

The example record of a kind, as babregen example prints it.

Parameters

Name Type Description Default
kind str "architecture", "unit" or "decision". required

Returns

Name Type Description
str str One complete TOML record with comments and folded prose. It uses the names of the sample repository and checks clean when it replaces the corresponding record there.

Raises

Name Type Description
SpecError If kind is not one of the three kinds.

Examples

from babregen.explain import example_text

print(example_text("decision"))
# regen/decisions/why-add.toml: a decision record. The file name is the id that intent
# items cite (decisions = ["why-add"]). The names are those of the sample repository.

title = "Addition is provided by the package"  # what was decided, in one line
date = 2026-01-01
status = "active"       # active (the default), superseded or expired

# What forced the decision: an incident, a requirement, a measurement. Prose is folded:
# wrap it, write no backslash.
driver = """
A user asked for a function that sums two integers, and three scripts had their own
copy of it."""
decision = """
The package provides add(a, b) in samplepkg.core.calc and promises plain arithmetic.
The scripts call it instead of keeping a copy."""
approved_by = "maintainer"  # who stands behind the decision

# References: file:<path>, commit:<sha>, KB:<entry> or url:<url>.
evidence = ["file:src/samplepkg/core/calc.py"]

# What the decision rests on. When one of these stops holding, review the record.
assumes = [
    "callers sum integers only",
]
# review_after = 2027-06-01  # the check warns when this date has passed

# Rejected options, kept because negative knowledge is fragile.
[[alternatives]]
option = "keep a copy of the sum in every script"
rejected_because = """
the copies drift, and a fix would have to be made three times."""