Skip to content

Parsing Source Code

๐Ÿšง work in progress

Extract elements from source code:

  • source.ExtractCodeElements(fileContent string, language string) ([]CodeElement, error)
// CodeElement represents a code structure element (class, function, method)
type CodeElement struct {
    Type        string // "class", "function", "method"
    Name        string
    Signature   string
    Description string
    LineNumber  int
    ParentClass string // For methods
    Parameters  []string
    Source      string // Source code of the element
}

the Signature could be useful to add context to embeddings.

Note

๐Ÿ‘€ you will find a complete example in: