Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

Commit 02f198b

Browse files
Add aggregated function/class/type counts to directory frontmatter
Directories now include function_count, class_count, type_count by aggregating from their contained files via DEFINES_FUNCTION, DECLARES_CLASS, DEFINES relationships.
1 parent 27140e4 commit 02f198b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

internal/graph2md/graph2md.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,16 @@ func (c *renderContext) writeDirectoryFrontmatter(sb *strings.Builder) {
879879
fileCount := len(c.containsFile[c.node.ID])
880880
subdirCount := len(c.childDir[c.node.ID])
881881

882+
// Aggregate function/class/type counts from contained files
883+
funcCount := 0
884+
classCount := 0
885+
typeCount := 0
886+
for _, fileID := range c.containsFile[c.node.ID] {
887+
funcCount += len(c.definesFunc[fileID])
888+
classCount += len(c.declaresClass[fileID])
889+
typeCount += len(c.definesType[fileID])
890+
}
891+
882892
title := fmt.Sprintf("%s/ — %s Directory Structure", path, c.repoName)
883893
desc := fmt.Sprintf("Directory listing for %s/ in the %s codebase. Contains %d files and %d subdirectories.", path, c.repoName, fileCount, subdirCount)
884894

@@ -890,6 +900,9 @@ func (c *renderContext) writeDirectoryFrontmatter(sb *strings.Builder) {
890900
sb.WriteString(fmt.Sprintf("repo: %q\n", c.repoName))
891901
sb.WriteString(fmt.Sprintf("file_count: %d\n", fileCount))
892902
sb.WriteString(fmt.Sprintf("subdir_count: %d\n", subdirCount))
903+
sb.WriteString(fmt.Sprintf("function_count: %d\n", funcCount))
904+
sb.WriteString(fmt.Sprintf("class_count: %d\n", classCount))
905+
sb.WriteString(fmt.Sprintf("type_count: %d\n", typeCount))
893906

894907
parts := strings.Split(path, "/")
895908
if len(parts) > 0 {

0 commit comments

Comments
 (0)