rules

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 12 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 *vast.Context) []Violation

ValidateWithContext validates using VAST (validation-ready AST)

type ContextualRule

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

	// ValidateWithContext uses pre-established section-schema mappings via VAST
	ValidateWithContext(ctx *vast.Context) []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 VAST

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 LinkValidationRule added in v0.3.0

type LinkValidationRule struct {
}

LinkValidationRule validates internal and external links in the document

func NewLinkValidationRule added in v0.3.0

func NewLinkValidationRule() *LinkValidationRule

NewLinkValidationRule creates a new link validation rule

func (*LinkValidationRule) GenerateContent added in v0.3.0

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

GenerateContent generates placeholder content (links don't generate content)

func (*LinkValidationRule) Name added in v0.3.0

func (r *LinkValidationRule) Name() string

Name returns the rule identifier

func (*LinkValidationRule) ValidateWithContext added in v0.3.0

func (r *LinkValidationRule) ValidateWithContext(ctx *vast.Context) []Violation

ValidateWithContext validates links based on schema configuration

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 *vast.Context) []Violation

ValidateWithContext validates using VAST (validation-ready AST)

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 *vast.Context) []Violation

ValidateWithContext validates using VAST (validation-ready AST)

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, s *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