Documentation
¶
Overview ¶
Package languages — indepth.go implements the "languages.indepth" sub-mode of the M4 languages plugin. It walks base.Computed.RepositoryList, shallow clones each repo with go-git, runs go-enry against every blob in HEAD's tree, and aggregates byte counts per language across all repos.
Contracts: specs/004-m4-github-plugins/contracts/plugin-p3-heavy.md §2 Data model: specs/004-m4-github-plugins/data-model.md E-012
Like recent.go, the runtime is unconditionally compiled — only the fixture-heavy tests sit behind //go:build heavy.
Package languages owns the M4 "languages" plugin in its standard (most-used) mode. It aggregates per-repository language byte breakdowns the base plugin paged into pc.Data.Computed.RepositoryList and surfaces them as Favorites + Other + Mostly, mirroring upstream's data.plugins.languages JSON shape.
Recent-mode and indepth-mode (P3, build tag heavy) ship in separate files (recent.go / indepth.go). Standard mode never issues additional API calls — it relies entirely on the data base already collected.
Contracts: specs/004-m4-github-plugins/contracts/plugin-p1-mvp.md §1 Data model: specs/004-m4-github-plugins/data-model.md E-010
Package languages — recent.go implements the "languages.recent" sub-mode of the M4 languages plugin. It walks PushEvents from /users/<login>/events, fetches per-commit file lists from /repos/<owner>/<name>/commits/<sha>, runs each filename through go-enry, and aggregates byte counts per language using the same favorites/other split as standard mode.
Contracts: specs/004-m4-github-plugins/contracts/plugin-p3-heavy.md §1 Data model: specs/004-m4-github-plugins/data-model.md E-011
The runtime is unconditionally compiled (no build tag) so the plugin registry sees a "languages.recent" entry on every build. The heavy test fixtures sit behind //go:build heavy in recent_heavy_test.go.
Index ¶
Constants ¶
const IndepthClonerKey = "_test_languages_indepth_cloner"
IndepthClonerKey is the inputs map key tests use to inject a custom IndepthCloner. The key is intentionally exported-only-for-tests; the dotted-leading-underscore shape keeps it from colliding with the user-facing `plugin_languages_*` input namespace.
const IndepthName = "languages.indepth"
IndepthName is the canonical plugin slug for the indepth sub-mode.
const Name = "languages"
Name is the canonical plugin slug.
const RecentName = "languages.recent"
RecentName is the canonical plugin slug for the recent sub-mode.
Variables ¶
var IndepthPlugin plugins.Plugin = &indepthPlugin{}
IndepthPlugin is the singleton registered with the global plugin registry.
var Plugin plugins.Plugin = &languagesPlugin{}
Plugin is the singleton registered with the global plugin registry.
var RecentPlugin plugins.Plugin = &recentPlugin{}
RecentPlugin is the singleton registered with the global plugin registry. It runs the recent-mode aggregation against /users/X/events.
Functions ¶
func Partial ¶
Partial renders the classic SVG fragment for the languages plugin. Returns "" when the result is missing or skipped — classic.go's dispatcher then suppresses the wrapper entirely (contract §6).
DOM contract (partial-classic-m4.md §5): emits a single <g class="languages-progress"> containing one <rect class="language-bar"> per favorite + an "Other" rect when applicable.
Types ¶
type IndepthCloner ¶
IndepthCloner abstracts the shallow-clone step so tests can substitute a local-filesystem fixture without going through a real git server. Production code never sees this interface; only the heavy test file injects a custom implementation via IndepthClonerKey.
type IndepthResult ¶
type IndepthResult struct {
Skipped bool `json:"skipped,omitempty"`
SkippedReason string `json:"-"`
Repositories map[string]LanguageBytes `json:"repositories"`
Total LanguageBytes `json:"total"`
Analyzed []string `json:"analyzed"`
Errors []string `json:"errors,omitempty"`
}
IndepthResult is the JSON payload published under data.Plugins["languages.indepth"]. Field set mirrors data-model E-012.
func (*IndepthResult) IsSkipped ¶
func (r *IndepthResult) IsSkipped() bool
IsSkipped lets the classic dispatcher detect the skipped path.
type LanguageBytes ¶
LanguageBytes carries per-language byte totals.
type RecentResult ¶
type RecentResult struct {
Skipped bool `json:"skipped,omitempty"`
SkippedReason string `json:"-"`
Favorites []plugins.LanguageStat `json:"favorites"`
Other plugins.LanguageStat `json:"other"`
Days int `json:"days"`
Load int `json:"load"`
Repos []string `json:"repos"`
}
RecentResult is the JSON payload published under data.Plugins["languages.recent"]. Field set mirrors data-model E-011.
func (*RecentResult) IsSkipped ¶
func (r *RecentResult) IsSkipped() bool
IsSkipped lets the classic dispatcher detect the skipped path.
type Result ¶
type Result struct {
Skipped bool `json:"skipped,omitempty"`
SkippedReason string `json:"-"`
Mode string `json:"mode,omitempty"`
Favorites []plugins.LanguageStat `json:"favorites"`
Other plugins.LanguageStat `json:"other"`
Sections []string `json:"sections"`
Mostly plugins.LanguageStat `json:"mostly"`
Colors map[string]string `json:"colors"`
}
Result is the JSON payload the plugin publishes under data.Plugins["languages"]. Field set mirrors upstream data.plugins.languages (constitution 原則 II).