Skip to content

Commit

Permalink
Drop Experimental prefix from ExperimentalStroustrup. (#2755)
Browse files Browse the repository at this point in the history
* Remove experimental prefix from stroustrup bracket style

* Update docs

* Remove experimental_stroustrup, Configuration.fsx tweaks.

---------

Co-authored-by: nojaf <[email protected]>
  • Loading branch information
josh-degraw and nojaf authored Feb 1, 2023
1 parent 8e17261 commit ea9fdfe
Show file tree
Hide file tree
Showing 31 changed files with 101 additions and 94 deletions.
94 changes: 50 additions & 44 deletions docs/docs/end-users/Configuration.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ Your IDE should respect your settings, however the implementation of that is edi
UI might be available depending on the IDE.
*)

#r "../../../src/Fantomas/bin/Release/net6.0/Fantomas.FCS.dll"
#r "../../../src/Fantomas/bin/Release/net6.0/Fantomas.Core.dll"

printf $"version: {Fantomas.Core.CodeFormatter.GetVersion()}"
(*** include-output ***)

(**
## Usage
Inside .editorconfig you can specify the file extension and code location to be use per config:
Expand All @@ -28,7 +34,7 @@ fsharp_bar_before_discriminated_union_declaration = true
#\ Apply specific settings for a targeted subfolder
[src/Elmish/View.fs]
fsharp_multiline_bracket_style = experimental_stroustrup
fsharp_multiline_bracket_style = stroustrup
```
*)

Expand All @@ -39,13 +45,13 @@ You can quickly try your settings via the <a href="https://fsprojects.github.io/
<img src="{{root}}/online_tool_usage.gif" alt="drawing" width="100%"/>
*)

#r "nuget: Fantomas.Core, 5.2.0-alpha-012"

open Fantomas.Core.FormatConfig
open Fantomas.Core

let formatCode input configIndent =
CodeFormatter.FormatDocumentAsync(false, input, configIndent)
async {
let! result = CodeFormatter.FormatDocumentAsync(false, input, configIndent)
printf $"%s{result.Code}"
}
|> Async.RunSynchronously

(**
Expand All @@ -63,7 +69,7 @@ However, there are settings that we do not recommend and generally should not be
<fantomas-setting name="indent_size" orange></fantomas-setting>
` indent_size` has to be between 1 and 10.
`indent_size` has to be between 1 and 10.
This preference sets the indentation
The common values are 2 and 4.
Expand All @@ -87,7 +93,7 @@ formatCode
"""
{ FormatConfig.Default with
IndentSize = 2 }
(*** include-it ***)
(*** include-output ***)
(**
<fantomas-setting name="max_line_length" green></fantomas-setting>
Expand All @@ -105,7 +111,7 @@ formatCode
"""
{ FormatConfig.Default with
MaxLineLength = 60 }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="end_of_line" green></fantomas-setting>
Expand All @@ -130,7 +136,7 @@ formatCode
"""
{ FormatConfig.Default with
InsertFinalNewline = false }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_space_before_parameter" orange></fantomas-setting>
Expand All @@ -148,7 +154,7 @@ formatCode
"""
{ FormatConfig.Default with
SpaceBeforeParameter = false }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_space_before_lowercase_invocation" orange></fantomas-setting>
Expand All @@ -169,7 +175,7 @@ match x with
"""
{ FormatConfig.Default with
SpaceBeforeLowercaseInvocation = false }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_space_before_uppercase_invocation" green gr></fantomas-setting>
Expand All @@ -190,7 +196,7 @@ match x with
"""
{ FormatConfig.Default with
SpaceBeforeUppercaseInvocation = true }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_space_before_class_constructor" orange></fantomas-setting>
Expand All @@ -209,7 +215,7 @@ formatCode
{ FormatConfig.Default with
SpaceBeforeClassConstructor = true }

(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_space_before_member" green gr></fantomas-setting>
Expand All @@ -229,7 +235,7 @@ formatCode
"""
{ FormatConfig.Default with
SpaceBeforeMember = true }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_space_before_colon" green></fantomas-setting>
Expand All @@ -247,7 +253,7 @@ formatCode
"""
{ FormatConfig.Default with
SpaceBeforeColon = true }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_space_after_comma" orange></fantomas-setting>
Expand All @@ -264,7 +270,7 @@ formatCode
"""
{ FormatConfig.Default with
SpaceAfterComma = false }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_space_before_semicolon" green gr></fantomas-setting>
Expand All @@ -282,7 +288,7 @@ formatCode
"""
{ FormatConfig.Default with
SpaceBeforeSemicolon = true }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_space_after_semicolon" orange></fantomas-setting>
Expand All @@ -300,7 +306,7 @@ formatCode
"""
{ FormatConfig.Default with
SpaceAfterSemicolon = false }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_space_around_delimiter" orange></fantomas-setting>
Expand All @@ -317,7 +323,7 @@ formatCode
"""
{ FormatConfig.Default with
SpaceAroundDelimiter = false }
(*** include-it ***)
(*** include-output ***)

(**
## Maximum width constraints
Expand All @@ -341,7 +347,7 @@ formatCode
"""
{ FormatConfig.Default with
MaxIfThenShortWidth = 15 }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_max_if_then_else_short_width" green></fantomas-setting>
Expand All @@ -358,7 +364,7 @@ formatCode
"""
{ FormatConfig.Default with
MaxIfThenElseShortWidth = 10 }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_max_infix_operator_expression" green></fantomas-setting>
Expand All @@ -374,7 +380,7 @@ formatCode
"""
{ FormatConfig.Default with
MaxInfixOperatorExpression = 20 }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_max_record_width" green></fantomas-setting>
Expand All @@ -393,7 +399,7 @@ formatCode
"""
{ FormatConfig.Default with
MaxRecordWidth = 20 }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_max_record_number_of_items" green></fantomas-setting>
Expand Down Expand Up @@ -425,7 +431,7 @@ formatCode
{ FormatConfig.Default with
MaxRecordNumberOfItems = 2
RecordMultilineFormatter = MultilineFormatterType.NumberOfItems }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_record_multiline_formatter" green></fantomas-setting>
Expand Down Expand Up @@ -453,7 +459,7 @@ formatCode
"""
{ FormatConfig.Default with
RecordMultilineFormatter = MultilineFormatterType.NumberOfItems }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_max_array_or_list_width" green></fantomas-setting>
Expand All @@ -471,7 +477,7 @@ formatCode
"""
{ FormatConfig.Default with
MaxArrayOrListWidth = 20 }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_max_array_or_list_number_of_items" green></fantomas-setting>
Expand All @@ -491,7 +497,7 @@ formatCode
{ FormatConfig.Default with
MaxArrayOrListNumberOfItems = 2
ArrayOrListMultilineFormatter = MultilineFormatterType.NumberOfItems }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_array_or_list_multiline_formatter" green></fantomas-setting>
Expand All @@ -511,7 +517,7 @@ formatCode
"""
{ FormatConfig.Default with
ArrayOrListMultilineFormatter = MultilineFormatterType.NumberOfItems }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_max_value_binding_width" green></fantomas-setting>
Expand All @@ -530,7 +536,7 @@ formatCode
"""
{ FormatConfig.Default with
MaxValueBindingWidth = 10 }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_max_function_binding_width" green></fantomas-setting>
Expand All @@ -549,7 +555,7 @@ formatCode
"""
{ FormatConfig.Default with
MaxFunctionBindingWidth = 10 }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_max_dot_get_expression_width" green></fantomas-setting>
Expand All @@ -569,14 +575,14 @@ formatCode
"""
{ FormatConfig.Default with
MaxDotGetExpressionWidth = 100 }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_multiline_bracket_style" green gr></fantomas-setting>
`Cramped` The default way in F# to format brackets.
`Aligned` Alternative way of formatting records, arrays and lists. This will align the braces at the same column level.
`ExperimentalStroustrup` Please contribute to [fsprojects/fantomas#1408](https://github.com/fsprojects/fantomas/issues/1408) and engage in [fsharp/fslang-design#706](https://github.com/fsharp/fslang-design/issues/706).
`Stroustrup` Allow for easier reordering of members and keeping the code succinct.
Default = Cramped.
*)
Expand Down Expand Up @@ -606,7 +612,7 @@ formatCode
"""
{ FormatConfig.Default with
MultilineBracketStyle = Aligned }
(*** include-it ***)
(*** include-output ***)

formatCode
"""
Expand All @@ -632,8 +638,8 @@ formatCode
(19, 20, 21) |]
"""
{ FormatConfig.Default with
MultilineBracketStyle = ExperimentalStroustrup }
(*** include-it ***)
MultilineBracketStyle = Stroustrup }
(*** include-output ***)

(**
## G-Research style
Expand All @@ -657,7 +663,7 @@ type Range =
"""
{ FormatConfig.Default with
NewlineBetweenTypeDefinitionAndMembers = true }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_align_function_signature_to_indentation" green gr></fantomas-setting>
Expand All @@ -679,7 +685,7 @@ let run
"""
{ FormatConfig.Default with
AlignFunctionSignatureToIndentation = true }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_alternative_long_member_definitions" green gr></fantomas-setting>
Expand Down Expand Up @@ -712,7 +718,7 @@ type D() =
"""
{ FormatConfig.Default with
AlternativeLongMemberDefinitions = true }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_multi_line_lambda_closing_newline" green gr></fantomas-setting>
Expand Down Expand Up @@ -740,7 +746,7 @@ let printListWithOffset a list1 =
"""
{ FormatConfig.Default with
MultiLineLambdaClosingNewline = true }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_experimental_keep_indent_in_branch" orange gr></fantomas-setting>
Expand Down Expand Up @@ -770,7 +776,7 @@ let main argv =
"""
{ FormatConfig.Default with
ExperimentalKeepIndentInBranch = true }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_bar_before_discriminated_union_declaration" green gr></fantomas-setting>
Expand All @@ -788,7 +794,7 @@ formatCode
{ FormatConfig.Default with
BarBeforeDiscriminatedUnionDeclaration = true }

(*** include-it ***)
(*** include-output ***)

(**
## Other
Expand Down Expand Up @@ -822,7 +828,7 @@ formatCode
"""
{ FormatConfig.Default with
BlankLinesAroundNestedMultilineExpressions = false }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_keep_max_number_of_blank_lines" green></fantomas-setting>
Expand All @@ -840,7 +846,7 @@ formatCode
"""
{ FormatConfig.Default with
KeepMaxNumberOfBlankLines = 1 }
(*** include-it ***)
(*** include-output ***)

(**
<fantomas-setting name="fsharp_strict_mode" red></fantomas-setting>
Expand All @@ -867,7 +873,7 @@ formatCode
"""
{ FormatConfig.Default with
StrictMode = true }
(*** include-it ***)
(*** include-output ***)
(**
<fantomas-nav previous="./StyleGuide.html" next="./IgnoreFiles.html"></fantomas-nav>
Expand Down
1 change: 1 addition & 0 deletions fantomas.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{29F22904-C9E0-40AA-B971-9AE377C17F59}"
ProjectSection(SolutionItems) = preProject
docs\index.html = docs\index.html
docs\docs\end-users\Configuration.fsx = docs\docs\end-users\Configuration.fsx
EndProjectSection
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fantomas.Client", "src\Fantomas.Client\Fantomas.Client.fsproj", "{AA895F94-CCF2-4FCF-A9BB-E16987B57535}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@ let ``update record in stroustrup style`` () =
let v = { rainbow with Boss = "Jeffrey" ; Lackeys = [ "Zippy"; "George"; "Bungle" ] }
"""
{ config with
MultilineBracketStyle = ExperimentalStroustrup }
MultilineBracketStyle = Stroustrup }
|> prepend newline
|> should
equal
Expand Down
Loading

0 comments on commit ea9fdfe

Please sign in to comment.