rules

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 13 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 ForbiddenTextRule added in v0.4.0

type ForbiddenTextRule struct {
}

ForbiddenTextRule validates that forbidden text patterns do not appear in sections

func NewForbiddenTextRule added in v0.4.0

func NewForbiddenTextRule() *ForbiddenTextRule

NewForbiddenTextRule creates a new forbidden text rule

func (*ForbiddenTextRule) GenerateContent added in v0.4.0

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

GenerateContent generates placeholder content for forbidden text rules

func (*ForbiddenTextRule) Name added in v0.4.0

func (r *ForbiddenTextRule) Name() string

Name returns the rule identifier

func (*ForbiddenTextRule) ValidateWithContext added in v0.4.0

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

ValidateWithContext validates using VAST (validation-ready AST)

type FrontmatterGenerator added in v0.4.0

type FrontmatterGenerator interface {
	Generate(builder *strings.Builder, s *schema.Schema) bool
}

FrontmatterGenerator generates document-level frontmatter content

type FrontmatterRule added in v0.4.0

type FrontmatterRule struct {
}

FrontmatterRule validates YAML frontmatter at the start of documents

func NewFrontmatterRule added in v0.4.0

func NewFrontmatterRule() *FrontmatterRule

NewFrontmatterRule creates a new frontmatter rule

func (*FrontmatterRule) Generate added in v0.4.0

func (r *FrontmatterRule) Generate(builder *strings.Builder, s *schema.Schema) bool

Generate generates YAML frontmatter based on schema configuration

func (*FrontmatterRule) Name added in v0.4.0

func (r *FrontmatterRule) Name() string

Name returns the rule identifier

func (*FrontmatterRule) ValidateWithContext added in v0.4.0

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

ValidateWithContext validates using VAST (validation-ready AST)

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

func (*Generator) GenerateFrontmatter added in v0.4.0

func (g *Generator) GenerateFrontmatter(builder *strings.Builder, s *schema.Schema)

GenerateFrontmatter generates document frontmatter using the frontmatter generator

type HeadingRule added in v0.4.0

type HeadingRule struct {
}

HeadingRule validates heading structure across the document

func NewHeadingRule added in v0.4.0

func NewHeadingRule() *HeadingRule

NewHeadingRule creates a new heading rule

func (*HeadingRule) Name added in v0.4.0

func (r *HeadingRule) Name() string

Name returns the rule identifier

func (*HeadingRule) ValidateWithContext added in v0.4.0

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

ValidateWithContext validates using VAST (validation-ready AST)

type ImageRule added in v0.4.0

type ImageRule struct {
}

ImageRule validates images using the hierarchical AST

func NewImageRule added in v0.4.0

func NewImageRule() *ImageRule

NewImageRule creates a new image rule

func (*ImageRule) GenerateContent added in v0.4.0

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

GenerateContent generates placeholder images for image rules

func (*ImageRule) Name added in v0.4.0

func (r *ImageRule) Name() string

Name returns the rule identifier

func (*ImageRule) ValidateWithContext added in v0.4.0

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

ValidateWithContext validates using VAST (validation-ready AST)

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) 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 ListRule added in v0.4.0

type ListRule struct {
}

ListRule validates lists using the hierarchical AST

func NewListRule added in v0.4.0

func NewListRule() *ListRule

NewListRule creates a new list rule

func (*ListRule) GenerateContent added in v0.4.0

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

GenerateContent generates placeholder lists for list rules

func (*ListRule) Name added in v0.4.0

func (r *ListRule) Name() string

Name returns the rule identifier

func (*ListRule) ValidateWithContext added in v0.4.0

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

ValidateWithContext validates using VAST (validation-ready AST)

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 Rule added in v0.4.0

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

	// ValidateWithContext uses pre-established section-schema mappings via VAST
	ValidateWithContext(ctx *vast.Context) []Violation
}

Rule is the base interface for all validation rules

type Severity

type Severity string

Severity levels for violations

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

type StructuralRule added in v0.4.0

type StructuralRule interface {
	Rule

	// 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
}

StructuralRule validates and generates content for structure elements (sections)

type StructureRule

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

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 TableRule added in v0.4.0

type TableRule struct {
}

TableRule validates tables using the hierarchical AST

func NewTableRule added in v0.4.0

func NewTableRule() *TableRule

NewTableRule creates a new table rule

func (*TableRule) GenerateContent added in v0.4.0

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

GenerateContent generates placeholder tables for table rules

func (*TableRule) Name added in v0.4.0

func (r *TableRule) Name() string

Name returns the rule identifier

func (*TableRule) ValidateWithContext added in v0.4.0

func (r *TableRule) 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, rootDir string) []Violation

Validate runs all rules against a document with a specified root directory. The rootDir is used for resolving absolute paths (e.g., /path links).

type Violation

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

Violation represents a rule violation

func NewViolation added in v0.4.0

func NewViolation(rule, message string, line, column int) Violation

NewViolation creates a violation with default severity (error)

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

func (Violation) WithPath added in v0.4.0

func (v Violation) WithPath(path string) Violation

func (Violation) WithSeverity added in v0.4.0

func (v Violation) WithSeverity(s Severity) Violation

WithSeverity returns a copy of the violation with the specified severity

type WordCountRule added in v0.4.0

type WordCountRule struct {
}

WordCountRule validates word count requirements for sections

func NewWordCountRule added in v0.4.0

func NewWordCountRule() *WordCountRule

NewWordCountRule creates a new word count rule

func (*WordCountRule) GenerateContent added in v0.4.0

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

GenerateContent generates placeholder content for word count rules

func (*WordCountRule) Name added in v0.4.0

func (r *WordCountRule) Name() string

Name returns the rule identifier

func (*WordCountRule) ValidateWithContext added in v0.4.0

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

ValidateWithContext validates using VAST (validation-ready AST)

Jump to

Keyboard shortcuts

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