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

Commit 27140e4

Browse files
Always show entity profile metrics, including zeroes
- Entity profile now shows all relevant metrics per node type even when zero, making API data gaps immediately visible - File entities: show line_count, imports, functions, classes, types - Function entities: show calls out, called by - Add line_count extraction for file nodes from API lineCount/endLine - JS renders metrics with value >= 0 (not just > 0) Refs #18
1 parent 9f022f2 commit 27140e4

File tree

3 files changed

+59
-48
lines changed

3 files changed

+59
-48
lines changed

internal/graph2md/graph2md.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,19 @@ func (c *renderContext) writeFileFrontmatter(sb *strings.Builder) {
617617
sb.WriteString(fmt.Sprintf("subdomain: %q\n", s))
618618
}
619619

620+
// File line count: use lineCount property, or compute from endLine
621+
if lc := getNum(props, "lineCount"); lc > 0 {
622+
sb.WriteString(fmt.Sprintf("line_count: %d\n", lc))
623+
} else if endLine := getNum(props, "endLine"); endLine > 0 {
624+
startLine := getNum(props, "startLine")
625+
if startLine <= 0 {
626+
startLine = 1
627+
}
628+
sb.WriteString(fmt.Sprintf("start_line: %d\n", startLine))
629+
sb.WriteString(fmt.Sprintf("end_line: %d\n", endLine))
630+
sb.WriteString(fmt.Sprintf("line_count: %d\n", endLine-startLine+1))
631+
}
632+
620633
sb.WriteString(fmt.Sprintf("import_count: %d\n", depCount))
621634
sb.WriteString(fmt.Sprintf("imported_by_count: %d\n", ibCount))
622635

internal/pssg/build/build.go

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -395,70 +395,68 @@ func (b *Builder) renderEntityPage(
395395
description := e.GetString("description")
396396

397397
// Entity profile chart data (compact format for JS)
398+
// Always include metrics so empty values are visible (helps diagnose API gaps)
399+
nodeType := e.GetString("node_type")
398400
profileData := map[string]interface{}{}
399-
if lc := e.GetInt("line_count"); lc > 0 {
400-
profileData["lc"] = lc
401-
}
402-
if co := e.GetInt("call_count"); co > 0 {
403-
profileData["co"] = co
404-
}
405-
if cb := e.GetInt("called_by_count"); cb > 0 {
406-
profileData["cb"] = cb
407-
}
408-
if ic := e.GetInt("import_count"); ic > 0 {
409-
profileData["ic"] = ic
410-
}
411-
if ib := e.GetInt("imported_by_count"); ib > 0 {
412-
profileData["ib"] = ib
413-
}
414-
if fn := e.GetInt("function_count"); fn > 0 {
415-
profileData["fn"] = fn
416-
}
417-
if cl := e.GetInt("class_count"); cl > 0 {
418-
profileData["cl"] = cl
419-
}
420-
if tc := e.GetInt("type_count"); tc > 0 {
421-
profileData["tc"] = tc
422-
}
423-
if fc := e.GetInt("file_count"); fc > 0 {
424-
profileData["fc"] = fc
401+
402+
profileData["lc"] = e.GetInt("line_count")
403+
404+
switch nodeType {
405+
case "Function":
406+
profileData["co"] = e.GetInt("call_count")
407+
profileData["cb"] = e.GetInt("called_by_count")
408+
case "File":
409+
profileData["ic"] = e.GetInt("import_count")
410+
profileData["ib"] = e.GetInt("imported_by_count")
411+
profileData["fn"] = e.GetInt("function_count")
412+
profileData["cl"] = e.GetInt("class_count")
413+
profileData["tc"] = e.GetInt("type_count")
414+
case "Class", "Type":
415+
profileData["fn"] = e.GetInt("function_count")
416+
profileData["cb"] = e.GetInt("called_by_count")
417+
case "Directory":
418+
profileData["fc"] = e.GetInt("file_count")
419+
profileData["fn"] = e.GetInt("function_count")
420+
profileData["cl"] = e.GetInt("class_count")
421+
default:
422+
// Domain, Subdomain, etc — include whatever is available
423+
if v := e.GetInt("function_count"); v > 0 {
424+
profileData["fn"] = v
425+
}
426+
if v := e.GetInt("file_count"); v > 0 {
427+
profileData["fc"] = v
428+
}
425429
}
430+
426431
if sl := e.GetInt("start_line"); sl > 0 {
427432
profileData["sl"] = sl
428433
}
429434
if el := e.GetInt("end_line"); el > 0 {
430435
profileData["el"] = el
431436
}
437+
432438
// Edge type breakdown
433439
edgeTypes := map[string]int{}
434-
if v := e.GetInt("import_count"); v > 0 {
435-
edgeTypes["imports"] = v
436-
}
437-
if v := e.GetInt("imported_by_count"); v > 0 {
438-
edgeTypes["imports"] += v
439-
}
440-
if v := e.GetInt("call_count"); v > 0 {
441-
edgeTypes["calls"] = v
440+
ic := e.GetInt("import_count")
441+
ibc := e.GetInt("imported_by_count")
442+
if ic+ibc > 0 {
443+
edgeTypes["imports"] = ic + ibc
442444
}
443-
if v := e.GetInt("called_by_count"); v > 0 {
444-
edgeTypes["calls"] += v
445+
co := e.GetInt("call_count")
446+
cbc := e.GetInt("called_by_count")
447+
if co+cbc > 0 {
448+
edgeTypes["calls"] = co + cbc
445449
}
446-
if v := e.GetInt("function_count"); v > 0 {
447-
edgeTypes["defines"] += v
448-
}
449-
if v := e.GetInt("class_count"); v > 0 {
450-
edgeTypes["defines"] += v
451-
}
452-
if v := e.GetInt("type_count"); v > 0 {
453-
edgeTypes["defines"] += v
450+
defines := e.GetInt("function_count") + e.GetInt("class_count") + e.GetInt("type_count")
451+
if defines > 0 {
452+
edgeTypes["defines"] = defines
454453
}
455454
if len(edgeTypes) > 0 {
456455
profileData["et"] = edgeTypes
457456
}
457+
458458
var entityChartJSON []byte
459-
if len(profileData) > 0 {
460-
entityChartJSON, _ = json.Marshal(profileData)
461-
}
459+
entityChartJSON, _ = json.Marshal(profileData)
462460

463461
// Source code (read from workspace if available)
464462
var sourceCode, sourceLang string

templates/_main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ window.addEventListener("load", function() {
212212
{ key: "tc", label: "Types", color: "#A98466" },
213213
{ key: "fc", label: "Files", color: "#808080" }
214214
];
215-
var metrics = metricDefs.filter(function(d) { return ep[d.key] > 0; })
215+
var metrics = metricDefs.filter(function(d) { return ep[d.key] !== undefined; })
216216
.map(function(d) { return { label: d.label, value: ep[d.key], color: d.color }; });
217217

218218
// Edge types from compact map {type: count}

0 commit comments

Comments
 (0)