OLD | NEW |
1 The dart_style package defines an automatic, opinionated formatter for Dart | 1 The dart_style package defines an automatic, opinionated formatter for Dart |
2 code. It replaces the whitespace in your program with what it deems to be the | 2 code. It replaces the whitespace in your program with what it deems to be the |
3 best formatting for it. Resulting code should following the [Dart style guide][] | 3 best formatting for it. Resulting code should following the [Dart style guide][] |
4 but, moreso, should look nice to most human readers, most of the time. | 4 but, moreso, should look nice to most human readers, most of the time. |
5 | 5 |
6 It handles indentation, inline whitespace and (by far the most difficult), | 6 It handles indentation, inline whitespace and (by far the most difficult), |
7 intelligent line wrapping. It has no problems with nested collections, function | 7 intelligent line wrapping. It has no problems with nested collections, function |
8 expressions, long argument lists, or otherwise tricky code. | 8 expressions, long argument lists, or otherwise tricky code. |
9 | 9 |
10 **The formatter is at a beta state right now. It does a good job on most code, | |
11 and I'd love to have you try it and [report bugs][bugs], but its output may | |
12 change over time.** | |
13 | |
14 ## Running it | 10 ## Running it |
15 | 11 |
16 The package exposes a simple command-line wrapper around the core formatting | 12 The package exposes a simple command-line wrapper around the core formatting |
17 library. The easiest way to invoke it is to [globally activate][] the package | 13 library. The easiest way to invoke it is to [globally activate][] the package |
18 and let pub put its executable on your path: | 14 and let pub put its executable on your path: |
19 | 15 |
20 $ pub global activate dart_style | 16 $ pub global activate dart_style |
21 $ dartformat ... | 17 $ dartfmt ... |
22 | 18 |
23 If you don't want `dartformat` on your path, you can run it explicitly: | 19 If you don't want `dartformat` on your path, you can run it explicitly: |
24 | 20 |
25 $ pub global activate dart_style --no-executables | 21 $ pub global activate dart_style --no-executables |
26 $ pub global run dart_style:format ... | 22 $ pub global run dart_style:format ... |
27 | 23 |
28 The formatter takes a list of paths, which can point to directories or files. | 24 The formatter takes a list of paths, which can point to directories or files. |
29 If the path is a directory, it processes every `.dart` file in that directory | 25 If the path is a directory, it processes every `.dart` file in that directory |
30 or any of its subdirectories. | 26 or any of its subdirectories. |
31 | 27 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 If it does do so, this is a critical bug and we'll fix it quickly. | 73 If it does do so, this is a critical bug and we'll fix it quickly. |
78 | 74 |
79 The rules the formatter uses to determine the "best" way to split a line may | 75 The rules the formatter uses to determine the "best" way to split a line may |
80 change over time. We don't promise that code produced by the formatter today | 76 change over time. We don't promise that code produced by the formatter today |
81 will be identical to the same code run through a later version of the formatter. | 77 will be identical to the same code run through a later version of the formatter. |
82 We do hope that you'll like the output of the later version more. | 78 We do hope that you'll like the output of the later version more. |
83 | 79 |
84 [bugs]: https://github.com/dart-lang/dart_style/issues | 80 [bugs]: https://github.com/dart-lang/dart_style/issues |
85 [dart style guide]: https://www.dartlang.org/articles/style-guide/ | 81 [dart style guide]: https://www.dartlang.org/articles/style-guide/ |
86 [globally activate]: https://www.dartlang.org/tools/pub/cmd/pub-global.html | 82 [globally activate]: https://www.dartlang.org/tools/pub/cmd/pub-global.html |
OLD | NEW |