-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Standardize toml format with taplo #10594
Standardize toml format with taplo #10594
Conversation
I would like to have |
what would be the default formatting, without a config file? |
@alice-i-cecile It is already, or what do you mean? |
My previous comment was expressing my endorsement of this change :) I like the intent, but I am unsure about the details. |
@mockersf the indent is with 2 spaces, but 4 is more used in rust. I checked other repos like wgpu and winit, and both use 4 spaces |
I think I would prefer without a config file. This should be mentioned in https://github.com/bevyengine/bevy/blob/main/CONTRIBUTING.md, with links to how to install and how to use it. I'm not sure it should be plugged in our |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this. IMO we should avoid duplicating this info in CONTRIBUTING.md, but if others want that, I don't feel strongly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great idea. I recently came across taplo
when contributing to matchbox
and it was fantastic to have a standardised Cargo.toml
file.
@ameknite if you can resolve conflicts, I'm happy to merge this in :) |
c8ced1d
to
4b285c8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to stick to the default settings
FWIW: custom settings could be specified in a configuration file if that's desirable. The VSCode extensions also correctly detects and uses it. |
yup, but adding a new file on the root level adds clutter to the repository. IMO formatting is already nicer enough, aiming for the 4 spaces isn't worth either the clutter or the complexity |
This is not a good change: - bevy_reflect = { path = "../bevy_reflect", version = "0.12.0", features = ["bevy"] }
+ bevy_reflect = { path = "../bevy_reflect", version = "0.12.0", features = [
+ "bevy",
+ ] } This is the first time I see features being split to a separate line (especially if there's only one feature), and it is less readable. Overall, you are adding more tooling that every contributor has to install and run before making a pull request. It does not need to be standardized. It needs to be readable and easy to use, and to me it doesn't look like achieving either. |
I'd suggest to go over each change and add them one-by-one (because current formatting is indeed inconsistent at times). In a year from now, if people add more inconsistencies, you can go over all the changes with your formatter again. Enforcing this and putting it on CI is imposing a small burden onto everyone (people who edit toml will have to install the tool, and the rest of contributors will just get worse CI response time). Same argument against |
By adding it to the CI, local devs don't need to have it installed. Once this is merged, the entire set of I would prefer it if this was a feature built into I think having something like this is important to avoid needless churn going forward. |
@ameknite, when I make a pull request, I grant access to that branch to bevy's maintainers ("Allowing edits by maintainers" checkbox on PR). Can this thing be configured to format, commit and automatically push formatted files to that branch that's triggered CI (if it's pull-request and not master branch of course)? |
Yeah, we could add a bot of some form that either automatically does formatting, or does it on command. I'd be interested in exploring that later for Rust/markdown/toml, as long as it's always in a separate commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- bevy_reflect = { path = "../bevy_reflect", version = "0.12.0", features = ["bevy"] }
+ bevy_reflect = { path = "../bevy_reflect", version = "0.12.0", features = [
+ "bevy",
+ ] }
I suggest to increase column_width (e.g. --option column_width=90
or 100
) specifically to keep older one-line formatting of internal modules with bevy
feature enabled.
This affects 20 changes in this PR (about half of it), and it's the only change that I can argue to be worse than before.
Coming from #10663 , could we add a Todo in the description to not forget to change the tracing doc link again? |
@rlidwka I would like to keep a simple fmt. It is not about achieving a beautiful format but rather making it standardize and easy to use. There reason why everyone agree to use cargo fmt is not because is pretty but because is standardize. |
@DasLixou Fixed, thanks for mentioned it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
212392e
to
ff28785
Compare
oh sorry, I didn't notice, it must have been the automatic formatting that I have in vscode |
# Objective - Standardize fmt for toml files ## Solution - Add [taplo](https://taplo.tamasfe.dev/) to CI (check for fmt and diff for toml files), for context taplo is used by the most popular extension in VScode [Even Better TOML](https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml - Add contribution section to explain toml fmt with taplo. Now to pass CI you need to run `taplo fmt --option indent_string=" "` or if you use vscode have the `Even Better TOML` extension with 4 spaces for indent --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Objective
Solution
Now to pass CI you need to run
taplo fmt
or if you use vscode have theEven Better TOML
extension with 2 spaces for indent