spec

package
v0.1.0-rc.5 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 27 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package spec reads specification sources and pins their addressable units.

Index

Constants

View Source
const (
	SpecMoved  = "spec-moved"
	Orphaned   = "orphaned"
	Unclaimed  = "unclaimed"
	Unmeasured = "unmeasured"
	Deprecated = "deprecated"

	ChangedSpecAdvice = "" /* 134-byte string literal not displayed */
)
View Source
const LockName = "docs/facets/spec-lock.yaml"

Variables

This section is empty.

Functions

func ConfigureSources

func ConfigureSources(sources []Source) error

func FollowDiff

func FollowDiff(pinned, current Sequence) string

FollowDiff shows changes to the normalised scenario sequence at follow.

func InOpenSpecChanges

func InOpenSpecChanges(path string) bool

func PinnedFeatures

func PinnedFeatures(ctx context.Context, root string, source Source, commit string, pins map[string]LockedScenario) (map[string]*FeatureBlock, error)

PinnedFeatures reads blocks containing the requested pins at one commit.

func ReadFile

func ReadFile(root, path string) (Document, []Finding)

ReadFile recognises file extensions and default layouts for local linting.

func Reference

func Reference(ref string, scenario bool) (source, file, address string, ok bool)

Reference splits a scenario or file reference using the specification ID grammar.

func RefreshCache

func RefreshCache(ctx context.Context, root string, sources []Source)

RefreshCache fetches the configured branches without reading or changing the lock.

func SequenceDiff

func SequenceDiff(pinned, record Sequence) string

SequenceDiff shows the changed portion of the pinned and record sequences.

Types

type Adapter

type Adapter interface {
	Read(root, path string, data []byte) (Document, []Finding)
	Matches(relativePath string) bool
}

Adapter reads one file within a source and returns its addressable units.

func AdapterFor

func AdapterFor(format Format) (Adapter, error)

type BindingStrength

type BindingStrength string
const (
	Exact          BindingStrength = "exact"
	Provenance     BindingStrength = "provenance"
	UnknownBinding BindingStrength = "unknown"
)

type Change

type Change struct {
	Source  string
	Address string
	Kind    string
	Binding BindingStrength
}

func Update

func Update(ctx context.Context, root string, sources []Source, overrides map[string]string, only []string) ([]Change, error)

Update reads all selected sources before publishing a new lock.

type DocString

type DocString struct {
	MediaType string `json:"media_type" yaml:"media_type"`
	Content   string `json:"content" yaml:"content"`
}

type Document

type Document struct {
	ID       string
	Status   string
	Language string
	Skipped  bool
	Units    []Unit
	// contains filtered or unexported fields
}

type FeatureBlock

type FeatureBlock struct {
	Body    string
	CaseTag string
}

type Finding

type Finding struct {
	File    string          `json:"file"`
	Line    int             `json:"line"`
	Message string          `json:"message"`
	Binding BindingStrength `json:"binding"`
}

func (Finding) Error

func (f Finding) Error() string

type Format

type Format string
const (
	FacetSpec       Format = "facet-spec"
	Gherkin         Format = "gherkin"
	OpenSpec        Format = "openspec"
	SpecKit         Format = "speckit"
	GherkinMarkdown Format = "gherkin-markdown"
	Kiro            Format = "kiro"
	BMAD            Format = "bmad"
	Gauge           Format = "gauge"
)

func (Format) Strength

func (f Format) Strength() BindingStrength

type Lock

type Lock map[string]LockedSource

func ReadLock

func ReadLock(root string) (Lock, error)

type LockedFile

type LockedFile struct {
	Status   string `yaml:"status"`
	Language string `yaml:"language"`
}

type LockedScenario

type LockedScenario struct {
	Commit   string          `yaml:"commit"`
	Binding  BindingStrength `yaml:"binding,omitempty"`
	Steps    string          `yaml:"steps"`
	Context  string          `yaml:"context,omitempty"`
	Sequence *Sequence       `yaml:"sequence,omitempty"`
	Text     string          `yaml:"text,omitempty"`
}

func (LockedScenario) FollowDiff

func (s LockedScenario) FollowDiff(current LockedScenario) string

func (LockedScenario) Strength

func (s LockedScenario) Strength() BindingStrength

type LockedSource

type LockedSource struct {
	Repo      string                    `yaml:"repo"`
	Follow    string                    `yaml:"follow"`
	Format    Format                    `yaml:"format"`
	Commit    string                    `yaml:"commit,omitempty"`
	Files     map[string]LockedFile     `yaml:"files"`
	Scenarios map[string]LockedScenario `yaml:"scenarios"`
}

func ReadFollow

func ReadFollow(ctx context.Context, root string, source Source, cached bool) (LockedSource, error)

ReadFollow reads the committed specification files at the fetched branch tip.

type Sequence

type Sequence struct {
	Steps    []Step       `json:"steps" yaml:"steps"`
	Examples [][][]string `json:"examples,omitempty" yaml:"examples,omitempty,flow"`
}

func NormaliseStatement

func NormaliseStatement(statement, language string) (Sequence, error)

NormaliseStatement parses one record statement in the given dialect (English when empty). A statement consists of steps and their arguments.

func (Sequence) Digest

func (s Sequence) Digest() string

type Source

type Source struct {
	ID         string   `yaml:"id"`
	Repo       string   `yaml:"repo"`
	Path       string   `yaml:"path"`
	Follow     string   `yaml:"follow"`
	Format     Format   `yaml:"format"`
	Runner     string   `yaml:"runner,omitempty"`
	Registries []string `yaml:"registries"`
}

func (*Source) UnmarshalYAML

func (s *Source) UnmarshalYAML(unmarshal func(any) error) error

type Step

type Step struct {
	Type      messages.StepKeywordType `json:"type" yaml:"type"`
	Text      string                   `json:"text" yaml:"text"`
	DocString *DocString               `json:"doc_string,omitempty" yaml:"doc_string,omitempty"`
	DataTable [][]string               `json:"data_table,omitempty" yaml:"data_table,omitempty,flow"`
}

type Unit

type Unit struct {
	Address       string
	Line          int
	Digest        string
	ContextDigest string
	Binding       BindingStrength
	Text          string
	Sequence      *Sequence
	// contains filtered or unexported fields
}

func (Unit) Strength

func (u Unit) Strength() BindingStrength

Jump to

Keyboard shortcuts

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