Skip to content

Commit

Permalink
try apply fantomas formatting to entire codebase (#716)
Browse files Browse the repository at this point in the history
* apply fantomas formatting

* workaround formatting bugs

* address issues arising from fsprojects/fantomas#1941

* simplify code
  • Loading branch information
dsyme authored Nov 1, 2021
1 parent dc23166 commit 81ccfef
Show file tree
Hide file tree
Showing 74 changed files with 16,892 additions and 11,249 deletions.
6 changes: 6 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
"commands": [
"paket"
]
},
"fantomas-tool": {
"version": "4.6.0-alpha-005",
"commands": [
"fantomas"
]
}
}
}
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ end_of_line = lf
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.fs]
fsharp_max_array_or_list_width=120
fsharp_max_infix_operator_expression=80
fsharp_max_value_binding_width=120
99 changes: 57 additions & 42 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,56 +23,58 @@ Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
// Information about the project to be used at NuGet and in AssemblyInfo files
let project = "FSharp.Formatting"

let summary = "A package of libraries for building great F# documentation, samples and blogs"
let summary =
"A package of libraries for building great F# documentation, samples and blogs"

let license = "Apache 2.0 License"

let configuration = DotNet.BuildConfiguration.fromEnvironVarOrDefault "configuration" DotNet.BuildConfiguration.Release
let configuration =
DotNet.BuildConfiguration.fromEnvironVarOrDefault "configuration" DotNet.BuildConfiguration.Release

// Folder to deposit deploy artifacts
let artifactsDir = __SOURCE_DIRECTORY__ @@ "artifacts"

// Read release notes document
let release = ReleaseNotes.load "RELEASE_NOTES.md"

let projectRepo = "https://github.com/fsprojects/FSharp.Formatting"
let projectRepo =
"https://github.com/fsprojects/FSharp.Formatting"

// --------------------------------------------------------------------------------------
// Generate assembly info files with the right version & up-to-date information

Target.create "AssemblyInfo" (fun _ ->
let info = [
AssemblyInfo.Product project
AssemblyInfo.Description summary
AssemblyInfo.Version release.AssemblyVersion
AssemblyInfo.FileVersion release.AssemblyVersion
AssemblyInfo.InformationalVersion release.NugetVersion
AssemblyInfo.Copyright license
]
let info =
[ AssemblyInfo.Product project
AssemblyInfo.Description summary
AssemblyInfo.Version release.AssemblyVersion
AssemblyInfo.FileVersion release.AssemblyVersion
AssemblyInfo.InformationalVersion release.NugetVersion
AssemblyInfo.Copyright license ]

AssemblyInfoFile.createFSharp "src/Common/AssemblyInfo.fs" info
AssemblyInfoFile.createCSharp "src/Common/AssemblyInfo.cs" info

let versionProps =
XElement(XName.Get "Project",
XElement(XName.Get "PropertyGroup",
XElement(
XName.Get "Project",
XElement(
XName.Get "PropertyGroup",
XElement(XName.Get "Version", release.NugetVersion),
XElement(XName.Get "PackageReleaseNotes", String.toLines release.Notes)
)
)
versionProps.Save("version.props")
)

versionProps.Save("version.props"))

// Clean build results
// --------------------------------------------------------------------------------------

Target.create "Clean" (fun _ ->
!! artifactsDir
++ "temp"
|> Shell.cleanDirs
!!artifactsDir ++ "temp" |> Shell.cleanDirs
// in case the above pattern is empty as it only matches existing stuff
["bin"; "temp"; "tests/bin"]
|> Seq.iter Directory.ensure
)
[ "bin"; "temp"; "tests/bin" ]
|> Seq.iter Directory.ensure)

// Build library
// --------------------------------------------------------------------------------------
Expand All @@ -81,8 +83,7 @@ let solutionFile = "FSharp.Formatting.sln"

Target.create "Build" (fun _ ->
solutionFile
|> DotNet.build (fun opts -> { opts with Configuration = configuration } )
)
|> DotNet.build (fun opts -> { opts with Configuration = configuration }))

Target.create "Tests" (fun _ ->
solutionFile
Expand All @@ -93,20 +94,18 @@ Target.create "Tests" (fun _ ->
Framework = Some "net5.0"
Configuration = configuration
ResultsDirectory = Some "TestResults"
Logger = Some "trx"
})
)
Logger = Some "trx" }))

// --------------------------------------------------------------------------------------
// Build a NuGet package

Target.create "NuGet" (fun _ ->
DotNet.pack (fun pack ->
{ pack with
OutputPath = Some artifactsDir
Configuration = configuration
}) solutionFile
)
DotNet.pack
(fun pack ->
{ pack with
OutputPath = Some artifactsDir
Configuration = configuration })
solutionFile)

// Generate the documentation by dogfooding the tools pacakge
// --------------------------------------------------------------------------------------
Expand All @@ -116,25 +115,41 @@ Target.create "GenerateDocs" (fun _ ->
Shell.cleanDir ".packages"
// Τhe tool has been uninstalled when the
// artifacts folder was removed in the Clean target.
DotNet.exec id "tool" ("install --no-cache --version " + release.NugetVersion + " --add-source " + artifactsDir + " --tool-path " + artifactsDir + " FSharp.Formatting.CommandTool") |> ignore
CreateProcess.fromRawCommand (artifactsDir @@ "fsdocs") ["build"; "--strict"; "--clean"; "--properties"; "Configuration=Release"]
DotNet.exec
id
"tool"
("install --no-cache --version "
+ release.NugetVersion
+ " --add-source "
+ artifactsDir
+ " --tool-path "
+ artifactsDir
+ " FSharp.Formatting.CommandTool")
|> ignore

CreateProcess.fromRawCommand
(artifactsDir @@ "fsdocs")
[ "build"
"--strict"
"--clean"
"--properties"
"Configuration=Release" ]
|> CreateProcess.ensureExitCode
|> Proc.run
|> ignore
// DotNet.exec id "fsdocs" "build --strict --clean --properties Configuration=Release" |> ignore
// DotNet.exec id "tool" "uninstall --local FSharp.Formatting.CommandTool" |> ignore
Shell.cleanDir ".packages"
)
Shell.cleanDir ".packages")

Target.create "All" ignore

// clean and recreate assembly inform on release
"Clean"
==> "AssemblyInfo"
==> "Build"
==> "NuGet"
==> "Tests"
==> "GenerateDocs"
==> "All"
==> "AssemblyInfo"
==> "Build"
==> "NuGet"
==> "Tests"
==> "GenerateDocs"
==> "All"

Target.runOrDefault "All"
12 changes: 6 additions & 6 deletions docs/literate.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ F# language.

| Literate Command | Description |
|:-----------------------|:----------------------------|
| `(*** define-output: output-name ***)` | Define a name for the outputs of the preceeding snippet |
| `(*** include-output ***)` | The console output of the preceeding snippet |
| `(*** define-output: output-name ***)` | Define a name for the outputs of the preceding snippet |
| `(*** include-output ***)` | The console output of the preceding snippet |
| `(*** include-output: output-name ***)` | The console output of the snippet (named with define-output) |
| `(*** include-fsi-output ***)` | The F# Interactive output of the preceeding snippet |
| `(*** include-fsi-output ***)` | The F# Interactive output of the preceding snippet |
| `(*** include-fsi-output: output-name ***)` | The F# Interactive output of the snippet (named with define-output) |
| `(*** include-fsi-merged-output ***)` | The merge of console output and F# Interactive output of the preceeding snippet |
| `(*** include-fsi-merged-output ***)` | The merge of console output and F# Interactive output of the preceding snippet |
| `(*** include-fsi-merged-output: output-name ***)` | The merge of console output and F# Interactive output of the snippet (named with define-output) |
| `(*** include-it ***)` | The formatted result of the preceeding snippet |
| `(*** include-it ***)` | The formatted result of the preceding snippet |
| `(*** include-it: output-name ***) ` | The formatted result of the snippet (named with define-output) |
| `(*** include-it-raw ***)` | The unformatted result of the preceeding snippet |
| `(*** include-it-raw ***)` | The unformatted result of the preceding snippet |
| `(*** include-it-raw: output-name ***)` | The unformatted result of the snippet (named with define-output) |
| `(*** include-value: value-name ***)` | The formatted value, an F# identifier name |

Expand Down
2 changes: 0 additions & 2 deletions docs/sidebyside/sidemarkdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,3 @@ code samples:

This snippet is turned into a `pre` element with the
`lang` attribute set to `csharp`.

<br />
Loading

0 comments on commit 81ccfef

Please sign in to comment.