schema

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2025 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 Schema

type Schema struct {
	// Document structure with embedded section rules
	Structure []StructureElement `yaml:"structure,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 []string `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
	Heading string `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

Jump to

Keyboard shortcuts

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