(md: &mut Md, map: &serde_json::Map<String, Value>, depth: u8)
| 655 | } |
| 656 | |
| 657 | fn 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)] |
no test coverage detected