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

Editorconfig page #2427

Merged
merged 37 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
832a680
Rebased with master
alanlomeli Aug 17, 2022
e75305e
Merge branch 'master' of https://github.com/fsprojects/fantomas into …
alanlomeli Aug 17, 2022
1ca47a8
Add function for formatting settings inside configuration page.
alanlomeli Aug 17, 2022
118c396
Clean a little bit introduction file
alanlomeli Aug 18, 2022
21005a7
Introduction
alanlomeli Aug 19, 2022
42a0654
Separated sections
alanlomeli Aug 19, 2022
b04e8b0
Recommendation system draft
alanlomeli Aug 19, 2022
840a814
Move function to top and update fantomas version in configuration.fsx to
alanlomeli Aug 20, 2022
887fc54
Update not recommended color to orange
alanlomeli Aug 20, 2022
1596f76
Add G-Research logos
alanlomeli Aug 21, 2022
6f7db25
Reworded some redactions
alanlomeli Aug 21, 2022
7a745b9
Recommendation explanations
alanlomeli Aug 21, 2022
8ab548f
Custom tooltips when you hover on recommendation icons.
alanlomeli Aug 21, 2022
29834c2
Cleanup
alanlomeli Aug 21, 2022
aa5922e
Better gif quality
alanlomeli Aug 22, 2022
9aab7eb
Merge branch 'master' into editorconfig-page
alanlomeli Aug 22, 2022
0a3ddf3
Merge branch 'master' into editorconfig-page
alanlomeli Aug 22, 2022
b29926f
Icons and other stylings
alanlomeli Aug 23, 2022
17c897a
Deleted letters from SVG
alanlomeli Aug 23, 2022
13ba230
Code result stylings
alanlomeli Aug 23, 2022
3c26550
Inline icon to header
alanlomeli Aug 23, 2022
e2f447e
New gif
alanlomeli Aug 23, 2022
2c7867a
Merge branch 'master' of https://github.com/fsprojects/fantomas into …
alanlomeli Aug 23, 2022
0c2d61c
Merge branch 'editorconfig-page' of https://github.com/MLH-Fellowship…
alanlomeli Aug 23, 2022
cd85f95
Tweaks from last feedback
alanlomeli Aug 23, 2022
cbfde70
Onload event for listeners
alanlomeli Aug 24, 2022
6469e94
Custom Web Components
alanlomeli Aug 24, 2022
cfe8b54
Deleted unused class and comment
alanlomeli Aug 24, 2022
7dbf3d9
Merge branch 'master' of https://github.com/fsprojects/fantomas into …
alanlomeli Aug 24, 2022
fd29481
Minor visual tweaks and haunted implementation for web components.
alanlomeli Aug 25, 2022
7112774
Add settings list
alanlomeli Aug 25, 2022
ef5c845
Merge branch 'master' of https://github.com/fsprojects/fantomas into …
alanlomeli Aug 25, 2022
9b62f90
Tweak stylings, minor refactors, rewords
alanlomeli Aug 26, 2022
4e211a2
SVG change size for icon recommendations
alanlomeli Aug 26, 2022
969a542
Configurations with descriptions and code snippets!
alanlomeli Aug 26, 2022
35112ea
Fix fsharp_space_before_parameter not rendering the right example.
alanlomeli Aug 26, 2022
210ee9b
Changed icons margin to inline stylings
alanlomeli Aug 29, 2022
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
7 changes: 7 additions & 0 deletions docs/.style/fsdocs-custom.sass
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ $headings-font-family: 'Reem Kufi', sans-serif
line-height: 1
color: $white

.green-recommendation
color: $green
.red-recommendation
color: $red
.yellow-recommendation
color: $yellow

.fsdocs-source-link
float: right
text-decoration: none
Expand Down
5 changes: 4 additions & 1 deletion docs/.style/variables.sass
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ $drop-shadow: rgba(22, 22, 22, 0.2)
$white: #FFF
$pearl: #f6f7f7
$menu-open: #347193
$green: #92DC84
alanlomeli marked this conversation as resolved.
Show resolved Hide resolved
alanlomeli marked this conversation as resolved.
Show resolved Hide resolved
$yellow: #E9DFB2
$red: #EA7268
$navbar-light-brand-color: $white
$navbar-light-brand-hover-color: $white
$navbar-light-color: $white
$navbar-light-active-color: $secondary
$navbar-light-hover-color: $white
$navbar-nav-link-padding-x: 0
$navbar-nav-link-padding-x: 0
3 changes: 3 additions & 0 deletions docs/_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@
document.getElementById(e.target.id+'-wrapper').classList.add('menu-open');
}
})
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))

</script>
<!-- BEGIN SEARCH BOX: this adds support for the search box -->
<link rel="stylesheet"
Expand Down
166 changes: 166 additions & 0 deletions docs/docs/end-users/Configuration.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
(**
---
category: End-users
categoryindex: 1
index: 3
---
*)
#r "nuget: Fantomas.Core, 5.0.0-alpha-*"

open Fantomas.Core.FormatConfig
open Fantomas.Core

(**
# Configuration
Fantomas ships with a series of format options.
alanlomeli marked this conversation as resolved.
Show resolved Hide resolved
These can be stored in an [.editorconfig](https://editorconfig.org/) file and will be picked up automatically by the
commandline. <br>
Your IDE should respect your settings, but the implementation of that is editor specific. Setting the configuration via
alanlomeli marked this conversation as resolved.
Show resolved Hide resolved
UI might be available depending on the IDE but do note that these features might not be up to
alanlomeli marked this conversation as resolved.
Show resolved Hide resolved
date nor work properly, therefore it's support and use is out of scope for this project.
*)

(**
## Usage
Inside .editorconfig you can specify the file extension and code location to be use per config:
```
[*.fs]
fsharp_space_before_uppercase_invocation = true

# Write a comment by starting the line with a '#'
[*.{fs,fsx,fsi}]
fsharp_bar_before_discriminated_union_declaration = true

# Apply specific settings for a targeted subfolder
[src/Elmish/View.fs]
fsharp_multiline_block_brackets_on_same_column = true
fsharp_experimental_stroustrup_style = true
```
*)

(**
## Trying your settings via the online tool
You can quickly try your settings via the <a href="https://fsprojects.github.io/fantomas-tools/#/fantomas/preview" target="_blank">online tool</a>. <br>
<img src="{{root}}/online_tool_usage.gif" alt="drawing" width="100%"/>
*)

(**
## Settings recommendations
Fantomas ships with a series of settings that you can use freely depending on your case. However there are settings that we do not recommend and generally should not be used. <br>
alanlomeli marked this conversation as resolved.
Show resolved Hide resolved
<i class="bi bi-check-circle-fill green-recommendation"></i> Good to use: TBD<br>
<i class="bi bi-exclamation-circle-fill yellow-recommendation"></i> Not recommended: TBD <br>
<i class="bi bi-check-circle-fill red-recommendation"></i> Do not use: TBD<br>
*)

(**
## Auxiliary settings
#### <i class="bi bi-check-circle-fill green-recommendation" data-bs-toggle="tooltip" data-bs-title="This setting is good to use"></i> indent_size
` indent_size` has to be between 1 and 10.

This preference sets the indentation
The common values are 2 and 4.
The same indentation is ensured to be consistent in a source file.
Default = 4.

`defaultConfig`
alanlomeli marked this conversation as resolved.
Show resolved Hide resolved
*)
let input = """
let inline selectRandom (f: _ []) =
let r = random 1.0

let rec find =
function
| 0 -> fst f.[0]
| n when r < snd f.[n] -> fst f.[n]
| n -> find (n - 1)

find <| f.Length - 1
"""
let configIndent = { FormatConfig.Default with IndentSize = 2 }
(**

## Maximum width constraints
Copy link
Contributor

Choose a reason for hiding this comment

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

Before listing all the settings, I would add some introduction text that summarizes what these settings do. You can use some lorem ipsum for now if nothing comes to mind.

#### <i class="bi bi-check-circle-fill yellow-recommendation" data-bs-toggle="tooltip" data-bs-title="This setting is not recommended"></i>indent_size
` indent_size` has to be between 1 and 10.

This preference sets the indentation
The common values are 2 and 4.
The same indentation is ensured to be consistent in a source file.
Default = 4.

`defaultConfig`

*)
let input2 = """
let inline selectRandom (f: _ []) =
let r = random 1.0

let rec find =
function
| 0 -> fst f.[0]
| n when r < snd f.[n] -> fst f.[n]
| n -> find (n - 1)

find <| f.Length - 1
"""
let configIndent2 = { FormatConfig.Default with IndentSize = 2 }
(**

## G-Research style
#### <i class="bi bi-check-circle-fill yellow-recommendation" data-bs-toggle="tooltip" data-bs-title="This setting is not recommended"></i>indent_size
` indent_size` has to be between 1 and 10.

This preference sets the indentation
The common values are 2 and 4.
The same indentation is ensured to be consistent in a source file.
Default = 4.

`defaultConfig`

*)
let input3 = """
let inline selectRandom (f: _ []) =
let r = random 1.0

let rec find =
function
| 0 -> fst f.[0]
| n when r < snd f.[n] -> fst f.[n]
| n -> find (n - 1)

find <| f.Length - 1
"""
let configIndent3 = { FormatConfig.Default with IndentSize = 2 }
(**

## Other
#### <i class="bi bi-check-circle-fill red-recommendation" data-bs-toggle="tooltip" data-bs-title="You shouldn't use this setting"></i>indent_size

` indent_size` has to be between 1 and 10.

This preference sets the indentation
The common values are 2 and 4.
The same indentation is ensured to be consistent in a source file.
Default = 4.

`defaultConfig`

*)
let input4 = """
let inline selectRandom (f: _ []) =
let r = random 1.0

let rec find =
function
| 0 -> fst f.[0]
| n when r < snd f.[n] -> fst f.[n]
| n -> find (n - 1)

find <| f.Length - 1
"""
let configIndent4 = { FormatConfig.Default with IndentSize = 2 }
let formatCode input configIndent =
CodeFormatter.FormatDocumentAsync (false, input, configIndent)
|> Async.RunSynchronously

formatCode input configIndent
Loading