Rustfmt: Survey for Code Style Preferences

Created on 23 Apr 2016  Â·  13Comments  Â·  Source: rust-lang/rustfmt

Recently I saw CSScomb's "Build your own config" page, which allows users to choose their favorite code style by choosing from examples multiple times (I think the examples even built upon previous choices).

Do you think this is something we could/should do for rustfmt as well?

This could also be used to find the code style that most people prefer.

fun! good first issue

Most helpful comment

This would be used to find a default for rustfmt right? Rather than helping people build configs. I feel like there should be at least a little friction to building configs so that only the people that do it are the really opinionated people.

All 13 comments

This would be awesome for rustfmt to have! It would be a great way to demo rustfmt on a webpage too.

I don't actually think this would be easy - it would be a big job - but you wouldn't need to know anything about rustfmt internals.

Maybe easy is the wrong label then? ;)

Maybe easy is the wrong label then? ;)

My thought process is that it is an appropriate issue for someone new to rustfmt to work on, but that is rather verbose for a label :-)

"Easy" aside, I like the "Fun!" label!

I would absolutely help out getting the web part going, so that we 'only' have to gather enough style options/examples 😄

I'm happy to help as well

On Wed, Apr 27, 2016, 12:11 AM Pascal Hertleif [email protected]
wrote:

"Easy" aside, I like the "Fun!" label!

I would absolutely help out getting the web part going, so that we 'only'
have to gather enough style options/examples 😄

—
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
https://github.com/rust-lang-nursery/rustfmt/issues/962#issuecomment-214980609

I'd also be interested in helping.

This would be used to find a default for rustfmt right? Rather than helping people build configs. I feel like there should be at least a little friction to building configs so that only the people that do it are the really opinionated people.

When you already have Rust sources with an undefined style that you like to adopt with rustfmt, you can use whatstyle to find the most similar rustfmt option values.

Furthermore by running, e.g.: whatstyle.py --variants yoursource.rs you can see how changing the option values would affect your code and eventually modify the style accordingly.

Maybe this is an alternative to "Build your own config" for you.

I have begun to implement something like this: https://github.com/m-decoster/rustfmt-cfg-generator.

It is far from complete but I am planning on adding configuration options over time. I would also like to eventually run this on a web server and have a page where you can try out your generated configuration file by copy-pasting code.

If you wish to contribute to this or have any remarks, feel free to do so.

Hello Mathieu,

this looks interesting, here are some things that I noticed for your consideration.

1)
After seeing the first two options I was wondering why you are not showing the resulting differences
between the options as you do starting with option 3.
To give a stronger first impression consider placing the diffless options after those that show diffs.
Even the options that only influence rustfmt console output (fixme/todo) could be shown as
shell output side by side.

2)
A back button would be useful.

3)
The intermediary rustfmt config file could be shown at each step eventually with the current option
highlighted separately while showing all available option values.

4)
I think good defaults are useful. If rustfmt has a default style consider putting the default option
always on the left side and make this clear to the user. If the user doesn't care about an option one way
or the other he is probably best served by sticking to the default.

Greetings,

Michael

On Dec 17, 2016, at 2:46 PM, Mathieu De Coster notifications@github.com wrote:

I have begun to implement something like this: https://github.com/m-decoster/rustfmt-cfg-generator https://github.com/m-decoster/rustfmt-cfg-generator.

It is far from complete but I am planning on adding configuration options over time. I would also like to eventually run this on a web server and have a page where you can try out your generated configuration file by copy-pasting code.

If you wish to contribute to this or have any remarks, feel free to do so.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/rust-lang-nursery/rustfmt/issues/962#issuecomment-267763701, or mute the thread https://github.com/notifications/unsubscribe-auth/AF1nvH0Rq7hXy9WHVB9LcE3PvsDJiXPVks5rI-fMgaJpZM4IOL5V.

1) For those first two options, it's because I haven't found a good clear example yet. I do think your point about diffless options showing after those with diffs is useful. I'll also add the shell output diffs, great idea.

2) You're right, I will implement this.

3) Very good idea.

4) This is already implemented actually: a checkmark indicates the default, an x mark indicates non-default options. The default is always on the left. I should make this more clear if it wasn't immediately obvious.

I also share @justgage's concerns that easy config generation could cause people to stray from the "default" Rust style too much. This is certainly something to consider.

cc @rust-lang-nursery/style

I think it's interesting, but the issue is that rustfmt doesn't implement the major issues; I still don't think it's possible to use block indent everywhere with rustfmt. I could see it being useful as a survey if it went into these kinds of things that rustfmt doesn't yet implement.

Was this page helpful?
0 / 5 - 0 ratings