Documentation
¶
Overview ¶
Package habits owns the M4 "habits" plugin. It derives "when do you commit" stats from the user's recent events feed. The full upstream behavior also analyzes commit diffs (lines / indent / chars per line) — the M4 MVP wires the day/hour histograms from PushEvents only, and exposes the input surface for the diff-based facts as a follow-up (commit-diff fetching lands alongside US3).
Index ¶
Constants ¶
const Name = "habits"
Name is the canonical plugin slug.
Variables ¶
var Plugin plugins.Plugin = &habitsPlugin{}
Plugin is the singleton registered with the global plugin registry.
Functions ¶
func Partial ¶
Partial renders the classic SVG fragment for the habits plugin. Mirrors upstream org_repo/source/templates/classic/partials/habits.ejs.
Two sections are emitted:
<section class="habits"> — header + facts list ("Mostly pushes code around HH:00", "Mostly active on Day", etc.)
<section class="habits"> — chart-bars - <h3>Commit activity per hour of day</h3> + chart-bars (24 bars) - <h3>Commit activity per day of week</h3> + chart-bars (7 bars)
The chart-bars block emits plain HTML inside foreignObject (no bare SVG primitives), fixing the v1.0.0 bare-`<g>` invisibility bug.
Types ¶
type HabitCharts ¶
HabitCharts holds the per-hour and per-weekday push event histogram.
type HabitFacts ¶
type HabitFacts struct {
LinesPerCommit float64 `json:"linesPerCommit"`
CharsPerLine float64 `json:"charsPerLine"`
CommitsPerDay float64 `json:"commitsPerDay"`
IndentStyle string `json:"indentStyle"`
}
HabitFacts holds the diff-derived statistics. In M4 MVP these are zero-valued because commit-diff fetching is deferred.
type HabitLinguist ¶ added in v1.1.0
type HabitLinguist struct {
Available bool `json:"available"`
Ordered []LanguageShare `json:"ordered"`
}
HabitLinguist holds the "Language activity" breakdown derived from the files touched by recent PushEvent commits. Mirrors upstream's `plugins.habits.linguist` ({available, ordered}). Available is false when no analyzable files were found, which keeps the section out of the SVG exactly like upstream's `linguist.available` gate.
type LanguageShare ¶ added in v1.1.0
type LanguageShare struct {
}
LanguageShare is one (language, share) pair in the Language activity chart. Share is the 0..1 fraction of analyzed bytes attributed to the language, matching upstream's `linguist.ordered` entries.
type Result ¶
type Result struct {
Skipped bool `json:"skipped,omitempty"`
SkippedReason string `json:"-"`
Days int `json:"days"`
FactsEnabled bool `json:"factsEnabled"`
ChartsEnabled bool `json:"chartsEnabled"`
Facts HabitFacts `json:"facts"`
Charts HabitCharts `json:"charts"`
Linguist HabitLinguist `json:"linguist"`
From int `json:"from"`
Trim bool `json:"trim"`
}
Result is the JSON payload published under data.Plugins["habits"].