Repository navigation
Add support for # fmt: skip directives - #223
Merged
Merged
Conversation
DavisVaughan
marked this pull request as ready for review
February 13, 2025 20:59
|
|
||
| `# fmt: skip file` skips the entire file. | ||
| This must be placed at the top of the file before the first non-comment R code, otherwise the comment is ignored. | ||
| Use this for generated files, or as an alternative to `exclude` for individual files that you know you'd like to exclude from formatting. |
Contributor
There was a problem hiding this comment.
Very happy to see this land in air! I was just taking a look at how this is implemented and noticed something unclear to me in the docs.
Is the sentence about generated files actually useful for end users? It seems to me that people who develop frameworks should include this in the generated files, but end users shouldn't since it will be overwritten next time the file is generated. The example following this paragraph is also a bit confusing in this regard.
lionel-
approved these changes
Feb 20, 2025
lionel-
force-pushed
the
feature/suppression
branch
from
February 21, 2025 11:00
0058a31 to
84d451e
Compare
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.
Closes #52
Motivating examples, until we add "official" support for these with
fmt: tabularorfmt: align-rightor something:Note that format directives are applied at the node level, meaning they are applied to whatever node the comment gets attached to (as determined by
place_comment()in the formatter). If a node is skipped, all of its children are also skipped.@lionel- I'm definitely open to more tests cases if you can think of any
@lionel- I went ahead and added a changelog bullet and some docs on
# fmt: skip file, it felt weird to talk about just# fmt skipknowing we are about to add this too. I've also gone ahead and addedFormatDirective::SkipFile. In the end it felt like a separate directive thanFormatDirective::Skiprather than an argument to that one. I'd also be open to# fmt: skip-fileif you like that better.