Repository navigation
Description
Migrated from NobleFactor/noblefactor-engprod#45 (star now lives in this repository; GitHub blocks private→public transfers). Original discussion remains there.
Summary
Create a shared internal/language package that provides language definitions for all extensions to use. This would centralize:
- File extension mappings
- Filename mappings (Makefile, Dockerfile, etc.)
- Shebang pattern matching
- Comment styles (line and block)
- Language metadata
Motivation
Currently, the copyright package embeds its own language definitions in internal/copyright/defaults.yaml. Other extensions may need similar language information:
- Documentation generators need comment styles
- Code formatters need language detection
- Linters need file type identification
- Syntax highlighters need language metadata
Duplicating language definitions across extensions is error-prone and inconsistent.
Proposal
1. Create internal/language package
// internal/language/language.go
type Language struct {
ID string // e.g., "go", "python", "javascript"
Name string // Display name: "Go", "Python", "JavaScript"
Extensions []string // [".go"], [".py", ".pyw"], etc.
Filenames []string // ["Makefile"], ["Dockerfile"], etc.
Shebangs []string // Regex patterns for shebang detection
LineComment string // "//", "#", "--", etc.
BlockComment struct {
Start string // "/*", "<!--", etc.
Prefix string // " *", " ", etc.
End string // "*/", "-->", etc.
}
Aliases []string // ["golang"], ["python3", "py"], etc.
}2. Data source: VS Code language contributions
VS Code's language definitions are MIT-licensed and cover 100+ languages:
- https://github.com/microsoft/vscode/tree/main/extensions
- Each language extension has a
package.jsonwith:contributes.languages[].extensionscontributes.languages[].filenamescontributes.languages[].firstLine(shebang patterns)- Comment styles in language configuration files
We could:
- Extract and convert VS Code definitions to our format
- Maintain a curated subset manually
- Generate from VS Code at build time
3. Starlark receiver
# In Starlark scripts
lang = language.detect("script.py")
# Returns: {language: "python", method: "extension", comment_line: "#", ...}
lang = language.get("python")
# Returns full language definition
langs = language.all()
# Returns list of all supported languages4. Integration with copyright package
The copyright package would use internal/language for detection and comment styles, adding only copyright-specific config (header templates, match patterns).
Alternatives Considered
- Keep language definitions per-extension: Current approach. Simple but duplicates data.
- External dependency: Use a third-party language detection library. Adds dependency complexity.
- Minimal shared detection: Only share extension → language mapping, let extensions define their own comment styles. Partial solution.
Implementation Plan
- Create
internal/languagepackage with types - Extract/create language definitions YAML
- Implement detector with extension/filename/shebang priority
- Create
languageStarlark receiver - Migrate copyright package to use shared language detection
- Document for extension authors
References
- VS Code language contributions: https://code.visualstudio.com/api/language-extensions/overview
- VS Code extensions source: https://github.com/microsoft/vscode/tree/main/extensions
- Linguist (GitHub's language detection): https://github.com/github-linguist/linguist
Activity
David-Noble-at-work commentedon Nov 9, 2026
star github triage sweep added this issue to Triage: devlore, for the rule it breaks:
no-evidence: no Evidence of completion section