MCPcopy Create free account
hub / github.com/github/gh-aw / renderMap

Function renderMap

pkg/console/render.go:217–237  ·  view source on GitHub ↗

renderMap renders a map as markdown-style headers

(val reflect.Value, title string, output *strings.Builder, depth int)

Source from the content-addressed store, hash-verified

215
216// renderMap renders a map as markdown-style headers
217func renderMap(val reflect.Value, title string, output *strings.Builder, depth int) {
218 if val.Len() == 0 {
219 return
220 }
221
222 // Print title without FormatInfoMessage styling
223 if title != "" {
224 if depth == 0 {
225 fmt.Fprintf(output, "# %s\n\n", title)
226 } else {
227 fmt.Fprintf(output, "%s %s\n\n", strings.Repeat("#", depth+1), title)
228 }
229 }
230
231 // Render map entries
232 for _, key := range val.MapKeys() {
233 mapValue := val.MapIndex(key)
234 fmt.Fprintf(output, " %-18s %v\n", fmt.Sprintf("%v:", key), formatFieldValue(mapValue))
235 }
236 output.WriteString("\n")
237}
238
239// buildTableConfig builds a TableConfig from a slice of structs
240func buildTableConfig(val reflect.Value, title string) TableConfig {

Callers 1

renderValueFunction · 0.85

Calls 1

formatFieldValueFunction · 0.85

Tested by

no test coverage detected