feat: support nested objects - #18
Conversation
Related to #14 Add support for arbitrary levels of nesting in `yamldoc`. * **Documentation Updates** - Update `docs/hier_tutorial.md` to reflect support for arbitrary levels of nesting. - Update `README.md` to remove the note about the two-level nesting limitation. * **Code Changes** - Modify `yamldoc/parser.py` to handle arbitrary levels of nesting. - Update `yamldoc/parser.py` to add type metadata for deeper nested entries. * **Test Updates** - Add new test cases in `test/test_examples.py` for deeper nesting. - Add new test cases in `test/test_exclude.py` for deeper nesting exclusion. - Update `test/yaml/two_level.yaml` and `test/schema/two_level.schema` to include examples of deeper nesting. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/Chris1221/yamldoc/issues/14?shareId=XXXX-XXXX-XXXX-XXXX).
Implements context-stack parser for routing sub-entries to the correct parent MetaEntry at any nesting depth, replacing the flat single-level approach. Nested MetaEntries now render as table rows within their parent section plus a deeper heading section (#### / #####). Also fixes add_type_metadata to search the full YAML tree recursively so schema types are applied correctly at any depth. Adds test fixtures for deeper nesting (three levels) and updates the exclusion test to cover nested exclusion. Removes the stale CircleCI badge from README and updates codecov badge to main branch. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
a1dc79b to
95e1c4b
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #18 +/- ##
==========================================
+ Coverage 90.52% 91.61% +1.08%
==========================================
Files 7 7
Lines 665 787 +122
==========================================
+ Hits 602 721 +119
- Misses 63 66 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@claude Please review |
|
Claude finished @Chris1221's task in 3m 4s —— View job Review complete
Note: I could not execute The overall approach is solid: replacing the old 2-level-only sub-entry handling with a generic Two things worth addressing: 1. Markdown heading levels overflow past 2 levels of nested h_section = "#" * (depth * 2)
h_members = "#" * (depth * 2 + 1)At 2.
Minor / non-blocking:
Nice work overall — the |
CommonMark only supports h1-h6; at nesting depth >= 3 the heading formula `depth * 2` would produce 7+ hashes which renders as plain text. Now falls back to bold text (**`name`** / **Member variables:**) for levels beyond h6. Also removes yamldoc.egg-info/ from git tracking (already in .gitignore, accidentally included from a prior rebase). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove leading newline from table_header() so Member variables tables don't have a blank line between the heading and the table - Skip extra blank line in to_markdown() when a MetaEntry has no meta text - Reduce nested section gap from 3 newlines to 1 so nested #### sections sit cleanly after their parent table row - Add blank line separator in main() between the flat-entry table and the first MetaEntry section (## heading) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Using a heading level for "Member variables:" was wasteful — it consumed a heading level at every nesting depth, accelerating the h6 overflow. Switching to bold text (**Member variables:**) keeps the visual hierarchy clear while leaving all heading levels for actual object names. Adds TestSpacing regression suite (5 tests) that preserve newlines to catch spacing regressions that the newline-stripping markdown tests miss: - blank line between flat table and first section heading - no extra blank line after the members label - single blank line before nested sections - no extra blank line for sections with empty meta - no consecutive blank lines across multiple YAML files Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
depth*2 jumped from ## straight to #### (skipping ###), making nested sections look more deeply indented than they are. depth+1 increments naturally: depth=1 → ##, depth=2 → ###, depth=3 → ####, up to h6 at depth=5. Overflow to bold still kicks in at depth=6+. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
Adds support for arbitrarily nested YAML objects in yamldoc documentation output.
What changed
parser.py): Replaced flat single-level sub-entry handling with a context stack (sub_stack) that routes new entries to the correct parentMetaEntryat any indentation depth.entries.py):MetaEntrynow has atypeattribute (for schema-derived type info) and ato_table_row()method for inline rendering within a parent table.MetaEntry.to_markdown()takes adepthparameter and uses depth-aware heading levels (##/###at depth 1,####/#####at depth 2), then recursively renders nested MetaEntries beneath the table.add_type_metadata): Recursive tree search replaces the previous 2-level-only approach, so schema types are applied correctly regardless of nesting depth.deeper_nesting.yaml,deeper_nesting.schema,deeper_nesting_exclusion.yaml) and full test coverage for 3-level nesting (parse, schema, E2E, markdown output, exclusion).mainbranch.Rendered output for 3-level nesting
Given:
Produces:
Test plan
TestYAMLs::test_deeper_nesting— parses 3-level structure correctlyTestSchemas::test_deeper_nesting— schema types applied at depth 3TestE2E::test_deeper_nesting— all keys/values present in outputTestMarkdown::test_deeper_nesting— exact markdown output matches expectedtest_deeper_nesting_exclusion— nested exclusion works correctly🤖 Generated with Claude Code