Internal

internal/adapters/markdown

Package markdown parses, renders, and stores living Markdown task specs.

import "github.com/nilstate/scafld/v2/internal/adapters/markdown"

Package markdown parses, renders, and stores living Markdown task specs.

Variables

Source: internal/adapters/markdown/spec_store.go:18

var (
	// ErrSpecNotFound is returned when taskID cannot be found in spec directories.
	ErrSpecNotFound = errors.New("spec not found")
	// ErrSpecExists is returned when a write would overwrite another task spec.
	ErrSpecExists = errors.New("spec already exists")
	// ErrMalformedMarkdown wraps spec Markdown grammar failures.
	ErrMalformedMarkdown = errors.New("malformed markdown spec")
)

Functions

func Parse(data []byte) (spec.Model, error)

Source: internal/adapters/markdown/parser.go:23

Parse converts living Markdown spec bytes into a normalized model.

func Render(model spec.Model) []byte

Source: internal/adapters/markdown/renderer.go:14

Render converts a normalized model into canonical living Markdown.

Types

type Store

Source: internal/adapters/markdown/spec_store.go:26

Store reads and writes Markdown task specs under a workspace root.

type Store struct {
	Root string
}
Fields
  • Root string

func CreateDraft(ctx context.Context, model spec.Model) (string, error)

Source: internal/adapters/markdown/spec_store.go:38

CreateDraft writes model as a new draft spec and returns its path.

func Find(taskID string) (string, error)

Source: internal/adapters/markdown/spec_store.go:81

Find returns the path for taskID across active spec directories.

func List(ctx context.Context) ([]spec.Record, error)

Source: internal/adapters/markdown/spec_store.go:111

List returns summaries for current non-archived task specs.

func ListAll(ctx context.Context) ([]spec.Record, error)

Source: internal/adapters/markdown/spec_store.go:116

ListAll returns summaries for current and archived task specs.

func Load(ctx context.Context, taskID string) (spec.Model, string, error)

Source: internal/adapters/markdown/spec_store.go:56

Load finds, parses, and returns a spec by task ID. If the file's directory disagrees with its frontmatter status, Load relocates it to the status-implied directory before returning. Relocation failures are non-fatal.

func Save(ctx context.Context, path string, model spec.Model) error

Source: internal/adapters/markdown/spec_store.go:49

Save writes model to an existing spec path.