@@ -7,9 +7,20 @@ open Fun.Build
77
88let root = __ SOURCE_ DIRECTORY__
99
10- /// A shallow clone of dotnet/fsharp main. It is git-ignored; the docs are generated from its
11- /// ` docs ` folder and from the FSharp.Compiler.Service it builds.
12- let fsharpDir = Path.Combine( root, " fsharp" )
10+ /// Set this to the path of an existing dotnet/fsharp checkout to generate the docs from it
11+ /// instead of the shallow clone the pipeline makes. Handy when iterating on docs changes in
12+ /// a local fork: the clone stage is skipped and the checkout is built and read in place.
13+ let fsharpRepoEnvVar = " FSHARP_REPO"
14+
15+ /// The dotnet/fsharp checkout the docs are generated from: its ` docs ` folder and the
16+ /// FSharp.Compiler.Service it builds. By default a git-ignored shallow clone of main.
17+ let fsharpRepo = Environment.GetEnvironmentVariable fsharpRepoEnvVar
18+
19+ let fsharpDir =
20+ if String.IsNullOrEmpty fsharpRepo then
21+ Path.Combine( root, " fsharp" )
22+ else
23+ Path.GetFullPath fsharpRepo
1324
1425/// The SDK bootstrap script dotnet/fsharp ships. It runs its arguments with the exact SDK that
1526/// ` fsharp/global.json ` asks for, installing it under ` fsharp/.dotnet ` first when this machine
@@ -25,7 +36,13 @@ let cloneStage =
2536 stage " clone fsharp" {
2637 run ( fun ctx ->
2738 async {
28- if Directory.Exists fsharpDir then
39+ if not ( String.IsNullOrEmpty fsharpRepo) then
40+ if Directory.Exists fsharpDir then
41+ printfn $" Using the dotnet/fsharp checkout at {fsharpDir} ({fsharpRepoEnvVar})."
42+ return Ok()
43+ else
44+ return Error $" {fsharpRepoEnvVar} points to {fsharpDir}, which does not exist."
45+ elif Directory.Exists fsharpDir then
2946 printfn " fsharp/ already exists, not cloning. Delete it to start from a fresh checkout."
3047 return Ok()
3148 else
@@ -47,10 +64,16 @@ let restoreStage =
4764
4865/// fsdocs targets a fixed .NET runtime. Let it run on whatever newer runtime the machine has,
4966/// prereleases included, so the SDK dotnet/fsharp needs is also enough to run the tool.
67+ /// FSHARP_REPO is passed on so FSharp.Compiler.Service.fsproj resolves the assembly from the
68+ /// same checkout.
5069let fsdocsEnv =
51- [ " DOTNET_ROLL_FORWARD" , " LatestMajor" ; " DOTNET_ROLL_FORWARD_TO_PRERELEASE" , " 1" ]
70+ [ " DOTNET_ROLL_FORWARD" , " LatestMajor"
71+ " DOTNET_ROLL_FORWARD_TO_PRERELEASE" , " 1"
72+ fsharpRepoEnvVar, fsharpDir ]
5273
53- let fsdocsArgs = " --eval --sourcefolder fsharp --input fsharp/docs"
74+ let fsdocsArgs =
75+ let docsDir = Path.Combine( fsharpDir, " docs" )
76+ $" --eval --sourcefolder \" {fsharpDir}\" --input \" {docsDir}\" "
5477
5578pipeline " Build" {
5679 description " Clone dotnet/fsharp, build FSharp.Compiler.Service and generate the docs into output/."
@@ -60,7 +83,15 @@ pipeline "Build" {
6083 restoreStage
6184 stage " docs" {
6285 envVars fsdocsEnv
63- run $" dotnet fsdocs build {fsdocsArgs}"
86+ // fsdocs caches the cracked project, including the FSharp.Compiler.Service.dll it resolved,
87+ // in .fsdocs/cache and does not notice when FSHARP_REPO changes. Drop it, and pass --clean
88+ // so pages from a previous build against another checkout never linger in output/.
89+ run ( fun _ ->
90+ let cache = Path.Combine( root, " .fsdocs" , " cache" )
91+ // File.Delete tolerates a missing file but not a missing directory, as on a fresh clone.
92+ if File.Exists cache then
93+ File.Delete cache)
94+ run $" dotnet fsdocs build --clean {fsdocsArgs}"
6495 }
6596 runIfOnlySpecified false
6697}
0 commit comments