Documentation
¶
Overview ¶
Package polyglot detects multi-language repository structures by scanning manifest files (go.mod, package.json, Cargo.toml, etc.) and grouping source files into language-specific layers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClassifyLayerRole ¶
ClassifyLayerRole is the public entry point for role classification. It takes source code snippets from a single layer and returns one of: "server", "client", "worker", or "library".
func DominantLanguage ¶ added in v1.22.2
DominantLanguage returns the most common language among the given files, counting only files with a non-empty Language. Returns "" if files is empty or no file has a recognised language.
This is the canonical implementation shared by every package that needs "most frequent language among a file set" — do not reimplement the argmax locally.
func DominantLanguageFromCounts ¶ added in v1.22.2
DominantLanguageFromCounts returns the language with the highest count. Returns "" if the map is empty. Ties resolve by Go's non-deterministic map iteration order, matching prior per-package implementations.
Types ¶
type CargoInfo ¶
type CargoInfo struct {
Name string
Version string
Edition string
Dependencies []string
DevDependencies []string
WorkspaceMembers []string
}
CargoInfo contains metadata extracted from a Cargo.toml file.
func ParseCargoToml ¶
ParseCargoToml extracts dependency and metadata from Cargo.toml content. Uses simple line-based parsing to avoid adding a TOML dependency.
type Layer ¶
Layer represents a distinct language area within the repository, typically rooted at a manifest file (go.mod, package.json, etc.).
type RepoStructure ¶
RepoStructure describes the detected language layout of a repository.
func DetectStructure ¶
func DetectStructure(files []*ingest.File) *RepoStructure
DetectStructure scans a list of ingested files for manifest files, groups files by the nearest manifest root, and builds layers.
func (*RepoStructure) IsPolyglot ¶
func (rs *RepoStructure) IsPolyglot() bool
IsPolyglot reports whether the repository contains 2 or more languages each with at least polyglotThreshold source files.