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

Feature: space between function and unit #649

Merged
merged 26 commits into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
95cc2cf
Split up setting SpaceBeforeArgument into multiple settings.
nojaf Jan 24, 2020
3040e39
Print warning for --noSpaceBeforeArgument.
nojaf Jan 24, 2020
446ddfc
Update SpaceBeforeArgument in json schema
nojaf Jan 24, 2020
36093e1
Adding extra settings for Class constructors
nojaf Jan 24, 2020
79484dd
Update documentation and schema.json
nojaf Jan 24, 2020
446c5cf
Add empty line at the end of file.
nojaf Jan 24, 2020
662fc07
Merged master
nojaf Jan 24, 2020
4b51b00
Updated month in release notes
nojaf Feb 3, 2020
3868c55
Merged master
nojaf Feb 3, 2020
860f07d
Merged master
nojaf Feb 3, 2020
c7d675f
Merge branch 'feature/space-between-function-and-unit' of https://git…
nojaf Feb 3, 2020
8a7c550
Merge branch 'master' of https://github.com/nojaf/fantomas
nojaf Feb 4, 2020
21fdbc0
Merge branch 'master' into feature/space-between-function-and-unit
nojaf Feb 4, 2020
fa8a37c
Merge remote-tracking branch 'upstream/master'
nojaf Feb 6, 2020
2f341d8
Merge branch 'master' of https://github.com/nojaf/fantomas
nojaf Feb 18, 2020
c28a045
Merge remote-tracking branch 'upstream/master'
nojaf Feb 18, 2020
e75942e
Merge remote-tracking branch 'upstream/master'
nojaf Feb 18, 2020
3fa733c
Merge remote-tracking branch 'upstream/master'
nojaf Feb 19, 2020
0d093e5
Merged latest master
nojaf Feb 21, 2020
cbfcbcd
Reduced class constructor setting to one setting.
nojaf Feb 21, 2020
cac8d65
Update sample default configuration
nojaf Feb 21, 2020
cfc1fc6
Merged latest master
nojaf Mar 6, 2020
cfb5e51
Simply configuration options
nojaf Mar 6, 2020
1ee8f20
Merge branch 'master' into feature/space-between-function-and-unit
nojaf Mar 17, 2020
56452ec
Update schema.json
nojaf Mar 17, 2020
b792c1d
Remove documentation for space before parameters.
nojaf Mar 17, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
235 changes: 228 additions & 7 deletions docs/Documentation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Fantomas: How to use

### Using the command line tool

---

For the overview how to use the tool, you can type the command
Expand Down Expand Up @@ -102,11 +103,220 @@ add semicolons at the end of lines e.g.
Mass = 0.0002858859807 * solarMass }
```

##### `--noSpaceBeforeArgument`
##### `--noSpaceBeforeArgument`

This option has been split into multiple settings.
These can be configured by passing a `fantomas-config.json` path to the `--config` flag.

###### `"SpaceBeforeUnitArgumentInUppercaseFunctionCall"`

> default false

Will add a whitespace before `()` argument when the function name starts with an uppercase character. e.g.

```fsharp
let value = MyFunction()
let value = person.ToString()
```

becomes

```fsharp
let value = MyFunction ()
let value = person.ToString ()
```

###### `"SpaceBeforeUnitArgumentInLowercaseFunctionCall"`

Will add a whitespace before `()` argument when the function name starts with a lowercase character. e.g.

> default false

```fsharp
let value = myFunction()
```

becomes

```fsharp
let value = myFunction ()
```

###### `"SpaceBeforeParenthesesArgumentInUppercaseFunctionCall"`

> default false

Will add a whitespace before an argument wrapped with parentheses when the function name starts with an uppercase character. e.g.

```fsharp
let value = MyFunction(a+b)
```

becomes

```fsharp
let value = MyFunction (a + b)
```

###### `"SpaceBeforeParenthesesArgumentInLowercaseFunctionCall"`

> default true

Will add a whitespace before an argument wrapped with parentheses when the function name starts with an lowercase character. e.g.

```fsharp
let value = myFunction(a+b)
```

becomes

```fsharp
let value = myFunction (a+b)
```

To remove the space, set `"SpaceBeforeParenthesesArgumentInLowercaseFunctionCall"` to `false`.

###### `"SpaceBeforeUnitParameterInUppercaseFunctionDefinition"`

> default false

Will add a whitespace before a `()` parameter in a function definition that starts with an uppercase letter. e.g.

```fsharp
let Value() = x
```

becomes

```fsharp
let Value () = x
```

###### `"SpaceBeforeUnitParameterInLowercaseFunctionDefinition"`

> default false

Will add a whitespace before a `()` parameter in a function definition that starts with an lowercase letter. e.g.

```fsharp
let value() = x
```

becomes

```fsharp
let value () = x
```

###### `"SpaceBeforeParenthesesInUppercaseFunctionDefinition"`

> default false

Will add a whitespace before a parameters wrapped with parentheses that starts with an uppercase letter. e.g.

```fsharp
let Value(a:int) = x
```

becomes

if being set, no space is inserted before a function name and its first argument.
For example, `Seq.filter (fun x -> x > 2)` becomes `Seq.filter(fun x -> x > 2)`.
This doesn't affect methods and constructors, e.g. `Console.WriteLine("Hello World")`.
```fsharp
let Value (a:int) = x
```

###### `SpaceBeforeParenthesesInLowercaseFunctionDefinition":true`

> default true

Will add a whitespace before a parameters wrapped with parentheses that starts with an uppercase letter. e.g.

```fsharp
let value(a:int) = x
```

becomes

```fsharp
let value (a:int) = x
```

To remove the space, set `"SpaceBeforeParenthesesInLowercaseFunctionDefinition"` to `false`.

###### `"SpaceBeforeUnitParameterInUppercaseClassConstructor"`

> default false

Will add a whitespace before an empty constructor of class definition that starts with an uppercase letter. e.g.

```fsharp
type Person() =
class end
```

becomes

```fsharp
type Person () =
class
end
```
nojaf marked this conversation as resolved.
Show resolved Hide resolved

###### `"SpaceBeforeUnitParameterInLowercaseClassConstructor"`

> default false

Will add a whitespace before an empty constructor of class definition that starts with a lowercase letter. e.g.

```fsharp
type t() =
class
end
```

becomes

```fsharp
type t () =
class
end
```

###### `"SpaceBeforeParenthesesParameterInUppercaseClassConstructor"`

> default false

Will add a whitespace before an non-empty constructor of class definition that starts with an uppercase letter. e.g.

```fsharp
type Animal(length:int) =
class end
```

becomes

```fsharp
type Animal (length: int) =
class
end
```

###### `"SpaceBeforeParenthesesParameterInLowercaseClassConstructor"`

> default false

Will add a whitespace before an non-empty constructor of class definition that starts with a lowercase letter. e.g.

```fsharp
type animal(length:int) =
class end
```

becomes

```fsharp
type animal (length:int) =
class end
```

##### `--spaceBeforeColon`

Expand Down Expand Up @@ -257,11 +467,22 @@ Use a JSON configuration file based on a [schema](../src/Fantomas/schema.json) t

A default configuration file would look like
```json
{
{
"IndentSpaceNum":4,
"PageWidth":120,
"SemicolonAtEndOfLine":false,
"SpaceBeforeArgument":true ,
"SpaceBeforeUnitArgumentInUppercaseFunctionCall":false,
"SpaceBeforeUnitArgumentInLowercaseFunctionCall":false,
"SpaceBeforeParenthesesArgumentInUppercaseFunctionCall":false,
"SpaceBeforeParenthesesArgumentInLowercaseFunctionCall":true ,
"SpaceBeforeUnitParameterInUppercaseFunctionDefinition":false,
"SpaceBeforeUnitParameterInLowercaseFunctionDefinition":false,
"SpaceBeforeParenthesesInUppercaseFunctionDefinition":false,
"SpaceBeforeParenthesesInLowercaseFunctionDefinition":true ,
"SpaceBeforeUnitParameterInUppercaseClassConstructor":false,
"SpaceBeforeUnitParameterInLowercaseClassConstructor":false,
"SpaceBeforeParenthesesParameterInUppercaseClassConstructor":false,
"SpaceBeforeParenthesesParameterInLowercaseClassConstructor":false,
Copy link
Contributor

Choose a reason for hiding this comment

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

2 remarks:

  • When the config setting says "functions" does it also mean methods? (just asking because I remember you opened a github issue in some MS docs repo where someone was advocating for defaults that differed depending if the invokation was on a function or a method)
  • When the config setting says "class constructor" does it also mean the invokation of it?

Copy link
Contributor

Choose a reason for hiding this comment

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

NOTE: you reduced ctor setting to one (SpaceBeforeClassConstructor) but here in the documentation there are still 4 ^

"SpaceBeforeColon":false,
"SpaceAfterComma":true ,
"SpaceAfterSemicolon":true ,
Expand All @@ -270,7 +491,7 @@ A default configuration file would look like
"SpaceAroundDelimiter":true ,
"KeepNewlineAfter":false,
"MaxIfThenElseShortWidth":40,
"StrictMode":false
"StrictMode":false
Copy link
Contributor

Choose a reason for hiding this comment

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

unneeded trailing whitespace addition?

}
```

Expand Down
Loading