MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / render_object

Function render_object

src/mcp/tools/render.rs:657–688  ·  view source on GitHub ↗
(md: &mut Md, map: &serde_json::Map<String, Value>, depth: u8)

Source from the content-addressed store, hash-verified

655}
656
657fn render_object(md: &mut Md, map: &serde_json::Map<String, Value>, depth: u8) {
658 for (k, v) in map {
659 if is_scalar(v) {
660 let cell = cell_str(k, v);
661 // Omit empty scalar fields entirely (no bare "**docstring:** ").
662 if cell.is_empty() {
663 continue;
664 }
665 md.field(k, &cell);
666 }
667 }
668 for (k, v) in map {
669 if is_scalar(v) {
670 continue;
671 }
672 // Empty collections collapse to a single "section: none" line rather
673 // than a bare heading with no body.
674 if is_empty_collection(v) {
675 md.line(&format!("{k}: none"));
676 continue;
677 }
678 md.blank().heading(depth.min(6), k);
679 if depth >= GENERIC_MAX_DEPTH {
680 md.line(&format!(
681 "`{}`",
682 serde_json::to_string(v).unwrap_or_default()
683 ));
684 } else {
685 render_value(md, v, depth + 1);
686 }
687 }
688}
689
690#[cfg(test)]
691#[allow(clippy::unwrap_used)]

Callers 1

render_valueFunction · 0.85

Calls 9

is_scalarFunction · 0.85
cell_strFunction · 0.85
is_empty_collectionFunction · 0.85
render_valueFunction · 0.85
fieldMethod · 0.80
lineMethod · 0.80
headingMethod · 0.80
blankMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected