From 47494fa84990bad928b40394a5e4c1e294cc6759 Mon Sep 17 00:00:00 2001 From: filifa Date: Sat, 5 Apr 2025 18:14:01 -0400 Subject: [PATCH] add comments on public methods --- cmd/internal/depgraph/dependencygraph.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/internal/depgraph/dependencygraph.go b/cmd/internal/depgraph/dependencygraph.go index 766294a..2fbcebf 100644 --- a/cmd/internal/depgraph/dependencygraph.go +++ b/cmd/internal/depgraph/dependencygraph.go @@ -23,36 +23,45 @@ import ( "gonum.org/v1/gonum/graph/simple" ) +// DependencyGraph represents dependencies between files in a Go package. type DependencyGraph struct { *simple.DirectedGraph } +// NewDependencyGraph returns an empty DependencyGraph. func NewDependencyGraph() *DependencyGraph { return &DependencyGraph{DirectedGraph: simple.NewDirectedGraph()} } +// NewNode returns a new Sourcefile node. func (g *DependencyGraph) NewNode() graph.Node { return &Sourcefile{Node: g.DirectedGraph.NewNode()} } +// Sourcefile represents a given source file in a Go package. type Sourcefile struct { graph.Node name string } +// String returns the name attribute of Sourcefile. func (s *Sourcefile) String() string { return s.name } +// NewSourcefile returns a Sourcefile node with ID determined by the CRC32 hash +// of the name of the source file. func NewSourcefile(name string) *Sourcefile { hash := crc32.ChecksumIEEE([]byte(name)) return &Sourcefile{Node: simple.Node(hash), name: name} } +// DOTID returns the name attribute of the source file. func (s *Sourcefile) DOTID() string { return s.name } +// SetDOTID sets the name attribute of a Sourcefile to the given id. func (s *Sourcefile) SetDOTID(id string) { s.name = id }