docset

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsYAML

func IsYAML(name string) bool

IsYAML reports whether name has a YAML extension.

func KindBreakdown

func KindBreakdown(docs []*parser.Document) string

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

func LoadDir(dir string, all bool) []*parser.Document

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

func LoadDirSkipped(dir string, all bool) ([]*parser.Document, int)

LoadDirSkipped is LoadDir plus the number of .txt files the walk left out by name or size (see walkableText).

func LoadDocs

func LoadDocs(dir string, all bool) []*parser.Document

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

func LoadPath(path string, all bool) ([]*parser.Document, error)

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

func RecentByMtime(docs []*parser.Document, root string, limit int) []string

RecentByMtime returns up to limit filenames sorted by mtime descending.

func WithoutYAML

func WithoutYAML(docs []*parser.Document) []*parser.Document

WithoutYAML returns docs minus YAML files, preserving order.

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

func ConvertNode(n parser.Node) JSONNode

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

func ConvertNodeList(nodes []parser.Node) []JSONNode

ConvertNodeList serializes a flat node list.

func ConvertNodesSince

func ConvertNodesSince(nodes []parser.Node, changed map[int]bool) []JSONNode

ConvertNodesSince keeps nodes whose line range intersects changed.

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.

Jump to

Keyboard shortcuts

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