vast

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractFilename added in v0.8.0

func ExtractFilename(path string) string

ExtractFilename extracts the filename without extension from a path

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)

	// Count tracking for multi-match elements
	MatchCount int // Total matches found for this element (0 if not multi-match)
	MatchIndex int // This node's index (0-based) among siblings with same element
}

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) MatchesHeading added in v0.8.0

func (pm *PatternMatcher) MatchesHeading(heading *parser.Heading, hp schema.HeadingPattern, filename string) bool

MatchesHeading checks if a heading matches a HeadingPattern (literal, pattern, or expr).

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