Skip to content

Commit

Permalink
Merge pull request #900 from nojaf/v20-beta
Browse files Browse the repository at this point in the history
v20 beta
  • Loading branch information
nojaf authored Jan 31, 2024
2 parents aed4687 + 7c5c1f1 commit a97ca87
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
]
},
"fsharp-analyzers": {
"version": "0.21.0",
"version": "0.24.0",
"commands": [
"fsharp-analyzers"
]
Expand Down
6 changes: 3 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="Ionide.KeepAChangelog.Tasks" Version="0.1.8" />
<PackageVersion Include="FSharp.Analyzers.Build" Version="0.2.0" />
<PackageVersion Include="G-Research.FSharp.Analyzers" Version="0.5.1" />
<PackageVersion Include="Ionide.Analyzers" Version="0.5.1" />
<PackageVersion Include="FSharp.Analyzers.Build" Version="0.3.0" />
<PackageVersion Include="G-Research.FSharp.Analyzers" Version="0.8.0" />
<PackageVersion Include="Ionide.Analyzers" Version="0.8.0" />
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 20.0.0-beta-001 - 2024-01-31

### Changed
* Marking development of v20 as complete.

## 20.0.0-alpha-019 - 2024-01-29

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<FSharpAnalyzersOtherFlags>--analyzers-path &quot;$(PkgG-Research_FSharp_Analyzers)/analyzers/dotnet/fs&quot;</FSharpAnalyzersOtherFlags>
<FSharpAnalyzersOtherFlags>$(FSharpAnalyzersOtherFlags) --analyzers-path &quot;$(PkgIonide_Analyzers)/analyzers/dotnet/fs&quot;</FSharpAnalyzersOtherFlags>
<FSharpAnalyzersOtherFlags>$(FSharpAnalyzersOtherFlags) --exclude-analyzer PartialAppAnalyzer -c Release</FSharpAnalyzersOtherFlags>
<FSharpAnalyzersOtherFlags>$(FSharpAnalyzersOtherFlags) --exclude-analyzers PartialAppAnalyzer -c Release</FSharpAnalyzersOtherFlags>
<FSharpAnalyzersOtherFlags>$(FSharpAnalyzersOtherFlags) --code-root ../.. --report &quot;../../reports/$(MSBuildProjectName)-$(TargetFramework).sarif&quot;</FSharpAnalyzersOtherFlags>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/FSharp.Formatting.ApiDocs/GenerateModel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@ module internal SymbolReader =
if allLinesHaveSameColumn then
trimmed
else
$"<pre>{trimmed}</pre>"
$"<pre>%s{trimmed}</pre>"

let rec readXmlElementAsHtml
anyTagsOK
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Formatting.Literate/Evaluator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ module __FsiSettings =
StdErr = e.Result.Error.Merged }

let msg =
$"Evaluation failed and --strict is on\n file={file}\n asExpression={asExpression}, text={text}\n stdout={e.Result.Output.Merged}\n\ stderr={e.Result.Error.Merged}\n inner exception={e.InnerException}"
$"Evaluation failed and --strict is on\n file=%A{file}\n asExpression=%b{asExpression}, text=%s{text}\n stdout=%s{e.Result.Output.Merged}\n\ stderr=%s{e.Result.Error.Merged}\n inner exception=%A{e.InnerException}"

onError msg

Expand Down
22 changes: 11 additions & 11 deletions src/FSharp.Formatting.Literate/ParsePynb.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@ module internal ParsePynb =
match this with
| Markdown source -> source
| Code code ->
let codeBlock = sprintf $"```{code.lang}\n{addLineEnd code.source}```"
let codeBlock = sprintf $"```%s{code.lang}\n%s{addLineEnd code.source}```"

match code.outputs with
| None -> codeBlock
| Some outputs ->
let outputsString = outputs |> String.concat "\n"
sprintf $"{codeBlock}\n{outputsString}"
sprintf $"%s{codeBlock}\n%s{outputsString}"

member this.ToFsx() =
match this with
| Markdown source -> $"(**\n{source}\n*)"
| Markdown source -> $"(**\n%s{source}\n*)"
| Code code when code.lang = "fsharp" ->
let codeBlock = addLineEnd code.source

match code.outputs with
| None -> codeBlock
| Some outputs ->
let outputsString = outputs |> String.concat "\n"
sprintf $"{codeBlock}\n(**\n{outputsString}\n*)"
| Code _ -> $"(**\n{this.ToMarkdown()}\n*)"
sprintf $"%s{codeBlock}\n(**\n%s{outputsString}\n*)"
| Code _ -> $"(**\n%s{this.ToMarkdown()}\n*)"

module Output =
let (|TextHtml|_|) (x: JsonElement) =
Expand All @@ -48,14 +48,14 @@ module internal ParsePynb =
|> Seq.map (fun x -> x.GetString().Replace("\r\n", "\n") |> addLineEnd)
|> String.concat ""

Some $"<p>{html}</p>"
Some $"<p>%s{html}</p>"
| _ -> None

let (|TextPlain|_|) (x: JsonElement) =
match x.TryGetProperty("text/plain") with
| true, text ->
let text = text.EnumerateArray() |> Seq.map (fun x -> x.GetString()) |> String.concat ""
Some $"""<table class="pre"><tbody><tr><td><pre><code>{text}</code></pre></td></tr></tbody></table>"""
Some $"""<table class="pre"><tbody><tr><td><pre><code>%s{text}</code></pre></td></tr></tbody></table>"""
| _ -> None

let (|DisplayData|_|) (x: JsonElement) =
Expand All @@ -65,7 +65,7 @@ module internal ParsePynb =
match x.TryGetProperty("data") with
| true, TextHtml html -> html
| true, TextPlain text -> text
| true, s -> failwith $"unknown output {s}"
| true, s -> failwith $"unknown output %A{s}"
| false, _ -> failwith "no data property"
|> Some
else
Expand All @@ -82,7 +82,7 @@ module internal ParsePynb =
| _ -> failwith "no text property"

Some
$"""<table class="pre"><tbody><tr><td><pre><code>{text}</code></pre></td></tr></tbody></table>"""
$"""<table class="pre"><tbody><tr><td><pre><code>%s{text}</code></pre></td></tr></tbody></table>"""
else
None
| _ -> failwith "no output_type property"
Expand All @@ -91,7 +91,7 @@ module internal ParsePynb =
match output with
| Stream stream -> stream
| DisplayData displayData -> displayData
| s -> failwith $"""unknown output {s.GetProperty("output_type").GetString()}"""
| s -> failwith $"""unknown output %s{s.GetProperty("output_type").GetString()}"""

let getSource (cell: JsonElement) =
let source =
Expand Down Expand Up @@ -152,7 +152,7 @@ module internal ParsePynb =
| _, Some _ -> failwith $"Markdown should not have outputs"
| source, None -> Markdown source
| "code" -> getCode cell
| _ -> failwith $"unknown cell type {cell_type}"
| _ -> failwith $"unknown cell type %s{cell_type}"

let pynbStringToMarkdown (ipynb: string) =
let json = JsonDocument.Parse(ipynb)
Expand Down
4 changes: 2 additions & 2 deletions src/FSharp.Formatting.Markdown/MarkdownUtils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ module internal MarkdownUtils =

for (j, line) in List.indexed lines do
if i = 0 && j = 0 then
yield $"{n} " + line
yield $"%i{n} " + line
else
yield " " + line

Expand Down Expand Up @@ -329,7 +329,7 @@ module internal MarkdownUtils =
else
let tempRoot = "fsdocs-secret-temp-root"
// We can't be sure code is a single html element, we could get multiple elements.
let element = XElement.Parse($"<{tempRoot}>{code}</{tempRoot}>")
let element = XElement.Parse($"<%s{tempRoot}>%s{code}</%s{tempRoot}>")
// ends-with is XPath 2.0 only, https://stackoverflow.com/questions/1525299/xpath-and-xslt-2-0-for-net
let attributes =
match System.Xml.XPath.Extensions.XPathEvaluate(element, "//*/@*[contains(., '.md')]") with
Expand Down
12 changes: 6 additions & 6 deletions src/fsdocs-tool/BuildCommand.fs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ type internal DocContent
Some uri
with _ ->
printfn
$"Couldn't map markdown reference {markdownReference} that seemed to correspond to an input file"
$"Couldn't map markdown reference %s{markdownReference} that seemed to correspond to an input file"

None

Expand Down Expand Up @@ -352,7 +352,7 @@ type internal DocContent

let evaluateNotebook ipynbFile =
let args =
$"repl --run {ipynbFile} --default-kernel fsharp --exit-after-run --output-path {ipynbFile}"
$"repl --run %s{ipynbFile} --default-kernel fsharp --exit-after-run --output-path %s{ipynbFile}"

let psi =
ProcessStartInfo(
Expand All @@ -367,8 +367,8 @@ type internal DocContent
p.WaitForExit()
with _ ->
let msg =
$"Failed to evaluate notebook {ipynbFile} using dotnet-repl\n"
+ $"""try running "{args}" at the command line and inspect the error"""
$"Failed to evaluate notebook %s{ipynbFile} using dotnet-repl\n"
+ $"""try running "%s{args}" at the command line and inspect the error"""

failwith msg

Expand All @@ -392,7 +392,7 @@ type internal DocContent
psi.Arguments <- "tool list --global"
p.Start() |> ignore
let og = p.StandardOutput.ReadToEnd()
let output = $"{ol}\n{og}"
let output = $"%s{ol}\n%s{og}"

if not (output.Contains("dotnet-repl")) then
failwith failmsg
Expand All @@ -403,7 +403,7 @@ type internal DocContent

if evaluate then
checkDotnetReplInstall ()
printfn $" evaluating {inputFileFullPath} with dotnet-repl"
printfn $" evaluating %s{inputFileFullPath} with dotnet-repl"
evaluateNotebook inputFileFullPath


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 @@ -459,7 +459,7 @@ module Crack =
projectFiles
|> List.filter (fun s ->
let isFSharpFormattingTestProject =
s.Contains $"FSharp.ApiDocs.Tests{Path.DirectorySeparatorChar}files"
s.Contains $"FSharp.ApiDocs.Tests%c{Path.DirectorySeparatorChar}files"
|| s.EndsWith("FSharp.Formatting.TestHelpers.fsproj", StringComparison.Ordinal)

if isFSharpFormattingTestProject then
Expand Down

0 comments on commit a97ca87

Please sign in to comment.