schema

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: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDefaultFile

func CreateDefaultFile(path string) error

CreateDefaultFile creates a .mdschema.yml file with default configuration

func FindSchema

func FindSchema(startPath string) (string, error)

FindSchema discovers schema files in the directory hierarchy

Types

type CodeBlockRule

type CodeBlockRule struct {
	Lang string `yaml:"lang"`
	Min  int    `yaml:"min,omitempty"`
	Max  int    `yaml:"max,omitempty"`
}

CodeBlockRule defines validation for code blocks within a section

type HeadingPattern added in v0.3.0

type HeadingPattern struct {
	// Pattern is the heading text or regex pattern to match
	Pattern string `yaml:"pattern,omitempty"`

	// Regex indicates the pattern should be treated as a regular expression
	Regex bool `yaml:"regex,omitempty"`
}

HeadingPattern defines a heading pattern with optional regex support

func (*HeadingPattern) UnmarshalYAML added in v0.3.0

func (h *HeadingPattern) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements custom unmarshaling to support both string and object syntax

type LinkRule added in v0.3.0

type LinkRule struct {
	// ValidateInternal validates anchor links (#section-name)
	ValidateInternal bool `yaml:"validate_internal,omitempty"`

	// ValidateFiles validates relative file links (./other.md)
	ValidateFiles bool `yaml:"validate_files,omitempty"`

	// ValidateExternal validates external URLs (http/https)
	ValidateExternal bool `yaml:"validate_external,omitempty"`

	// ExternalTimeout is the timeout in seconds for external URL checks (default: 10)
	ExternalTimeout int `yaml:"external_timeout,omitempty"`

	// AllowedDomains restricts external links to these domains only
	AllowedDomains []string `yaml:"allowed_domains,omitempty"`

	// BlockedDomains blocks external links to these domains
	BlockedDomains []string `yaml:"blocked_domains,omitempty"`
}

LinkRule defines validation rules for links in the document

type RequiredTextPattern added in v0.3.0

type RequiredTextPattern struct {
	// Pattern is the text or regex pattern to match
	Pattern string `yaml:"pattern,omitempty"`

	// Regex indicates the pattern should be treated as a regular expression
	Regex bool `yaml:"regex,omitempty"`
}

RequiredTextPattern defines a required text pattern with optional regex support

func (*RequiredTextPattern) UnmarshalYAML added in v0.3.0

func (r *RequiredTextPattern) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements custom unmarshaling to support both string and object syntax

type Schema

type Schema struct {
	// Document structure with embedded section rules
	Structure []StructureElement `yaml:"structure,omitempty"`

	// Global link validation rules
	Links *LinkRule `yaml:"links,omitempty"`
}

Schema represents the validation rules for Markdown files (v0.1 DSL)

func Load

func Load(path string) (*Schema, error)

Load reads and parses a schema file

func LoadMultiple

func LoadMultiple(paths []string) ([]*Schema, error)

LoadMultiple loads multiple schemas

type SectionRules

type SectionRules struct {
	// Required text/substrings within the section
	RequiredText []RequiredTextPattern `yaml:"required_text,omitempty"`

	// Code block requirements within this section
	CodeBlocks []CodeBlockRule `yaml:"code_blocks,omitempty"`
}

SectionRules defines validation rules scoped to a specific heading/section

type StructureElement

type StructureElement struct {
	// Heading pattern (string or {pattern: "...", regex: true})
	Heading HeadingPattern `yaml:"heading,omitempty"`

	// Optional element flag
	Optional bool `yaml:"optional,omitempty"`

	// Hierarchical children elements
	Children []StructureElement `yaml:"children,omitempty"`

	// Embedded section rules for validation within this element's scope
	*SectionRules `yaml:",inline"`
}

StructureElement represents an element in the document structure Supports hierarchical structure with children and section-scoped rules

func (*StructureElement) UnmarshalYAML

func (se *StructureElement) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements custom unmarshaling to support the new hierarchical syntax

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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