Skip to content

Trim leading/trailing whitespace from fileHeaderComment #138

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

Merged
merged 2 commits into from
Aug 13, 2022

Conversation

liamnichols
Copy link
Member

@liamnichols liamnichols commented Aug 13, 2022

While testing 0.1 on some existing projects, I found a slight issue when using fileHeaderComment with multiline strings in yaml.

Lets say that we define the following configuration:

fileHeaderComment: |
  // Generated by Create API
  // https://github.com./CreateAPI/CreateAPI
  //
  // swiftformat:disable all
access: public
# ...

You'd expect it to generate some code like this:

// Generated by Create API
// https://github.com./CreateAPI/CreateAPI
//
// swiftformat:disable all

import Foundation 

// ...

However it will actually include two lines between the comment and the import statement because Yaml seems to add a trailing whitespace after the multiline string.

To address this, I've updated the generator so that it trims whitespace and newlines from the generated output. I also added a dedicated test to validate the behaviour since there wasn't one before.

@liamnichols liamnichols self-assigned this Aug 13, 2022
@liamnichols liamnichols merged commit c74ed47 into main Aug 13, 2022
@liamnichols liamnichols deleted the ln/trim-fileHeaderComment branch August 13, 2022 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant