adr

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package adr parses ADR files under docs/decisions, renders the ACTIVE.md index, and scaffolds new ADR files from the rendered template (awf new adr). Generated by awf sync (regenerates docs/decisions/ACTIVE.md).

Index

Constants

This section is empty.

Variables

View Source
var FilenameRe = regexp.MustCompile(`^(\d{4})-.+\.md$`)

FilenameRe matches an ADR filename (NNNN-slug.md); group 1 is the 4-digit number.

Functions

func NewFile added in v0.6.0

func NewFile(dir, title string) (string, error)

NewFile scaffolds a new ADR under dir: the next sequential number, the rendered template.md with every marker comment stripped and its date and title heading filled in, named NNNN-slug.md. Refuses to overwrite an existing file at that path. invariant: adr-new-strips-markers invariant: adr-new-heading-matches-file invariant: adr-new-no-overwrite

func NextNumber added in v0.6.0

func NextNumber(dir string) (string, error)

NextNumber returns the next available 4-digit ADR number for dir: one more than the highest number ParseDir finds, or "0001" for an ADR-less dir. invariant: adr-new-sequential-numbering

func RenderActiveMD

func RenderActiveMD(dir string) (string, error)

RenderActiveMD renders the ACTIVE.md index for dir, grouped by status. It returns a placeholder index when dir holds no ADRs (ADR-0020). The content carries no generated-by banner — like RenderDomainIndex, that is the caller's job (internal/project's generateActiveMD, via injectBanner) so every rendered artifact's banner comes from the one canonical source.

func RenderDomainIndex

func RenderDomainIndex(dir, domain string) (string, error)

RenderDomainIndex renders the per-domain ADR index for the decisions directory dir: every ADR whose domains frontmatter includes domain, grouped by status in the same order as ACTIVE.md, with links relative to docs/domains/ (one dir over) and each superseded entry annotated with its successor. Returns a placeholder line when no ADR matches, so the rendered section is never empty.

func SetNowForTest added in v0.6.0

func SetNowForTest(fn func() time.Time) (prev func() time.Time)

SetNowForTest overrides the now seam for a test and returns the previous value, so the caller can restore it. Exported because adr_test.go is an external test package (package adr_test), mirroring the project's existing var-seam-for-coverage convention rather than adding an internal test file.

Types

type ADR

type ADR struct {
	Number            string            // e.g. "0001"
	Title             string            // e.g. "ADR-0001: Template Overlay Rendering Engine"
	Status            string            // e.g. "Accepted"
	Filename          string            // e.g. "0001-template-overlay-rendering-engine.md"
	Path              string            // path as globbed
	Domains           []string          // `domains:` frontmatter (ADR-0014)
	SupersededBy      string            // `superseded_by:` frontmatter (e.g. "0008", or "")
	RetiresInvariants []string          // `retires_invariants:` frontmatter (ADR-0031)
	Sections          map[string]string // `## ` heading -> section body
}

ADR is a parsed ADR record.

func ParseDir

func ParseDir(dir string) ([]ADR, error)

ParseDir scans dir for ADR files (NNNN-*.md) and parses each into an ADR.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL