renderStruct renders a struct as markdown-style headers with key-value pairs
(val reflect.Value, title string, output *strings.Builder, depth int)
| 56 | |
| 57 | // renderStruct renders a struct as markdown-style headers with key-value pairs |
| 58 | func renderStruct(val reflect.Value, title string, output *strings.Builder, depth int) { |
| 59 | typ := val.Type() |
| 60 | renderLog.Printf("Rendering struct: type=%s, title=%s, depth=%d, fields=%d", typ.Name(), title, depth, val.NumField()) |
| 61 | |
| 62 | // Print title without FormatInfoMessage styling |
| 63 | if title != "" { |
| 64 | if depth == 0 { |
| 65 | fmt.Fprintf(output, "# %s\n\n", title) |
| 66 | } else { |
| 67 | fmt.Fprintf(output, "%s %s\n\n", strings.Repeat("#", depth+1), title) |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | maxFieldLen := computeMaxFieldLen(val) |
| 72 | renderInlineEmbeddedFields(val, maxFieldLen, output, depth) |
| 73 | |
| 74 | output.WriteString("\n") |
| 75 | } |
| 76 | |
| 77 | // renderInlineEmbeddedFields renders the fields of an anonymous embedded struct |
| 78 | // directly into the parent struct output, flattening the hierarchy. |
no test coverage detected