Documentation
¶
Overview ¶
Package parse turns raw file bytes into a normalized model.ParsedDoc. A small extension registry routes each file to its Parser: markdown, Go source, or the plain-text fallback. Richer SQL/HTML parsers are deliberately deferred — for V0 those extensions fall through to the text parser.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasFrontmatter ¶
HasFrontmatter reports whether content opens with a YAML frontmatter block (a leading `---` delimiter line). It lets callers distinguish "no frontmatter at all" from "frontmatter present but missing a field".
Types ¶
type GoParser ¶
type GoParser struct{}
GoParser parses Go source with the standard go/parser, emitting one section per top-level declaration (func, method, type) including its leading doc comment, with exact line ranges from the token.FileSet. When parsing fails (e.g. a non-compiling snippet) it falls back to a single whole-file section that the code chunker windows by lines.
type MarkdownParser ¶
type MarkdownParser struct{}
MarkdownParser parses markdown via goldmark. It extracts YAML frontmatter, builds heading-scoped sections with exact 1-based line ranges, and collects link destinations from the AST (not regex, so fenced code blocks don't produce false-positive links). OKF index.md files are marked structure-only.
type Parser ¶
type Parser interface {
// Parse reads src.Content and returns the normalized document.
Parse(ctx context.Context, src model.Source) (model.ParsedDoc, error)
}
Parser converts a Source into a ParsedDoc. Implementations must be deterministic and side-effect free.
type TextParser ¶
type TextParser struct{}
TextParser is the V0 fallback for any non-markdown, non-Go file (.txt, .sql, .html, .json, .yaml/.yml, .toml). It emits a single whole-document section; the text chunker handles paragraph/line windowing. Rich SQL/HTML structure is deliberately deferred past V0.