fix: combine graph visualization fixes — populate ArchData, fix double-encoding, fix len()#11
Conversation
…e-encoding, fix len() Combines changes from both fix branches to fully resolve graph rendering: 1. Populate ArchData (domain/subdomain force graph) in renderHomepage 2. Populate entity ChartData (profile chart) in renderEntityPage 3. Fix homepage chart JSON field names (label/topEntries → name/count/slug) 4. Change template.HTML → template.JS for all JSON in <script> tags to prevent double-encoding by html/template's JS context escaper 5. Fix len() template function to use reflect.ValueOf().Len() so it works with any slice/map/array/string type (fixes #8) 6. Add graph node enrichment fields (lc, lang, cc, cbc) in graph2md 7. Add SourceDir to PathsConfig for source code display 8. Add regression tests for double-encoding and length function Fixes #10 Co-authored-by: Jonathan Popham <jonathanpopham@users.noreply.github.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (6)
WalkthroughThis PR enriches graph nodes with metadata (line counts, language, call counts), converts template chart data from HTML to JavaScript representation, adds source code extraction from workspace, builds architecture overview graphs for homepages, and fixes the custom template length function to handle any slice/map type via reflection rather than brittle type switches. Changes
Sequence Diagram(s)sequenceDiagram
participant Source as Source Code<br/>(Workspace)
participant Graph as Graph Data<br/>Generation
participant Build as Build &<br/>Data Population
participant Template as Template<br/>Rendering
participant Output as HTML Output
Source->>Graph: Extract entities, calls, imports
Graph->>Graph: Compute LC, Lang, CC, CBC
Graph->>Build: Pass enriched graph nodes
Source->>Build: Read source snippets (start_line:end_line)
Build->>Build: Detect language from field/extension
Build->>Build: Build profileData JSON (counts + edge breakdown)
Build->>Build: Build ArchData JSON (domains/subdomains graph)
Build->>Template: Pass ChartData as template.JS
Build->>Template: Pass SourceCode & SourceLang
Build->>Template: Pass ArchData as template.JS
Template->>Template: Render with reflect-based length()
Template->>Output: Generate valid JSON in script tags (no double-encoding)
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
Fixes #10, fixes #8
Summary
Combines all fixes from the three previous branches into a single complete fix. Neither previous branch alone was sufficient — the first populated the data but double-encoded it, the second fixed the encoding but didn't populate ArchData.
Root Cause
The consolidation in
8f1470b(Feb 17) moved pssg fromtext/templatetohtml/template. Go'shtml/templateapplies JS-context escaping inside<script>tags, which double-encoded all JSON data (ChartData,ArchData) — wrapping valid JSON in quotes and escaping internal quotes. This broke graph rendering on all 6 repos built after the consolidation, while the 27 repos built before remained working.Changes
renderHomepagerenderEntityPagelabel/topEntries→name/count/slugto match JS treemap expectations<script>tagsreflect.ValueOf(v).Len()so[]taxonomy.Entrydoesn't return 0lc,lang,cc,cbcfields for node sizing/tooltipsSourceDirtoPathsConfigfor source code displayVerified
Test plan
go test ./...passes (13 render tests)<script>tags (no double-encoding)Summary by CodeRabbit
New Features
Improvements
Tests