Documentation
¶
Index ¶
- func IsYAML(name string) bool
- func KindBreakdown(docs []*parser.Document) string
- func LoadDir(dir string, all bool) []*parser.Document
- func LoadDirSkipped(dir string, all bool) ([]*parser.Document, int)
- func LoadDocs(dir string, all bool) []*parser.Document
- func LoadPath(path string, all bool) ([]*parser.Document, error)
- func RecentByMtime(docs []*parser.Document, root string, limit int) []string
- func WithoutYAML(docs []*parser.Document) []*parser.Document
- type JSONDocument
- type JSONNode
- type JSONOutput
- type JSONRef
- type JSONSection
- type JSONSummary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KindBreakdown ¶
KindBreakdown renders per-format counts for a doc set, e.g. "2 md, 1 pdf, 2 yaml". Formats with no files are omitted.
func LoadDir ¶
LoadDir walks dir for markdown, PDF, plain-text and YAML documents. Unless all is true it skips dependency directories and honors .gitignore. Collection uses charlievieth/fastwalk (parallel WalkDir); parsing uses a worker pool bounded by GOMAXPROCS. Results are sorted by Filename.
func LoadDirSkipped ¶
LoadDirSkipped is LoadDir plus the number of .txt files the walk left out by name or size (see walkableText).
func LoadDocs ¶
LoadDocs is LoadDir without YAML. YAML under a tree is config, fixtures and CI, not documentation: gumroad has 3,514 spec/support YAML files that would otherwise count as docs. Explicit YAML paths and --all still load it.
func LoadPath ¶
LoadPath loads a single file or directory of docs. For directories, Filename is relative to path; for a file it is the base name.
func RecentByMtime ¶
RecentByMtime returns up to limit filenames sorted by mtime descending.
Types ¶
type JSONDocument ¶
type JSONDocument struct {
Filename string `json:"filename"`
Change string `json:"change,omitempty"`
OldPath string `json:"old_path,omitempty"`
ChangedLines []int `json:"changed_lines,omitempty"`
Tokens int `json:"tokens"`
Summary JSONSummary `json:"summary"`
Sections []JSONSection `json:"sections"`
Nodes []JSONNode `json:"nodes,omitempty"`
References []JSONRef `json:"references,omitempty"`
}
JSONDocument is one file in a JSONOutput.
type JSONNode ¶
type JSONNode struct {
Kind string `json:"kind"`
LineStart int `json:"line_start,omitempty"`
LineEnd int `json:"line_end,omitempty"`
Tokens int `json:"tokens,omitempty"`
Title string `json:"title,omitempty"` // Heading
Level int `json:"level,omitempty"` // Heading
Language string `json:"language,omitempty"` // CodeBlock
Code string `json:"code,omitempty"` // CodeBlock
Variant string `json:"variant,omitempty"` // Callout
Headers []string `json:"headers,omitempty"` // Table
Aligns []string `json:"aligns,omitempty"` // Table
TeX string `json:"tex,omitempty"` // MathBlock / InlineMath
ID string `json:"id,omitempty"` // FootnoteDef
Label string `json:"label,omitempty"` // LinkRefDef
URL string `json:"url,omitempty"` // LinkRefDef / Link
Checked *bool `json:"checked,omitempty"` // TaskItem
Raw string `json:"raw,omitempty"` // HTMLBlock / Frontmatter
Format string `json:"format,omitempty"` // Frontmatter
Target string `json:"target,omitempty"` // WikiLink / WikiEmbed
Children []JSONNode `json:"children,omitempty"`
}
JSONNode is the typed-AST-aware serialization format. Kind identifies the node type (e.g. "code_block", "callout"); remaining fields are populated per kind. Agents can switch on Kind to deserialize.
func ConvertNode ¶
ConvertNode serializes one typed AST node into JSON-friendly form. Only fields relevant to the kind are populated; omitempty keeps the output compact.
func ConvertNodeList ¶
ConvertNodeList serializes a flat node list.
type JSONOutput ¶
type JSONOutput struct {
Root string `json:"root"`
Since string `json:"since,omitempty"`
TotalTokens int `json:"total_tokens"`
TotalDocs int `json:"total_docs"`
Documents []JSONDocument `json:"documents"`
}
JSONOutput is the top-level --json / MCP documents payload.
func DocumentsJSON ¶
func DocumentsJSON(root string, docs []*parser.Document) JSONOutput
DocumentsJSON builds a full JSONOutput for a set of loaded documents.
type JSONRef ¶
type JSONRef struct {
Text string `json:"text"`
Target string `json:"target"`
Line int `json:"line"`
}
JSONRef is a cross-document reference edge.
type JSONSection ¶
type JSONSection struct {
Level int `json:"level"`
Title string `json:"title"`
Tokens int `json:"tokens"`
LineStart int `json:"line_start,omitempty"`
LineEnd int `json:"line_end,omitempty"`
KeyTerms []string `json:"key_terms,omitempty"`
Notables []JSONNode `json:"notables,omitempty"`
Children []JSONSection `json:"children,omitempty"`
}
JSONSection is a section tree node for JSON output.
func ConvertSections ¶
func ConvertSections(sections []*parser.Section) []JSONSection
ConvertSections serializes a section tree.
func ConvertSectionsSince ¶
func ConvertSectionsSince(sections []*parser.Section, changed map[int]bool) []JSONSection
ConvertSectionsSince keeps sections that touch changed lines (or have children that do).
type JSONSummary ¶
type JSONSummary struct {
Callouts int `json:"callouts,omitempty"`
Tables int `json:"tables,omitempty"`
CodeBlocks int `json:"code_blocks,omitempty"`
MathBlocks int `json:"math_blocks,omitempty"`
HTMLBlocks int `json:"html_blocks,omitempty"`
Footnotes int `json:"footnotes,omitempty"`
DefLists int `json:"definition_lists,omitempty"`
LinkRefDefs int `json:"link_ref_defs,omitempty"`
Tasks int `json:"tasks,omitempty"`
TasksChecked int `json:"tasks_checked,omitempty"`
WikiLinks int `json:"wiki_links,omitempty"`
WikiEmbeds int `json:"wiki_embeds,omitempty"`
Mentions int `json:"mentions,omitempty"`
IssueRefs int `json:"issue_refs,omitempty"`
CommitRefs int `json:"commit_refs,omitempty"`
Emojis int `json:"emojis,omitempty"`
}
JSONSummary mirrors parser.ContentSummary for JSON consumers.
func ConvertSummary ¶
func ConvertSummary(s parser.ContentSummary) JSONSummary
ConvertSummary maps a ContentSummary into JSONSummary.