Documentation
¶
Index ¶
- Variables
- type Classifier
- type FilenameParser
- type Language
- type ParseResult
- type Parser
- type Registry
- func (r *Registry) All() []Parser
- func (r *Registry) ExcludeExtensions() []string
- func (r *Registry) Fallback() Parser
- func (r *Registry) Get(lang Language) (Parser, bool)
- func (r *Registry) GetByExtension(ext string) (Parser, bool)
- func (r *Registry) ParserForFile(filePath string) (Parser, bool)
- func (r *Registry) Register(p Parser)
- func (r *Registry) SetExcludeExtensions(exts []string)
- func (r *Registry) SetFallback(p Parser)
- func (r *Registry) SupportedExtensions() []string
- func (r *Registry) SupportedFilenames() []string
Constants ¶
This section is empty.
Variables ¶
var FileExtensions = map[Language][]string{ LangGo: {".go"}, LangPython: {".py", ".pyi"}, LangTypeScript: {".ts", ".tsx"}, LangJavaScript: {".js", ".jsx", ".mjs", ".cjs"}, LangJava: {".java"}, LangHTML: {".html", ".htm", ".jinja2", ".j2", ".tmpl", ".gohtml", ".vue", ".svelte"}, LangMarkdown: {".md", ".mdx"}, LangMakefile: {".mk"}, LangShell: {".sh", ".bash"}, LangTerraform: {".tf", ".tfvars"}, LangYAML: {".yml", ".yaml"}, LangManifest: {".toml"}, LangRust: {".rs"}, LangCSharp: {".cs"}, LangRuby: {".rb", ".rake"}, }
FileExtensions maps each language to its recognized file extensions.
Functions ¶
This section is empty.
Types ¶
type Classifier ¶
type Classifier struct{}
Classifier performs post-parse classification of nodes, enriching them with architectural roles, design patterns, and layer tags based on heuristics (annotations, decorators, naming conventions, base classes, package paths).
func NewClassifier ¶
func NewClassifier() *Classifier
NewClassifier creates a new Classifier instance.
func (*Classifier) Classify ¶
func (c *Classifier) Classify(result *ParseResult) *ParseResult
Classify iterates all nodes in a ParseResult and enriches them with architectural metadata. It may reclassify node types (e.g., Class -> DBModel) and adds PropArchRole, PropDesignPattern, and PropLayerTag properties.
func (*Classifier) ClassifyNode ¶
func (c *Classifier) ClassifyNode(node *graph.Node) *graph.Node
ClassifyNode classifies a single node, modifying it in place.
type FilenameParser ¶
type FilenameParser interface {
Parser
// Filenames returns the exact filenames this parser can handle.
Filenames() []string
}
FilenameParser extends Parser for languages where files are identified by exact filenames rather than extensions (e.g., "Makefile", "Dockerfile").
type Language ¶
type Language string
Language represents a supported programming language.
const ( LangGo Language = "go" LangPython Language = "python" LangTypeScript Language = "typescript" LangJavaScript Language = "javascript" LangJava Language = "java" LangHTML Language = "html" LangMarkdown Language = "markdown" LangMakefile Language = "makefile" LangShell Language = "shell" LangTerraform Language = "terraform" LangYAML Language = "yaml" LangManifest Language = "manifest" LangRust Language = "rust" LangCSharp Language = "csharp" LangRuby Language = "ruby" )
type ParseResult ¶
type ParseResult struct {
Nodes []*graph.Node
Edges []*graph.Edge
FilePath string
Language Language
}
ParseResult holds the extracted nodes and edges from parsing a file.
type Parser ¶
type Parser interface {
// Language returns which language this parser handles.
Language() Language
// Extensions returns the file extensions this parser can handle.
Extensions() []string
// ParseFile parses the given file content and returns extracted nodes and edges.
ParseFile(filePath string, content []byte) (*ParseResult, error)
}
Parser defines the interface for language-specific source code parsers.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages a collection of language parsers.
func (*Registry) ExcludeExtensions ¶
ExcludeExtensions returns the list of extensions excluded from fallback processing.
func (*Registry) GetByExtension ¶
GetByExtension retrieves a parser by file extension (e.g. ".go", ".py").
func (*Registry) ParserForFile ¶
ParserForFile resolves the appropriate parser for a given file path. It first tries extension-based lookup, then filename-based lookup, then falls back to the generic fallback parser (if set).
func (*Registry) Register ¶
Register adds a parser to the registry, indexing it by language and file extensions. If the parser implements FilenameParser, it is also indexed by exact filenames.
func (*Registry) SetExcludeExtensions ¶
SetExcludeExtensions sets extensions to exclude from fallback processing.
func (*Registry) SetFallback ¶
SetFallback sets a fallback parser used when no language parser matches.
func (*Registry) SupportedExtensions ¶
SupportedExtensions returns all file extensions that have a registered parser.
func (*Registry) SupportedFilenames ¶
SupportedFilenames returns all filenames that have a registered parser.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package generic provides a fallback parser for non-code files (text, images).
|
Package generic provides a fallback parser for non-code files (text, images). |