Documentation
¶
Index ¶
- func ExtractFilename(path string) string
- type Builder
- type Context
- type Node
- func (n *Node) CodeBlocks() []*parser.CodeBlock
- func (n *Node) Content() string
- func (n *Node) HeadingText() string
- func (n *Node) Images() []*parser.Image
- func (n *Node) Links() []*parser.Link
- func (n *Node) Lists() []*parser.List
- func (n *Node) Location() (line, column int)
- func (n *Node) Tables() []*parser.Table
- type PatternMatcher
- type Tree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractFilename ¶ added in v0.8.0
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.
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 ¶
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.
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 ¶
CodeBlocks returns the code blocks if bound, empty slice otherwise.
func (*Node) HeadingText ¶
HeadingText returns the heading text if bound, otherwise the schema pattern.
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 ¶
GetByElement finds all nodes matching a specific schema element heading pattern.