Documentation
¶
Overview ¶
Package scenario parses markdown rehearse scenario files: body metadata (`**Verifies:**` / `**Status:**`) and fenced step blocks with info-string params (REQ: scenario-shape). Parsing only — no execution.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateACSummary ¶ added in v0.20.0
GenerateACSummary renders the `## Acceptance Criteria` read-model table for a feature from its thin ACs: one row per AC with its slug (linked), one-line statement, verifies target, and status. This is a denormalized projection of the `_acs/` source of truth so a reader — human or agent — gets every AC's intent inline, in one read, without opening each file. ACs are sorted by slug for a stable, drift-free output. Feature: cli/rehearse/thin-acs.
Types ¶
type AC ¶ added in v0.20.0
type AC struct {
// Slug is the id from the `# AC: <slug>` heading.
Slug string
// Statement is the prose under the `## Statement` heading (what must be true).
Statement string
// Verifies is the `**Verifies:**` URL reference to the feature/requirement.
Verifies string
// Status is the `**Status:**` value (e.g. "accepted", "draft").
Status string
// AppliesTo lists the `**Applies-to:**` tags (e.g. sign-in methods). Never nil.
AppliesTo []string
// Path is the file the AC was parsed from.
Path string
}
AC is a parsed thin acceptance criterion (`_acs/<slug>.ac.md`): a statement of intent — "what must be true" — with no verification inside (proof is a scenario's job). Feature: cli/rehearse/thin-acs.
func ParseACBytes ¶ added in v0.20.0
ParseACBytes parses AC content already in memory: the `# AC:` slug, the `**Verifies:**` / `**Status:**` / `**Applies-to:**` metadata, and the prose under the `## Statement` heading. A file with no `# AC:` heading is an error.
type Block ¶
type Block struct {
// Kind is the first info-string token (e.g. "bash", "sql"). Empty for a
// bare “` fence.
Kind string
// Params holds the remaining info-string tokens as key=value pairs; a
// bare token maps to the empty string.
Params map[string]string
// Body is the verbatim block content (without the fence lines).
Body string
// Line is the 1-based line number of the opening fence.
Line int
}
Block is one fenced block extracted from a scenario file.
type Check ¶ added in v0.20.0
type Check struct {
// Slug is the check id from its `# Check: <slug>` heading (may be empty).
Slug string
// Params are the names declared on the `**Params:**` line. Never nil.
Params []string
// Body is the verbatim content of the check's first fenced block.
Body string
}
Check is a parsed reusable check (`<slug>.check.md`): a named, parameterized verification unit. Feature: cli/rehearse/reusable-checks.
func ParseCheck ¶ added in v0.20.0
ParseCheck reads and parses the reusable-check file at path.
func ParseCheckBytes ¶ added in v0.20.0
ParseCheckBytes parses check content already in memory: the `# Check:` slug, the `**Params:**` declaration, and the body of the first fenced block (the verification). A check with no fenced block is an error.
type CheckUse ¶ added in v0.20.0
type CheckUse struct {
// Ref is the check URL from the Markdown link (relative to the scenario).
Ref string
// Params maps each `name=value` binding; values may be `{{context}}` refs.
Params map[string]string
// Line is the 1-based line number of the directive.
Line int
}
CheckUse is one `**Use:** [label](url) with name=value …` invocation of a reusable check. Feature: cli/rehearse/reusable-checks.
type FileAssertion ¶ added in v0.20.0
type FileAssertion struct {
// Path is the file path (relative or absolute) extracted from the heading.
Path string
// Kind is one of: exists, missing, contains, not-contains, permissions.
Kind string
// Expected is the content of the code block immediately following the
// heading, if any (empty for kinds that do not require one, e.g. exists).
Expected string
}
FileAssertion is one `### Assert: file` heading parsed from a scenario.
type Scenario ¶
type Scenario struct {
// Path is the file the scenario was parsed from.
Path string
// Verifies lists the AC ids from the `**Verifies:**` body metadata,
// parenthetical annotations stripped. Never nil.
Verifies []string
// Status is the `**Status:**` body metadata value (e.g. "pending").
Status string
// Expect is the `**Expect:**` body metadata value: "fail" when the scenario
// is expected to fail, "pass" otherwise (the default, and the value for any
// unrecognized directive). Feature: cli/rehearse/expected-fail.
Expect string
// Blocks are all fenced blocks in document order.
Blocks []Block
// FileAssertions are all `### Assert: file` headings in document order.
// Never nil.
FileAssertions []FileAssertion
// Uses are all `**Use:**` reusable-check invocations in document order.
// Feature: cli/rehearse/reusable-checks. Never nil.
Uses []CheckUse
}
Scenario is one parsed scenario file.
type SuiteWhen ¶ added in v0.20.0
type SuiteWhen struct {
// Label is the branch heading text (e.g. "When he completes the callback").
Label string
// Content is the verbatim markdown of the branch.
Content string
}
SuiteWhen is one `### When …` branch of a nested scenario suite: its heading label and the verbatim markdown of the branch (from its heading to the next `### When` or end of file). Feature: cli/rehearse/nested-suites.
func SplitSuite ¶ added in v0.20.0
SplitSuite reports whether data is a nested scenario *suite* — one that branches with `### When` (H3) headings — and, if so, splits it into the shared Given preamble (everything before the first `### When`, including frontmatter and body metadata) and one SuiteWhen per branch. Each root-to-leaf path (Given + one When) is an independently-executed case. `### When` headings inside fenced code blocks are ignored. A file with no `### When` heading is not a suite (nested=false) and runs flat. Feature: cli/rehearse/nested-suites.