Skip to content

Commit a1df296

Browse files
[Repo Assist] Fix script warnings and add CheckDocScripts to Verify pipeline (#1083)
* Fix script warnings and add CheckDocScripts to Verify pipeline - Fix FS0760 IDisposable warnings in docs/evaluation.fsx by using 'new FsiEvaluator()' constructor syntax (two occurrences) - Improve error message in ParseScript when type errors are found in a script file (now includes the file path) - Add CheckDocScripts stage to the Verify pipeline in build.fsx so that 'dotnet fsi build.fsx -- -p Verify' also type-checks docs scripts with --strict, catching errors locally before CI The full CI pipeline already ran 'fsdocs build --strict' in the GenerateDocs stage (permanent check). The new CheckDocScripts stage makes the same check available via the lighter-weight Verify pipeline. Closes #1081 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: trigger checks * feat: run CheckDocScripts stage on Windows too Remove the 'whenNot Windows' guard and use System.OperatingSystem.IsWindows() to select the correct binary extension (fsdocs.exe on Windows, fsdocs on Unix). This means the Verify pipeline now type-checks documentation scripts on all platforms. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: trigger checks * build: add CheckDocScripts to CI pipeline Move fsdocsLocalBin/checkDocScriptsStage definitions before the CI pipeline and include the stage in CI (after Tests, before GenerateDocs). This ensures doc-script type errors are caught on all CI runners, not only when running the Verify pipeline locally. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: trigger checks * chore: remove changelog entries from RELEASE_NOTES.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: trigger checks --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a7b9e55 commit a1df296

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

build.fsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ let testStage =
4949
$"dotnet test {solutionFile} --configuration {configuration} --no-build --blame --logger trx --results-directory TestResults -tl"
5050
}
5151

52+
// Standalone doc-script type-check using the locally built fsdocs tool.
53+
// Assumes the solution has been built (e.g. after running the CI pipeline or
54+
// `dotnet build`). Catches type errors in .fsx documentation sources early,
55+
// matching the `--strict` check in the full GenerateDocs stage.
56+
let fsdocsLocalBin =
57+
let ext = if System.OperatingSystem.IsWindows() then ".exe" else ""
58+
$"src/fsdocs-tool/bin/Release/net10.0/fsdocs{ext}"
59+
60+
let checkDocScriptsStage =
61+
stage "CheckDocScripts" { run $"\"{fsdocsLocalBin}\" build --strict --clean --properties Configuration=Release" }
62+
5263
pipeline "CI" {
5364
lintStage
5465

@@ -68,6 +79,8 @@ pipeline "CI" {
6879

6980
testStage
7081

82+
checkDocScriptsStage
83+
7184
stage "GenerateDocs" {
7285
// Skip on Windows CI runners: docs are only deployed from Linux
7386
whenNot { envVar "RUNNER_OS" "Windows" }
@@ -92,6 +105,7 @@ pipeline "Verify" {
92105
lintStage
93106
testStage
94107
stage "Analyzers" { run "dotnet msbuild /t:AnalyzeSolution" }
108+
checkDocScriptsStage
95109
runIfOnlySpecified true
96110
}
97111

docs/evaluation.fsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ let a = 10
158158
(*** include-value:a ***)"""
159159

160160
// Create evaluator and parse script
161-
let fsi = FsiEvaluator()
161+
let fsi = new FsiEvaluator()
162162

163163
let doc = Literate.ParseScriptString(content, fsiEvaluator = fsi)
164164

@@ -192,7 +192,7 @@ This can be done by calling `cref:M:FSharp.Formatting.Literate.Evaluation.FsiEva
192192
193193
*)
194194
// Create evaluator & register simple formatter for lists
195-
let fsiEvaluator = FsiEvaluator()
195+
let fsiEvaluator = new FsiEvaluator()
196196

197197
fsiEvaluator.RegisterTransformation(fun (o, ty, _executionCount) ->
198198
// If the type of value is an F# list, format it nicely

src/FSharp.Formatting.Literate/ParseScript.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,14 +370,14 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
370370
let sourceSnippets, diagnostics =
371371
CodeFormatter.ParseAndCheckSource(filePath, content, ctx.CompilerOptions, defines, onError)
372372

373-
let mutable fail = false
373+
let mutable hasErrors = false
374374

375375
for (SourceError((l0, c0), (l1, c1), kind, msg)) in diagnostics do
376376
printfn
377377
" %s: %s(%d,%d)-(%d,%d) %s"
378378
filePath
379379
(if kind = ErrorKind.Error then
380-
fail <- true
380+
hasErrors <- true
381381
"error"
382382
else
383383
"warning")
@@ -387,8 +387,8 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
387387
c1
388388
msg
389389

390-
if fail then
391-
ctx.OnError "errors parsing or checking script"
390+
if hasErrors then
391+
ctx.OnError(sprintf "errors found in '%s'" filePath)
392392

393393
let parsedBlocks =
394394
[ for Snippet(name, lines) in sourceSnippets do

0 commit comments

Comments
 (0)