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

Update documentation #4345

Merged
merged 4 commits into from
Jul 28, 2020
Merged

Update documentation #4345

merged 4 commits into from
Jul 28, 2020

Conversation

ayazhafiz
Copy link
Contributor

@ayazhafiz ayazhafiz commented Jul 22, 2020

This commit includes changes to the readme, cargo-fmt, and rustfmt

  • Readme
    • rearrange sections to an order I believe is a more natural
      progression (this is opinionated, open to suggestions)
    • add a TOC (I can add a CI test to ensure it's up to date, lmk what
      you think)
  • cargo-fmt
    • link to config options
  • rustfmt
    • elaborate on operation with files/stdin
    • include examples
    • link to config options

This commit includes changes to the readme, cargo-fmt, and rustfmt

- Readme
  - rearrange sections to an order I believe is a more natural
    progression (this is opinionated, open to suggestions)
  - add a TOC (I can add a CI test to ensure it's up to date, lmk what
    you think)
- cargo-fmt
  - link to config options
- rustfmt
  - elaborate on operation with files/stdin
  - include examples
  - link to config options

Closes rust-lang#4336
Comment on lines +94 to 101
You can run `rustfmt --help` for information about available arguments.

You can run Rustfmt by just typing `rustfmt filename` if you used `cargo
install`. This runs rustfmt on the given file, if the file includes out of line
modules, then we reformat those too. So to run on a whole module or crate, you
just need to run on the root file (usually mod.rs or lib.rs). Rustfmt can also
read data from stdin. Alternatively, you can use `cargo fmt` to format all
binary and library targets of your crate.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the section that I'm most interested in updating to address #4336

There's items in the current text that are strictly not true, like the if the file includes out of line modules, then we reformat those too which is quite false with rustfmt 2.0 (so relevant for anyone building from source). Then there's other items like the if you used cargo install clause in the first sentence feels a bit dated/out of place (rustfmt filename is available regardless of whether you used rustup, installed from crates.io, or build from source).

Here's a high level framing and order of the items that IMO we should call out here, let me know what you think

  1. cargo fmt is the easiest way to run rustfmt against your entire project and is the general recommendation, worth calling out cargo fmt --help. this is true for single-crate projects, but also cargo workspaces (not sure we necessarily need to call that out here)
  2. Less commonly used, but rustfmt can also be used directly to format files (rustfmt foo.rs bar.rs) or via stdin, but want to highlight the stdin bit more than the current text does
    a. rustfmt 1.x will format out of line mods by default, so rustfmt rootfile will basically format the entire project
    b. rustfmt 2.x does not format out of line mods by default, requires --recursive flag

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds great to me, are you okay with the addition of this in a followup PR where I will also add changes to the running section?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's fine, but will want to keep #4336 open til after that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm

@ayazhafiz
Copy link
Contributor Author

@calebcartwright sorry for the late response, I have been very busy ): ptal

Copy link
Member

@calebcartwright calebcartwright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@calebcartwright calebcartwright merged commit a190c4b into rust-lang:master Jul 28, 2020
@calebcartwright
Copy link
Member

By the way, forgot to mention this earlier but really like the ordering of content. It's a conceptually simple change but does read much more fluidly now to me as well 👍

ayazhafiz added a commit to ayazhafiz/rustfmt that referenced this pull request Aug 1, 2020
This time we try to clean up a lot of the README, after its structure
was reorged in rust-lang#4345.

cc @calebcartwright

Closes rust-lang#4336
calebcartwright pushed a commit that referenced this pull request Aug 5, 2020
* Update documentation, round 2

This time we try to clean up a lot of the README, after its structure
was reorged in #4345.

cc @calebcartwright

Closes #4336

* fixup! Update documentation, round 2
@karyon
Copy link
Contributor

karyon commented Oct 28, 2021

@calebcartwright says he'll likely overhaul the readme in 1.x anyway, backport not needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants