Documentation
¶
Index ¶
Constants ¶
const SpecFileName = ".fault-spec.yaml"
SpecFileName is the default spec file name.
Variables ¶
var AnchorPattern = regexp.MustCompile(`spec:([A-Za-z][A-Za-z0-9_-]*-\d+)`)
AnchorPattern matches spec anchors in source code comments: spec:REQ-001
Functions ¶
func GroupAnchorsByReqID ¶
GroupAnchorsByReqID groups anchors by their requirement ID.
Types ¶
type Anchor ¶
type Anchor struct {
ReqID string // the requirement ID referenced (e.g. "REQ-001")
File string // file path relative to repo root
Line int // 1-based line number
}
Anchor represents a spec anchor found in source code.
func ExtractAnchorsFromDir ¶
ExtractAnchorsFromDir walks a directory tree and extracts all spec anchors. It skips binary files, vendor dirs, node_modules, and .git.
func ExtractAnchorsFromFile ¶
ExtractAnchorsFromFile scans a single file for spec anchors.
type Requirement ¶
type Requirement struct {
ID string `yaml:"id" json:"id"`
Description string `yaml:"description" json:"description"`
Priority string `yaml:"priority" json:"priority"`
Status string `yaml:"status" json:"status"`
Targets []string `yaml:"targets" json:"targets"`
Tags []string `yaml:"tags" json:"tags"`
}
Requirement represents a single requirement in the spec.
type Spec ¶
type Spec struct {
Version int `yaml:"version" json:"version"`
Title string `yaml:"title" json:"title"`
Requirements []Requirement `yaml:"requirements" json:"requirements"`
}
Spec represents a parsed specification file.
func LoadSpec ¶
LoadSpec reads and parses a spec file. It dispatches to the appropriate parser based on the file extension: .md/.markdown → Markdown, otherwise YAML.
func ParseMarkdownSpec ¶ added in v0.7.2
ParseMarkdownSpec parses a Markdown document into a Spec.
The first H1 heading becomes the spec title. H2 headings become top-level requirements (SEC-1, SEC-2, ...). H3 headings become sub-requirements (SEC-1-1, SEC-1-2, ...). Each section's body text becomes the requirement description.
func ParseYAMLSpec ¶ added in v0.7.2
ParseYAMLSpec parses spec YAML bytes into a Spec (YAML only, no fallback).
func (*Spec) RequirementByID ¶
func (s *Spec) RequirementByID(id string) *Requirement
RequirementByID returns the requirement with the given ID, or nil.
func (*Spec) RequirementIDs ¶
RequirementIDs returns all requirement IDs in order.