Documentation
¶
Index ¶
Constants ¶
const DefaultParseTimeout = time.Second
DefaultParseTimeout caps how long the parser will spend on a single file. Past this point the file is treated as unsupported and falls through as raw content. Pathological inputs (large table-driven test files, generated parser tables) can otherwise dominate runtime.
const Separator = "⋮----"
Variables ¶
This section is empty.
Functions ¶
func Outline ¶
Outline reduces source to a structural skeleton: declarations, signatures and comments are kept, function bodies are dropped. Returns the outline and true if the file's language is supported, otherwise "", false.
func SetParseTimeout ¶
SetParseTimeout overrides the per-file parse timeout. Must be called before the first Outline or Pack call; later calls are ignored once a language pool has been created. A zero duration disables the timeout.
Types ¶
type File ¶
type File struct {
Path string
Content string
Language string
Outlined bool
Symbols []Symbol // populated when Outlined is true
Size int64
Skipped string // reason content was omitted, e.g. "binary", "too-large"
}
File is one packed file.
type Import ¶ added in v0.2.0
type Import struct {
Module string
Kind ImportKind
Names []Name
Line int
}
Import is one source import form. A statement containing more than one form, such as a JavaScript default plus named import, produces one Import value for each form. Names is empty for side-effect and wildcard imports, and when a local binding cannot be established from the statement alone, such as an unaliased Go import.
type ImportKind ¶ added in v0.2.0
type ImportKind string
ImportKind identifies the source-language form of an import.
const ( // ImportNamed imports one or more named exports. ImportNamed ImportKind = "named" // ImportDefault imports a default export. ImportDefault ImportKind = "default" // ImportNamespace imports a module namespace. ImportNamespace ImportKind = "namespace" // ImportModule binds a module object using the language's module form. ImportModule ImportKind = "module" // ImportSideEffect loads a module without binding a local name. ImportSideEffect ImportKind = "side-effect" // ImportWildcard imports every exported name. ImportWildcard ImportKind = "wildcard" )
type Name ¶ added in v0.2.0
Name is one named import and its optional local alias. ImportDefault, ImportNamespace, and ImportModule use Alias for a local binding declared by the source syntax.
type Options ¶
type Options struct {
// MaxFileSize is the per-file byte limit. Files larger than this are
// listed in the tree but their content is omitted. Zero means 1MB.
MaxFileSize int64
// MaxFiles caps the number of files read. Zero means 10000.
MaxFiles int
// Compress applies tree-sitter outlining to supported source files.
// When false, full file contents are kept.
Compress bool
// Ignore adds gitignore-syntax patterns on top of .gitignore and the
// built-in defaults.
Ignore []string
// Concurrency is the number of files processed in parallel.
// Zero means runtime.NumCPU().
Concurrency int
}
Options configures Pack.
type Result ¶
Result is the output of Pack.
func Pack ¶
Pack walks root, reads text files that survive gitignore and default filtering, optionally outlines them, and returns the collected result.