Skip to content

Commit

Permalink
mandatory Fantomas formatting commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorium committed Mar 15, 2024
1 parent 495bc37 commit c4f4e0d
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/Common/Collections.fs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module internal List =
f x
g ()
iterInterleaved f g (y :: tl)
| [x] -> f x
| [ x ] -> f x
| [] -> ()

/// Tests whether a list starts with the elements of another
Expand Down
20 changes: 13 additions & 7 deletions src/Common/StringParsing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ module String =
/// Matches when a string is a whitespace or null
[<return: Struct>]
let (|WhiteSpace|_|) (s) =
if String.IsNullOrWhiteSpace(s) then ValueSome() else ValueNone
if String.IsNullOrWhiteSpace(s) then
ValueSome()
else
ValueNone

/// Returns a string trimmed from both start and end
let (|TrimBoth|) (text: string) = text.Trim()
Expand Down Expand Up @@ -118,12 +121,15 @@ module String =

module StringPosition =
/// Matches when a string is a whitespace or null
[<return:Struct>]
[<return: Struct>]
let (|WhiteSpace|_|) (s, _n: MarkdownRange) =
if String.IsNullOrWhiteSpace(s) then ValueSome() else ValueNone
if String.IsNullOrWhiteSpace(s) then
ValueSome()
else
ValueNone

/// Matches when a string does starts with non-whitespace
[<return:Struct>]
[<return: Struct>]
let (|Unindented|_|) (s: string, _n: MarkdownRange) =
if not (String.IsNullOrWhiteSpace(s)) && s.TrimStart() = s then
ValueSome()
Expand Down Expand Up @@ -177,7 +183,7 @@ module StringPosition =
StartColumn = n.StartColumn + text.Length - trimmed.Length })

/// Matches when a string starts with any of the specified sub-strings
[<return:Struct>]
[<return: Struct>]
let (|StartsWithAny|_|) (starts: string seq) (text: string, _n: MarkdownRange) =
if starts |> Seq.exists (fun s -> text.StartsWith(s, StringComparison.Ordinal)) then
ValueSome()
Expand Down Expand Up @@ -301,7 +307,7 @@ module StringPosition =

/// Matches when a string consists of some number of
/// complete repetitions of a specified sub-string.
[<return:Struct>]
[<return: Struct>]
let (|EqualsRepeated|_|) (repeated, _n: MarkdownRange) =
function
| StartsWithRepeated repeated (_n, (v, _)) when (String.IsNullOrWhiteSpace v) -> ValueSome()
Expand Down Expand Up @@ -409,7 +415,7 @@ module Lines =
lines
// first remove all whitespace on the beginning of the line
// then remove all additional spaces at the end, but keep two spaces if existent
|> List.map (fun (StringPosition.TrimStart (s, n)) ->
|> List.map (fun (StringPosition.TrimStart(s, n)) ->
let endsWithTwoSpaces = s.EndsWith(" ", StringComparison.Ordinal)

let trimmed = s.TrimEnd([| ' ' |]) + if endsWithTwoSpaces then " " else ""
Expand Down
14 changes: 7 additions & 7 deletions src/FSharp.Formatting.ApiDocs/GenerateModel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module internal Utils =
else
None

[<return:Struct>]
[<return: Struct>]
let (|MeasureOne|_|) (typ: FSharpType) =
if
typ.HasTypeDefinition
Expand Down Expand Up @@ -1758,7 +1758,7 @@ module internal SymbolReader =
[ let mutable line = ""

while (line <- reader.ReadLine()
not(isNull line)) do
not (isNull line)) do
yield line ]

String.removeSpaces lines
Expand Down Expand Up @@ -1906,14 +1906,14 @@ module internal SymbolReader =
let name = elem.Attribute(XName.Get "name")
let nameAsHtml = HttpUtility.HtmlEncode name.Value

if not(isNull name) then
if not (isNull name) then
html.AppendFormat("<span class=\"fsdocs-param-name\">{0}</span>", nameAsHtml)
|> ignore
| "see"
| "seealso" ->
let cref = elem.Attribute(XName.Get "cref")

if not(isNull cref) then
if not (isNull cref) then
if System.String.IsNullOrEmpty(cref.Value) || cref.Value.Length < 3 then
printfn "ignoring invalid cref specified in: %A" e

Expand Down Expand Up @@ -2019,7 +2019,7 @@ module internal SymbolReader =
let remarks =
let remarkNodes = doc.Elements(XName.Get "remarks") |> Seq.toList

if not(List.isEmpty remarkNodes) then
if not (List.isEmpty remarkNodes) then
let html = new StringBuilder()

for (id, e) in List.indexed remarkNodes do
Expand Down Expand Up @@ -2054,7 +2054,7 @@ module internal SymbolReader =
[ for e in exceptionNodes do
let cref = e.Attribute(XName.Get "cref")

if not(isNull cref) then
if not (isNull cref) then
if String.IsNullOrEmpty(cref.Value) || cref.Value.Length < 3 then
printfn "Warning: Invalid cref specified in: %A" doc

Expand Down Expand Up @@ -2822,7 +2822,7 @@ module internal SymbolReader =
[ for e in doc.Descendants(XName.Get "member") do
let attr = e.Attribute(XName.Get "name")

if (not(isNull attr)) && not (String.IsNullOrEmpty(attr.Value)) then
if (not (isNull attr)) && not (String.IsNullOrEmpty(attr.Value)) then
yield attr.Value, e ] do
// NOTE: We completely ignore duplicate keys and I don't see
// an easy way to detect where "value" is coming from, because the entries
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Formatting.CodeFormat/CodeFormatAgent.fs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ module CodeFormatter =
[| let line = ref ""

while (line := reader.ReadLine()
not(isNull line.Value)) do
not (isNull line.Value)) do
yield line.Value |]
// Get options for a standalone script file (this adds some
// default references and doesn't require full project information)
Expand Down
3 changes: 1 addition & 2 deletions src/FSharp.Formatting.Common/Templating.fs
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,7 @@ module internal SimpleTemplating =
| true, lookupContent -> lookupContent
| false, _ -> "")
+ (match lookup.TryGetValue ParamKeys.``fsdocs-tooltips`` with
| true, lookupTips ->
"\n\n" + lookupTips
| true, lookupTips -> "\n\n" + lookupTips
| false, _ -> "")
| Some templateText -> ApplySubstitutionsInText substitutions templateText

Expand Down
8 changes: 3 additions & 5 deletions src/FSharp.Formatting.Common/YaafFSharpScripting.fs
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,8 @@ module internal CompilerServiceExtensions =
|> List.map (fun file ->
file,
(match referenceDict.TryGetValue file with
| true, refFile ->
Some refFile
| false, _ ->
None))
| true, refFile -> Some refFile
| false, _ -> None))

let getProjectReferencesSimple frameworkVersion (dllFiles: string list) =
getProjectReferences frameworkVersion None None dllFiles |> resolve dllFiles
Expand Down Expand Up @@ -465,7 +463,7 @@ module internal ArgParser =
else
None

[<return:Struct>]
[<return: Struct>]
let (|FsiBoolArg|_|) argName s =
match s with
| StartsWith argName rest ->
Expand Down
7 changes: 4 additions & 3 deletions src/FSharp.Formatting.Literate/ParseScript.fs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
| Command "condition" name when not (String.IsNullOrWhiteSpace name) -> { Condition = Some name }
| _ -> { Condition = None }

[<return:Struct>]
let (|EmptyString|_|) (v: string) = if v.Length = 0 then ValueSome() else ValueNone
[<return: Struct>]
let (|EmptyString|_|) (v: string) =
if v.Length = 0 then ValueSome() else ValueNone

/// Transform list of code blocks (snippet/comment/command)
/// into a formatted Markdown document, with link definitions
Expand Down Expand Up @@ -387,7 +388,7 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =

let parsedBlocks =
[ for Snippet(name, lines) in sourceSnippets do
if not(isNull name) then
if not (isNull name) then
yield BlockComment("## " + name)

yield! parseScriptFile (lines) ]
Expand Down
3 changes: 1 addition & 2 deletions src/FSharp.Formatting.Literate/Transformations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ module internal Transformations =
|> Array.toList
|> String.removeSpaces
|> String.concat "\n"
| _ ->
code
| _ -> code

let lang =
match language with
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Formatting.Markdown/Markdown.fs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type Markdown internal () =
let mutable lineNo = 1

while (line := reader.ReadLine()
not(isNull line.Value)) do
not (isNull line.Value)) do
yield
(line.Value,
{ StartLine = lineNo
Expand Down
2 changes: 1 addition & 1 deletion src/fsdocs-tool/ProjectCracker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ module DotNetCli =

module Crack =

[<return:Struct>]
[<return: Struct>]
let (|ConditionEquals|_|) (str: string) (arg: string) =
if System.String.Compare(str, arg, System.StringComparison.OrdinalIgnoreCase) = 0 then
ValueSome()
Expand Down

0 comments on commit c4f4e0d

Please sign in to comment.