Skip to content

Commit 606d0c5

Browse files
committed
Improve local doc creation
1 parent 594ad5d commit 606d0c5

File tree

2 files changed

+47
-8
lines changed

2 files changed

+47
-8
lines changed

build.fsx

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ nuget Fake.DotNet.Fsi
1212
nuget Fake.DotNet.NuGet
1313
nuget Fake.DotNet.Testing.Expecto
1414
nuget Fake.Tools.Git
15-
nuget Fake.Api.GitHub //"
15+
nuget Fake.Api.GitHub
16+
nuget System.Runtime.InteropServices.RuntimeInformation //"
1617

1718
#if !FAKE
1819
#load "./.fake/build.fsx/intellisense.fsx"
@@ -28,6 +29,18 @@ open Fake.IO
2829
open Fake.IO.FileSystemOperators
2930
open Fake.IO.Globbing.Operators
3031
open Fake.Tools
32+
open System.Runtime.InteropServices
33+
34+
let openOsSpecificFile path =
35+
if RuntimeInformation.IsOSPlatform(OSPlatform.Windows) then
36+
let psi = new System.Diagnostics.ProcessStartInfo(FileName = path, UseShellExecute = true)
37+
System.Diagnostics.Process.Start(psi) |> ignore
38+
elif RuntimeInformation.IsOSPlatform(OSPlatform.Linux) then
39+
System.Diagnostics.Process.Start("xdg-open", path) |> ignore
40+
elif RuntimeInformation.IsOSPlatform(OSPlatform.OSX) then
41+
System.Diagnostics.Process.Start("open", path) |> ignore
42+
else
43+
invalidOp "Not supported OS platform"
3144

3245
let project = "FSharp.Plotly"
3346

@@ -229,7 +242,14 @@ Target.create "GenerateDocs" (fun _ ->
229242
"fsi"
230243
"--define:RELEASE --define:REFERENCE --define:HELP --exec generate.fsx"
231244

232-
if not result.OK then failwith "error generating docs"
245+
if not result.OK then
246+
failwith "error generating docs"
247+
else
248+
Shell.copyRecursive
249+
(__SOURCE_DIRECTORY__ @@ "packages/formatting/FSharp.Formatting/styles")
250+
"docs/output/content"
251+
true
252+
|> printfn "%A"
233253
)
234254

235255
// --------------------------------------------------------------------------------------
@@ -242,7 +262,7 @@ Target.create "ReleaseDocs" (fun _ ->
242262
let tempDocsDir = "temp/gh-pages"
243263
Shell.cleanDir tempDocsDir |> ignore
244264
Git.Repository.cloneSingleBranch "" (gitHome + "/" + gitName + ".git") "gh-pages" tempDocsDir
245-
Shell.copyRecursive "docs" tempDocsDir true |> printfn "%A"
265+
Shell.copyRecursive "docs/output" tempDocsDir true |> printfn "%A"
246266
Git.Staging.stageAll tempDocsDir
247267
Git.Commit.exec tempDocsDir (sprintf "Update generated documentation for version %s" release.NugetVersion)
248268
Git.Branches.push tempDocsDir
@@ -251,12 +271,23 @@ Target.create "ReleaseDocs" (fun _ ->
251271
Target.create "ReleaseDocsLocal" (fun _ ->
252272
let tempDocsDir = "temp/gh-pages"
253273
Shell.cleanDir tempDocsDir |> ignore
254-
Shell.copyRecursive "docs" tempDocsDir true |> printfn "%A"
274+
Shell.copyRecursive "docs/output" tempDocsDir true |> printfn "%A"
275+
let filesToReplaceIn =
276+
!! (tempDocsDir @@ "*.html")
277+
printfn "%A" filesToReplaceIn
255278
Shell.replaceInFiles
256-
(seq {
257-
yield "href=\"/" + project + "/","href=\""
258-
yield "src=\"/" + project + "/","src=\""})
259-
(Directory.EnumerateFiles tempDocsDir |> Seq.filter (fun x -> x.EndsWith(".html")))
279+
[
280+
"""href="https://muehlhaus.github.io/FSharp.Plotly/""","""href=./"""
281+
"""src="https://muehlhaus.github.io/FSharp.Plotly/""", """src=./"""
282+
".html\"", ".html"
283+
".css\"", ".css"
284+
".jpg\"", ".jpg"
285+
".png\"", ".png"
286+
".svg\"", ".svg"
287+
"tips.js\"", "tips.js"
288+
]
289+
filesToReplaceIn
290+
openOsSpecificFile (tempDocsDir @@ "index.html")
260291
)
261292
Target.create "Release" (fun _ ->
262293
Git.Staging.stageAll ""

build.fsx.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,14 @@ NUGET
508508
System.Reflection.Primitives (>= 4.3)
509509
System.Runtime (>= 4.3)
510510
System.Runtime.Handles (>= 4.3)
511+
System.Runtime.InteropServices.RuntimeInformation (4.3)
512+
runtime.native.System (>= 4.3)
513+
System.Reflection (>= 4.3)
514+
System.Reflection.Extensions (>= 4.3)
515+
System.Resources.ResourceManager (>= 4.3)
516+
System.Runtime (>= 4.3)
517+
System.Runtime.InteropServices (>= 4.3)
518+
System.Threading (>= 4.3)
511519
System.Runtime.InteropServices.WindowsRuntime (4.3)
512520
System.Runtime (>= 4.3)
513521
System.Runtime.Loader (4.3)

0 commit comments

Comments
 (0)