Skip to content

Commit 65ea123

Browse files
committed
docs: reorganize readme
1 parent d91a1fc commit 65ea123

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ If no paths are provided, then input is taken from `stdin` (as with `gofmt`).
3636
By default, the results are printed to `stdout`.
3737
To overwrite the existing files in place, use the `-w` flag.
3838

39+
## Examples
40+
41+
See this [before](/shorten/testdata/end_to_end/end_to_end.go) and [after](/shorten/testdata/end_to_end/end_to_end.go.golden) view of a file with very long lines.
42+
More example pairs can be found in the [`testdata`](/shorten/testdata) directory.
43+
44+
## Limitations
45+
46+
The tool has been tested on a variety of inputs, but it's not perfect.
47+
Among other examples, the handling of long lines in comments could be improved.
48+
If you see anything particularly egregious, please report it via an issue.
49+
3950
## Options
4051

4152
Some other options are described in the sections below.
@@ -47,31 +58,31 @@ By default, the tool tries to shorten lines that are longer than 100 columns
4758
and assumes that 1 tab = 4 columns.
4859
The latter can be changed via the `-m` and `-t` flags respectively.
4960

50-
#### Dry-run mode
61+
### Dry-run mode
5162

5263
Running the tool with the `--dry-run` flag will show pretty, git-style diffs.
5364

54-
#### Comment shortening
65+
### Comment shortening
5566

5667
Shortening long comment lines is harder than shortening code
5768
because comments can have arbitrary structure and format.
5869
`golines` includes some basic logic for shortening single-line (i.e., `//`-prefixed) comments,
5970
but this is turned off by default since the quality isn't great.
6071
To enable this feature anyway, run with the `--shorten-comments` flag.
6172

62-
#### Custom formatters
73+
### Custom formatters
6374

6475
By default, the tool will use [`goimports`](https://godoc.org/golang.org/x/tools/cmd/goimports)
6576
as the base formatter (if found), otherwise it will revert to `gofmt`.
6677
An explicit formatter can be set via the `--base-formatter` flag;
6778
the command provided here should accept its input via `stdin` and write its output to `stdout`.
6879

69-
#### Generated files
80+
### Generated files
7081

7182
By default, the tool will not format any files that look like they're generated.
7283
If you want to reformat these too, run with the flag `--ignore-generated=false`.
7384

74-
#### Chained method splitting
85+
### Chained method splitting
7586

7687
There are several possible ways to split lines that are part of
7788
[method chains](https://en.wikipedia.org/wiki/Method_chaining).
@@ -102,7 +113,7 @@ myObj.Method(arg1, arg2, arg3).
102113
The original behavior can be used by running the tool with the
103114
`--no-chain-split-dots` flag.
104115

105-
#### Struct tag reformatting
116+
### Struct tag reformatting
106117

107118
In addition to shortening long lines, the tool also aligns struct tag keys;
108119
see the associated [before](shorten/testdata/struct_tags/struct_tags.go)
@@ -193,11 +204,6 @@ like the one above, according to their preferences.
193204

194205
More background and technical details are available in [this blog post](https://yolken.net/blog/cleaner-go-code-golines).
195206

196-
## Examples
197-
198-
See this [before](/shorten/testdata/end_to_end/end_to_end.go) and [after](/shorten/testdata/end_to_end/end_to_end.go.golden) view of a file with very long lines.
199-
More example pairs can be found in the [`testdata`](/shorten/testdata) directory.
200-
201207
## How It Works
202208

203209
For each input source file, `golines` runs through the following process:
@@ -217,9 +223,3 @@ For each input source file, `golines` runs through the following process:
217223
`stdout` or the source file
218224

219225
See [this blog post](https://yolken.net/blog/cleaner-go-code-golines) for more technical details.
220-
221-
## Limitations
222-
223-
The tool has been tested on a variety of inputs, but it's not perfect.
224-
Among other examples, the handling of long lines in comments could be improved.
225-
If you see anything particularly egregious, please report it via an issue.

0 commit comments

Comments
 (0)