Documentation
¶
Overview ¶
Package language provides language detection and configuration loading.
Index ¶
- Variables
- func Detect(projectRoot string) ([]string, error)
- func FilterDisabled(languages, disabled []string) []string
- func GetDisplayName(id string) string
- func HasUserContent(content string) bool
- func ListAvailableLanguages(teamDir, personalDir, projectDir string) ([]string, error)
- func LoadLanguageFiles(languages []string, teamDir, personalDir, projectDir string) (map[string][]*LanguageFile, error)
- func Resolve(cfg *LanguageConfig, projectRoot string) ([]string, error)
- type Language
- type LanguageConfig
- type LanguageFile
Constants ¶
This section is empty.
Variables ¶
var SupportedLanguages = []Language{ {ID: "python", DisplayName: "Python", Markers: []string{"pyproject.toml", "setup.py", "requirements.txt", "Pipfile", "poetry.lock"}}, {ID: "go", DisplayName: "Go", Markers: []string{"go.mod"}}, {ID: "typescript", DisplayName: "TypeScript", Markers: []string{"tsconfig.json"}}, {ID: "javascript", DisplayName: "JavaScript", Markers: []string{"package.json"}}, {ID: "rust", DisplayName: "Rust", Markers: []string{"Cargo.toml"}}, {ID: "java", DisplayName: "Java", Markers: []string{"pom.xml", "build.gradle", "build.gradle.kts"}}, {ID: "ruby", DisplayName: "Ruby", Markers: []string{"Gemfile"}}, {ID: "csharp", DisplayName: "C#", Markers: []string{"*.csproj", "*.sln"}}, {ID: "swift", DisplayName: "Swift", Markers: []string{"Package.swift"}}, {ID: "kotlin", DisplayName: "Kotlin", Markers: []string{"build.gradle.kts"}}, }
SupportedLanguages lists all languages staghorn can detect.
Functions ¶
func Detect ¶
Detect scans projectRoot for language marker files. Returns a sorted list of detected language IDs.
func FilterDisabled ¶ added in v0.2.0
FilterDisabled removes disabled languages from the list.
func GetDisplayName ¶
GetDisplayName returns the display name for a language ID.
func HasUserContent ¶ added in v0.2.0
HasUserContent checks if a markdown file contains user-added content beyond just headings and HTML comments. This is used to skip "empty" personal language files that were created but not yet customized.
func ListAvailableLanguages ¶
ListAvailableLanguages returns all language IDs that have files in any of the given directories.
func LoadLanguageFiles ¶
func LoadLanguageFiles(languages []string, teamDir, personalDir, projectDir string) (map[string][]*LanguageFile, error)
LoadLanguageFiles loads language configs from all layers for given languages. Returns a map of language ID to a slice of LanguageFiles (one per layer where found). Personal and project files without user content (just headings/comments) are skipped.
Types ¶
type Language ¶
type Language struct {
ID string // "python", "go", "typescript"
DisplayName string // "Python", "Go", "TypeScript"
Markers []string // Detection marker files
}
Language represents a supported programming language.
func GetLanguage ¶
GetLanguage returns the Language struct for a given ID.
type LanguageConfig ¶
type LanguageConfig struct {
AutoDetect bool `yaml:"auto_detect"`
Enabled []string `yaml:"enabled,omitempty"`
Disabled []string `yaml:"disabled,omitempty"`
}
LanguageConfig contains language-specific settings.