Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Column ¶
type Column struct {
// Name is the clean name of the column without any type suffixes.
Name string
// Type is the declared column type, defaulting to TypeString if not specified.
Type ColumnType
}
Column defines the schema of a single table column.
type ColumnType ¶
type ColumnType string
ColumnType represents the parsed data type of a table column.
const ( // TypeString represents a string column type. TypeString ColumnType = "string" // TypeInt represents an integer column type. TypeInt ColumnType = "int" // TypeFloat represents a floating-point column type. TypeFloat ColumnType = "float" // TypeBool represents a boolean column type. TypeBool ColumnType = "bool" )
type Comment ¶ added in v0.0.2
type Comment struct {
// Text is the Markdown source fragment for this comment block.
Text string
// Kind is the Markdown node category that produced this comment.
Kind CommentKind
// Range is the best-effort source location of Text in the original document.
Range SourceRange
// Target is an optional anchor such as a section title or config block name.
Target string
}
Comment is documentation prose or other non-config Markdown preserved during parsing.
type CommentKind ¶ added in v0.0.2
type CommentKind string
CommentKind identifies the Markdown node type preserved as a comment.
const ( // CommentParagraph is a normal prose paragraph. CommentParagraph CommentKind = "paragraph" // CommentBlockQuote is a blockquote block. CommentBlockQuote CommentKind = "blockquote" // CommentCodeBlock is a fenced or indented code block. CommentCodeBlock CommentKind = "code_block" // CommentHTML is raw HTML or an HTML comment block. CommentHTML CommentKind = "html" // CommentThematicBreak is a horizontal rule. CommentThematicBreak CommentKind = "thematic_break" // CommentOther is an unsupported or unknown block node. CommentOther CommentKind = "other" )
type Config ¶
type Config struct {
// RootSection holds tables, lists, checklists, and comments defined before any Markdown heading.
RootSection Section
// Sections maps section heading titles to their respective parsed Section configurations.
Sections map[string]*Section
}
Config is the root configuration structure containing all parsed Markdown data.
func DynamicParse ¶ added in v0.0.2
DynamicParse processes a Markdown byte slice and returns a structured Config with comments preserved.
func DynamicParseFrom ¶ added in v0.0.2
DynamicParseFrom reads Markdown data from an io.Reader and parses it into a structured Config.
func (*Config) AsString ¶
AsString generates a stable, deterministic, and highly detailed human-readable textual representation of the entire parsed configuration. It lists the root section first, followed by all other sections sorted alphabetically by their titles. For each section, it outputs its tables (including schemas and cell data with parsed types), sequential lists, checklists (with keys sorted alphabetically to ensure consistency across separate executions), and preserved comments. This is highly useful for debugging and golden-file testing.
type DecodeError ¶ added in v0.0.2
DecodeError reports a failure while mapping Markdown config data into a Go struct field.
func (*DecodeError) Error ¶ added in v0.0.2
func (e *DecodeError) Error() string
type Section ¶
type Section struct {
// Title is the heading text that represents the section category name.
Title string
// Level is the Markdown heading level (e.g., 1 for #, 2 for ##, etc.).
Level int
// Tables is the collection of tables parsed within this section.
Tables []Table
// Lists contains ordinary sequential list items grouped by list.
Lists [][]string
// BoolLists contains checklist maps representing checklist items and their checked status.
BoolLists []map[string]bool
// Comments holds non-config Markdown blocks within this section.
Comments []Comment
}
Section represents a configuration category defined by a Markdown heading.
type SourceRange ¶ added in v0.0.2
type SourceRange struct {
// Start is the inclusive byte offset in the source document.
Start int
// End is the exclusive byte offset in the source document.
End int
// Line is the 1-based line number at Start when known, otherwise zero.
Line int
// Col is the 1-based column number at Start when known, otherwise zero.
Col int
}
SourceRange maps a parsed block back to its location in the original Markdown bytes.
type Table ¶
type Table struct {
// Name is the name of the table, typically extracted from the preceding paragraph.
Name string
// Columns is the list of columns defining the table's schema.
Columns []Column
// Rows contains the table data, where each row is a slice of typed Values corresponding to the columns.
Rows [][]Value
}
Table represents a parsed Markdown table.
type ValidationError ¶
type ValidationError struct {
// Section is the title of the section containing the invalid table.
Section string
// TableIndex is the 0-based index of the table within its section.
TableIndex int
// TableName is the name of the table, if specified.
TableName string
// RowIndex is the 0-based index of the row containing the invalid value.
RowIndex int
// ColIndex is the 0-based index of the column containing the invalid value.
ColIndex int
// ColName is the name of the column containing the invalid value.
ColName string
// ExpectedType is the schema type that the value failed to conform to.
ExpectedType ColumnType
// Value is the raw string value that caused the validation failure.
Value string
// Message is the detailed description of the type conversion failure.
Message string
}
ValidationError describes an error that occurred while validating a table cell value against its column schema.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error formats the ValidationError into a detailed, human-readable string.
type Value ¶
type Value struct {
// Raw is the original string value extracted from the Markdown document.
Raw string
// Typed contains the validated Go typed value (string, int64, float64, bool) if parsed successfully, or nil otherwise.
Typed interface{}
}
Value represents a single cell or list item value that holds both its raw string representation and its successfully parsed typed value.