Repository navigation
fix(settings): keep doc comments on every list item in generated YAML - #283
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
to_yaml_string reset its list item counter on every non-list key, so each list item after the first was looked up as item 0. Docs that only exist for a later item, such as the fields of an Option that is None in the first item and Some in a later one, were dropped. Track the next item index per list indentation instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
to_yaml_stringreset its list item counter on every key line that is not a list item. When a list item has more than one key, the counter is back at 0 before the next item starts, so every item after the first is looked up as item0. Docs that exist only for a later item are then dropped from the generated YAML, for example the fields of anOptionthat isNonein the first item andSomein a later one. This affectsCli's--generateoutput andto_yaml_filewith both theserde_yamlandserde-saphyrbackends.This change tracks the next item index for each enclosing list by its indentation. A list item line continues the list at its indentation and ends any list nested in the previous item. A key line at or left of a list's dash ends that list.
Before
After
Testing
vec_items_with_different_fieldstofoundations/tests/settings.rs, with expected output for both YAML backends. It fails without the fix and passes with it.cargo test -p foundations --no-default-features --features settings --test settings: 13 passed, with and without--features serde-saphyr.cargo fmt --all -- --checkand the clippy command fromAGENTS.md(on--lib --test settings) are clean.Fixes #282