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 17 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
23 changes: 23 additions & 0 deletions docs/.style/fsdocs-custom.sass
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,29 @@ $headings-font-family: 'Reem Kufi', sans-serif
line-height: 1
color: $white

.green-recommendation
color: $green
.red-recommendation
color: $red
.orange-recommendation
color: $orange
.gresearch-recommendation
padding: 6px
background-color: $gresearch-color
border-radius: 50%

.green-tooltip
.tooltip-inner
background-color: $green
.red-tooltip
.tooltip-inner
background-color: $red
.orange-tooltip
.tooltip-inner
background-color: $orange
.gresearch-tooltip
.tooltip-inner
background-color: $gresearch-color
.fsdocs-source-link
float: right
text-decoration: none
Expand Down
6 changes: 5 additions & 1 deletion docs/.style/variables.sass
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ $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
$orange: #F5BF4F
$red: #EA7268
$gresearch-color: #00A8E2
$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
5 changes: 5 additions & 0 deletions docs/_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
document.getElementById(e.target.id+'-wrapper').classList.add('menu-open');
}
})

</script>
<!-- BEGIN SEARCH BOX: this adds support for the search box -->
<link rel="stylesheet"
Expand All @@ -114,6 +115,10 @@
<script type="text/javascript" src="{{root}}content/fsdocs-search.js"></script>
<!-- END SEARCH BOX: this adds support for the search box -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>
<script>
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))
</script>
<script type="module">
import mermaid from "https://cdn.skypack.dev/mermaid";
mermaid.initialize({
Expand Down
170 changes: 170 additions & 0 deletions docs/docs/end-users/Configuration.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
(**
---
category: End-users
categoryindex: 1
index: 3
---
*)
#r "nuget: Fantomas.Core, 5.0.0-beta-*"
alanlomeli marked this conversation as resolved.
Show resolved Hide resolved

open Fantomas.Core.FormatConfig
open Fantomas.Core
let formatCode input configIndent =
CodeFormatter.FormatDocumentAsync (false, input, configIndent)
|> Async.RunSynchronously

(**
# Configuration
Fantomas ships with a limited series of options.
These can be stored in an [.editorconfig](https://editorconfig.org/) file and will be picked up automatically by the
commandline.
Your IDE should respect your settings, however the implementation of that is editor specific. Setting the configuration via
UI might be available depending on the IDE.
*)

(**
## 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>.
<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.
alanlomeli marked this conversation as resolved.
Show resolved Hide resolved
<i class="bi bi-check-circle-fill green-recommendation" ></i> <strong>Safe to change:</strong> Settings that aren't attached to any guidelines. Depending on your team or your own preferences, feel free to use these as it's been agreed on the codebase, however, you can always use it's defaults.
alanlomeli marked this conversation as resolved.
Show resolved Hide resolved
<i class="bi bi-exclamation-circle-fill orange-recommendation"></i> <strong>Not recommended:</strong> Settings that don't follow any guidelines.
alanlomeli marked this conversation as resolved.
Show resolved Hide resolved
<i class="bi bi-check-circle-fill red-recommendation"></i> <strong>Do not use:</strong> Experimental settings that might not be stable and don't follow any guidelines.
alanlomeli marked this conversation as resolved.
Show resolved Hide resolved
alanlomeli marked this conversation as resolved.
Show resolved Hide resolved

<img class="gresearch-recommendation" src="{{root}}/gresearch.svg" alt="G-Research logo"/> <strong>G-Research:</strong> G-Research styling guide. If you use one of these, for consistency reasons you should use all of them.
*)

(**
## Auxiliary settings
#### <i class="bi bi-check-circle-fill green-recommendation" data-bs-toggle="tooltip" data-bs-custom-class="green-tooltip" data-bs-title="This setting is good to use" ></i> indent_size
alanlomeli marked this conversation as resolved.
Show resolved Hide resolved
alanlomeli marked this conversation as resolved.
Show resolved Hide resolved
` 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 }
formatCode input configIndent
alanlomeli marked this conversation as resolved.
Show resolved Hide resolved
(*** include-it ***)
alanlomeli marked this conversation as resolved.
Show resolved Hide resolved

(**
## 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 orange-recommendation" data-bs-toggle="tooltip" data-bs-custom-class="orange-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 }

(**
## <img class="gresearch-recommendation align-top" data-bs-toggle="tooltip" data-bs-custom-class="gresearch-tooltip" data-bs-title="If you use one of these you should use all G-Research settings for consistency reasons" data-bs-custom-class="orange-tooltip" src="{{root}}/gresearch.svg" alt="G-Research logo"/> G-Research style
#### <i class="bi bi-check-circle-fill orange-recommendation" data-bs-toggle="tooltip" data-bs-custom-class="orange-tooltip" data-bs-title="This setting is not recommended"></i> indent_size
Copy link
Contributor

Choose a reason for hiding this comment

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

@KenBonny don't mind the fsx part, we are using fsdocs.
Everything in between (** and *) will be rendered as Markdown.

We currently need to write a lot of HTML code inside our markdown to show the right icon with a tooltip.
Using a web component, we can wrap all that.
We are most likely going to go with lit.
Cook some components up and then place the HTML with something like <fantomas-icon></fantomas-icon>.

` 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-custom-class="red-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 }

formatCode input configIndent
Loading