languages

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.

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.

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.

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

View Source
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.

View Source
const IndepthName = "languages.indepth"

IndepthName is the canonical plugin slug for the indepth sub-mode.

View Source
const Name = "languages"

Name is the canonical plugin slug.

View Source
const RecentName = "languages.recent"

RecentName is the canonical plugin slug for the recent sub-mode.

Variables

View Source
var IndepthPlugin plugins.Plugin = &indepthPlugin{}

IndepthPlugin is the singleton registered with the global plugin registry.

View Source
var Plugin plugins.Plugin = &languagesPlugin{}

Plugin is the singleton registered with the global plugin registry.

View Source
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).

Output structure (matches upstream org_repo/source/templates/classic/partials/languages.ejs):

<section data-section="languages">
  <h2 class="field"><svg/>N Language(s)</h2>          ← count header (a11y title via aria-hidden octicon)
  <section class="column">
    <h3 class="field">Most used languages</h3>        ← section sub-header
    [<small>estimation from N kb...</small>]          ← indepth summary (when indepth result present)
    <svg class="bar" xmlns=... width=460 height=8>    ← progress bar wrapper (FIXES bare-<g> bug)
      <title>Languages distribution</title>           ← a11y title (Q1 verbatim preservation)
      <g class="languages-progress">
        <rect class="language-bar" .../>...
      </g>
    </svg>
    <div class="field center horizontal-wrap fill-width">  ← per-language dot+name list
      <div class="field center no-wrap language">
        <svg/>Go
      </div>...
    </div>
    [<ul class="languages-list">...]                  ← compat shim retained per parity checklist deviation
  </section>
  [<section class="column"><h3>Recently used languages</h3>
    <small>estimation from...</small>
    <svg class="bar"><g class="languages-recent">...</g></svg>
  </section>]
  [<g class="languages-indepth">...]                  ← wrapped in <svg> for visibility
</section>

Types

type IndepthCloner

type IndepthCloner interface {
	Clone(ctx context.Context, dst, url string) (string, error)
}

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

type LanguageBytes struct {
	Bytes map[string]int64 `json:"bytes"`
}

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"`
	// Details mirrors upstream `plugins.languages.details` — a list of
	// per-language detail columns to render. Subset of
	// {"lines", "bytes-size", "percentage"}. mjun0812 uses all three.
	// (011 v2 additive extension per Principle II.)
	Details []string `json:"details,omitempty"`
	// Unique is the distinct-language count surfaced in the count
	// header — mirrors upstream `plugins.languages.unique`. Computed
	// across all analyzed repositories before favorites truncation.
	Unique int `json:"unique,omitempty"`
}

Result is the JSON payload the plugin publishes under data.Plugins["languages"]. Field set mirrors upstream data.plugins.languages (constitution 原則 II).

func (*Result) IsSkipped

func (r *Result) IsSkipped() bool

IsSkipped lets the classic dispatcher (and any duck-typed consumer) detect the skipped path uniformly across plugins.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL