Skip to content

Commit f57e557

Browse files
committed
Improve CONTRIBUTING to point people who need the file here.
1 parent 3b13ae2 commit f57e557

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ For the folders below in monospace text, they are published on maven central at
4444
The easiest way to create a FormatterStep is `FormatterStep createNeverUpToDate(String name, FormatterFunc function)`, which you can use like this:
4545

4646
```java
47-
FormatterStep identityStep = FormatterStep.createNeverUpToDate("identity", unix -> unix)
47+
FormatterStep identityStep = FormatterStep.createNeverUpToDate("identity", unixStr -> unixStr)
4848
```
4949

5050
This creates a step which will fail up-to-date checks (it is equal only to itself), and will use the function you passed in to do the formatting pass.
@@ -73,7 +73,7 @@ public final class ReplaceStep {
7373
}
7474

7575
FormatterFunc toFormatter() {
76-
return raw -> raw.replace(target, replacement);
76+
return unixStr -> unixStr.replace(target, replacement);
7777
}
7878
}
7979
}
@@ -100,6 +100,10 @@ Here's a checklist for creating a new step for Spotless:
100100
- [ ] Test class has test methods to verify behavior.
101101
- [ ] Test class has a test method `equality()` which tests equality using `StepEqualityTester` (see existing methods for examples).
102102

103+
### Accessing the underlying File
104+
105+
In order for Spotless' model to work, each step needs to look only at the `String` input, otherwise they cannot compose. However, there are some cases where the source `File` is useful, such as to look at the file extension. In this case, you can pass a `FormatterFunc.NeedsFile` instead of a `FormatterFunc`. This should only be used in [rare circumstances](https://github.com/diffplug/spotless/pull/637), be careful that you don't accidentally depend on the bytes inside of the `File`!
106+
103107
## How to enable the _ext projects
104108

105109
The `_ext` projects are disabled per default, since:

0 commit comments

Comments
 (0)