Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manage YAML comment indentation #1946

Merged
merged 6 commits into from
Mar 1, 2022
Merged

Conversation

cognifloyd
Copy link
Contributor

This is probably not perfect but it indents more of the comment lines as prettier does.
Ideally, we need to peek at the next object to determine how to format the comment, but the Emitter does not have that information.
Hopefully a future release of ruamel.yaml will move more of the comment lines from "post" comments to "pre" comments so that the Emitter does not need to guess about what comes next.
That involves changing the parsing layer to split up the comments somehow, but it is too big a change for us to implement by extending ruamel.yaml.

This PR also fixes an issue where empty flow maps were written as { } instead of {}.

  • Don't dedent full line comments
  • Handle full line comments more like prettier
  • no space in empty flow maps and better full line comment indentation

@cognifloyd cognifloyd requested a review from a team as a code owner February 28, 2022 20:58
@cognifloyd cognifloyd added this to the 6.0.0 milestone Feb 28, 2022
@cognifloyd cognifloyd added the skip-changelog Can be missed from the changelog. label Feb 28, 2022
@cognifloyd cognifloyd self-assigned this Feb 28, 2022
@cognifloyd cognifloyd requested review from ssbarnea and removed request for a team February 28, 2022 20:58
@cognifloyd cognifloyd changed the title Manage comment indentation Manage YAML comment indentation Feb 28, 2022
@ssbarnea ssbarnea merged commit af9ae6b into ansible:main Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Can be missed from the changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants