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

Improve MiniYaml support for comments and whitespace. #15125

Merged
merged 4 commits into from May 12, 2018

Conversation

Projects
None yet
3 participants
@pchote
Copy link
Member

pchote commented May 7, 2018

The bulk of this PR is described by the second commit message:

Extend MiniYaml parser with new features:

  • Add support for escaping '#' inside values
  • Add support for escaping leading and trailing whitespace

And when discardCommentsAndWhitespace is set to false:

  • Add proper support for comments
  • Persist empty lines

Whitespace and comment support requires an explicit opt-in because
they produce MiniYamlNodes with null keys. Supporting these through
the entire game engine would require changing all yaml enumerations
to explicitly check and account for these keys with no benefit.

Comments and whitespace are now treated as real nodes during parsing,
which means that the yaml parser will throw errors if they have
incorrect indentation, even if these nodes will be discarded.

Fixes #2407. Fixes the mod updater removing comments and inserting/removing arbitrary newlines.

The comment indentation change requires special attention: modders will need to manually check and fix this before running the mod updater. This will need to be documented in the mod SDK upgrade instructions alongside other mod.yaml syntax changes.

@pchote pchote changed the title Improve MiniYaml roundtrips Improve MiniYaml support for comments and whitespace. May 7, 2018

@pchote pchote added this to the Next release milestone May 7, 2018

@pchote

This comment has been minimized.

Copy link
Member Author

pchote commented May 7, 2018

Note that the unit tests verify that this behaves correctly and does not break anything in the cases that we test. This should help with the intimidation barrier from the MiniYaml code.

pchote added some commits May 7, 2018

Extend MiniYaml parser with new features:
- Add support for escaping '#' inside values
- Add support for escaping leading and trailing whitespace

And when discardCommentsAndWhitespace is set to false:
- Add proper support for comments
- Persist empty lines

Whitespace and comment support requires an explicit opt-in because
they produce MiniYamlNodes with null keys.  Supporting these through
the entire game engine would require changing all yaml enumerations
to explicitly check and account for these keys with no benefit.

Comments and whitespace are now treated as real nodes during parsing,
which means that the yaml parser will throw errors if they have
incorrect indentation, even if these nodes will be discarded.

@pchote pchote force-pushed the pchote:yaml-comments branch from bc5e2b0 to 2b53310 May 7, 2018

@GraionDilach
Copy link
Contributor

GraionDilach left a comment

👍

@reaperrr reaperrr merged commit 6fdb25b into OpenRA:bleed May 12, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@pchote pchote deleted the pchote:yaml-comments branch Jul 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.