rules

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 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 CodeBlockRule

type CodeBlockRule struct {
}

CodeBlockRule validates code blocks using the hierarchical AST

func NewCodeBlockRule

func NewCodeBlockRule() *CodeBlockRule

NewCodeBlockRule creates a new simplified code block rule

func (*CodeBlockRule) GenerateContent

func (r *CodeBlockRule) GenerateContent(builder *strings.Builder, element schema.StructureElement) bool

GenerateContent generates placeholder code blocks for code block rules

func (*CodeBlockRule) Name

func (r *CodeBlockRule) Name() string

Name returns the rule identifier

func (*CodeBlockRule) ValidateWithContext

func (r *CodeBlockRule) ValidateWithContext(ctx *ValidationContext) []Violation

ValidateWithContext validates using pre-established section-schema mappings (no string matching)

type ContextualRule

type ContextualRule interface {
	// Name returns the rule identifier
	Name() string

	// ValidateWithContext uses pre-established section-schema mappings
	ValidateWithContext(ctx *ValidationContext) []Violation

	// GenerateContent generates markdown content for elements that match this rule
	// Returns true if the rule handled content generation for this element
	GenerateContent(builder *strings.Builder, element schema.StructureElement) bool
}

ContextualRule is an enhanced rule interface that uses pre-built mappings

type Generator

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

Generator creates markdown content using rules

func NewGenerator

func NewGenerator() *Generator

NewGenerator creates a generator that uses the same rules as the validator

func (*Generator) GenerateContent

func (g *Generator) GenerateContent(builder *strings.Builder, element schema.StructureElement)

GenerateContent generates content for an element using all applicable rules

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 RequiredTextRule

type RequiredTextRule struct {
}

RequiredTextRule validates required text within sections

func NewRequiredTextRule

func NewRequiredTextRule() *RequiredTextRule

NewRequiredTextRule creates a new section content rule

func (*RequiredTextRule) GenerateContent

func (r *RequiredTextRule) GenerateContent(builder *strings.Builder, element schema.StructureElement) bool

GenerateContent generates placeholder content for required text rules

func (*RequiredTextRule) Name

func (r *RequiredTextRule) Name() string

Name returns the rule identifier

func (*RequiredTextRule) ValidateWithContext

func (r *RequiredTextRule) ValidateWithContext(ctx *ValidationContext) []Violation

ValidateWithContext validates using pre-established section-schema mappings (no string matching)

type SectionMapping

type SectionMapping struct {
	Element  schema.StructureElement
	Sections []*parser.Section // All document sections that match this element
	Parent   *SectionMapping   // Parent mapping in the hierarchy
	Children []*SectionMapping // Child mappings
}

SectionMapping represents a mapping between a schema element and document sections

type Severity

type Severity string

Severity levels for violations

const (
	SeverityError   Severity = "error"
	SeverityWarning Severity = "warning"
	SeverityInfo    Severity = "info"
)

type StructureRule

type StructureRule struct {
}

StructureRule validates document structure using the hierarchical AST

func NewStructureRule

func NewStructureRule() *StructureRule

NewStructureRule creates a new simplified structure rule

func (*StructureRule) GenerateContent

func (r *StructureRule) GenerateContent(builder *strings.Builder, element schema.StructureElement) bool

GenerateContent generates structural organization and ordering information

func (*StructureRule) Name

func (r *StructureRule) Name() string

Name returns the rule identifier

func (*StructureRule) ValidateWithContext

func (r *StructureRule) ValidateWithContext(ctx *ValidationContext) []Violation

ValidateWithContext validates using pre-established section-schema mappings (no string matching)

type ValidationContext

type ValidationContext struct {
	Document *parser.Document
	Schema   *schema.Schema
	Mappings []*SectionMapping // Root-level mappings
}

ValidationContext provides clean access to section-schema mappings for rules

func NewValidationContext

func NewValidationContext(doc *parser.Document, s *schema.Schema) *ValidationContext

NewValidationContext creates a context with pre-established section-to-schema mappings

type Validator

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

Validator manages and runs all rules

func NewValidator

func NewValidator() *Validator

NewValidator creates a new validator with default rules for v0.1 DSL

func (*Validator) Validate

func (v *Validator) Validate(doc *parser.Document, schema *schema.Schema) []Violation

Validate runs all rules against a document

type Violation

type Violation struct {
	Rule     string
	Message  string
	Path     string
	Line     int
	Column   int
	Severity Severity
}

Violation represents a rule violation

func (Violation) Error

func (v Violation) Error() string

Error returns the violation as an error string

func (Violation) Position

func (v Violation) Position() string

Position returns the formatted position string

Jump to

Keyboard shortcuts

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