vast

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder transforms parser output + schema into a validation-ready AST.

func NewBuilder

func NewBuilder() *Builder

NewBuilder creates a new VAST builder.

func (*Builder) Build

func (b *Builder) Build(doc *parser.Document, s *schema.Schema) *Tree

Build creates a validation-ready AST from document and schema.

type Context

type Context struct {
	// The validation-ready AST
	Tree *Tree

	// Schema reference (Tree.Document provides document access)
	Schema *schema.Schema

	// RootDir is the root directory for resolving absolute paths (e.g., /path links).
	// Typically the directory containing .mdschema.yml.
	RootDir string
	// contains filtered or unexported fields
}

Context provides all validation state with the validation-ready AST.

func NewContext

func NewContext(doc *parser.Document, s *schema.Schema, rootDir string) *Context

NewContext creates a new validation context with VAST. The rootDir is used for resolving absolute paths (e.g., /path links). Pass "" when no root directory is needed.

func (*Context) HasSlug

func (c *Context) HasSlug(slug string) bool

HasSlug checks if an internal anchor exists.

type Node

type Node struct {
	// Schema binding
	Element schema.StructureElement

	// Document binding (may be nil if required element is missing)
	Section *parser.Section

	// Semantic parent-child relationships (schema-driven, not heading-level-driven)
	Parent   *Node
	Children []*Node

	// Pre-computed validation state
	IsBound bool // True if a matching section was found

	// Ordering metadata
	Order       int // Expected order (position in schema)
	ActualOrder int // Actual order in document (line number for ordering violations)
}

Node represents a single schema-bound section in the validation AST. Each Node is a 1:1 binding between a schema element and a document section.

func (*Node) CodeBlocks

func (n *Node) CodeBlocks() []*parser.CodeBlock

CodeBlocks returns the code blocks if bound, empty slice otherwise.

func (*Node) Content

func (n *Node) Content() string

Content returns the section content if bound, empty string otherwise.

func (*Node) HeadingText

func (n *Node) HeadingText() string

HeadingText returns the heading text if bound, otherwise the schema pattern.

func (*Node) Images

func (n *Node) Images() []*parser.Image

Images returns the images if bound, empty slice otherwise.

func (n *Node) Links() []*parser.Link

Links returns the links if bound, empty slice otherwise.

func (*Node) Lists added in v0.4.0

func (n *Node) Lists() []*parser.List

Lists returns the lists if bound, empty slice otherwise.

func (*Node) Location

func (n *Node) Location() (line, column int)

Location returns line/column for error reporting.

func (*Node) Tables

func (n *Node) Tables() []*parser.Table

Tables returns the tables if bound, empty slice otherwise.

type PatternMatcher

type PatternMatcher struct {
	// contains filtered or unexported fields
}

PatternMatcher provides utilities for matching heading patterns.

func NewPatternMatcher

func NewPatternMatcher() *PatternMatcher

NewPatternMatcher creates a new pattern matcher with caching.

func (*PatternMatcher) MatchesHeadingPattern

func (pm *PatternMatcher) MatchesHeadingPattern(heading *parser.Heading, pattern string, isRegex bool) bool

MatchesHeadingPattern checks if a heading matches a pattern with explicit regex flag.

type Tree

type Tree struct {
	// Root nodes (top-level schema elements)
	Roots []*Node

	// Document reference for context
	Document *parser.Document

	// All nodes flattened for iteration
	AllNodes []*Node

	// Unmatched sections (sections in document but not in schema)
	UnmatchedSections []*parser.Section
}

Tree represents the complete validation-ready AST.

func (*Tree) GetByElement

func (t *Tree) GetByElement(heading string) []*Node

GetByElement finds all nodes matching a specific schema element heading pattern.

func (*Tree) Walk

func (t *Tree) Walk(fn func(*Node) bool)

Walk traverses all nodes in depth-first order. Returns early if fn returns false.

func (*Tree) WalkBound

func (t *Tree) WalkBound(fn func(*Node) bool)

WalkBound traverses only bound nodes (nodes with matching sections).

Jump to

Keyboard shortcuts

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