3
3
// --------------------------------------------------------------------------------------
4
4
5
5
#r " paket: groupref FakeBuild //"
6
- open Fake.IO
7
6
8
7
#load " ./.fake/build.fsx/intellisense.fsx"
9
8
@@ -13,10 +12,68 @@ open Fake.Core.TargetOperators
13
12
open Fake.DotNet
14
13
open Fake.IO
15
14
open Fake.IO .FileSystemOperators
15
+ open Fake.IO .Globbing
16
16
open Fake.IO .Globbing .Operators
17
17
open Fake.DotNet .Testing
18
18
open Fake.Tools
19
19
open Fake.Api
20
+ open Fake.Tools .Git
21
+
22
+ [<AutoOpen>]
23
+ module TemporaryDocumentationHelpers =
24
+
25
+ type LiterateArguments =
26
+ { ToolPath : string
27
+ Source : string
28
+ OutputDirectory : string
29
+ Template : string
30
+ ProjectParameters : ( string * string ) list
31
+ LayoutRoots : string list
32
+ FsiEval : bool }
33
+
34
+
35
+ let private run toolPath command =
36
+ if 0 <> Process.execSimple (( fun info ->
37
+ { info with
38
+ FileName = toolPath
39
+ Arguments = command }) >> Process.withFramework) System.TimeSpan.MaxValue
40
+
41
+ then failwithf " FSharp.Formatting %s failed." command
42
+
43
+ let createDocs p =
44
+ let toolPath = Tools.findToolInSubPath " fsformatting.exe" ( Directory.GetCurrentDirectory() @@ " lib/Formatting" )
45
+
46
+ let defaultLiterateArguments =
47
+ { ToolPath = toolPath
48
+ Source = " "
49
+ OutputDirectory = " "
50
+ Template = " "
51
+ ProjectParameters = []
52
+ LayoutRoots = []
53
+ FsiEval = false }
54
+
55
+ let arguments = ( p: LiterateArguments-> LiterateArguments) defaultLiterateArguments
56
+ let layoutroots =
57
+ if arguments.LayoutRoots.IsEmpty then []
58
+ else [ " --layoutRoots" ] @ arguments.LayoutRoots
59
+ let source = arguments.Source
60
+ let template = arguments.Template
61
+ let outputDir = arguments.OutputDirectory
62
+ let fsiEval = if arguments.FsiEval then [ " --fsieval" ] else []
63
+
64
+ let command =
65
+ arguments.ProjectParameters
66
+ |> Seq.map ( fun ( k , v ) -> [ k; v ])
67
+ |> Seq.concat
68
+ |> Seq.append
69
+ ([ " literate" ; " --processdirectory" ] @ layoutroots @ [ " --inputdirectory" ; source; " --templatefile" ; template;
70
+ " --outputDirectory" ; outputDir] @ fsiEval @ [ " --replacements" ])
71
+ |> Seq.map ( fun s ->
72
+ if s.StartsWith " \" " then s
73
+ else sprintf " \" %s \" " s)
74
+ |> String.separated " "
75
+ run arguments.ToolPath command
76
+ printfn " Successfully generated docs for %s " source
20
77
21
78
// --------------------------------------------------------------------------------------
22
79
// START TODO: Provide project-specific details below
@@ -319,20 +376,43 @@ Target.create "Docs" (fun _ ->
319
376
| Some lang -> layoutRootsAll.[ lang]
320
377
| None -> layoutRootsAll.[ " en" ] // "en" is the default language
321
378
322
- FSFormatting. createDocs ( fun args ->
379
+ createDocs ( fun args ->
323
380
{ args with
324
381
Source = content
325
382
OutputDirectory = output
326
383
LayoutRoots = layoutRoots
327
384
ProjectParameters = ( " root" , root):: info
328
- Template = docTemplate } )
385
+ Template = docTemplate
386
+ FsiEval = true
387
+ } )
329
388
)
330
389
331
390
// --------------------------------------------------------------------------------------
332
391
// Release Scripts
333
392
393
+
334
394
//#load "paket-files/fsharp/FAKE/modules/Octokit/Octokit.fsx"
335
395
//open Octokit
396
+ Target.create " ReleaseDocs" ( fun _ ->
397
+ let tempDocsDir = " temp/gh-pages"
398
+ Shell.cleanDir tempDocsDir |> ignore
399
+ Git.Repository.cloneSingleBranch " " ( gitHome + " /" + gitName + " .git" ) " gh-pages" tempDocsDir
400
+ Shell.copyRecursive " docs" tempDocsDir true |> printfn " %A "
401
+ Git.Staging.stageAll tempDocsDir
402
+ Git.Commit.exec tempDocsDir ( sprintf " Update generated documentation for version %s " release.NugetVersion)
403
+ Git.Branches.push tempDocsDir
404
+ )
405
+
406
+ Target.create " ReleaseLocal" ( fun _ ->
407
+ let tempDocsDir = " temp/gh-pages"
408
+ Shell.cleanDir tempDocsDir |> ignore
409
+ Shell.copyRecursive " docs" tempDocsDir true |> printfn " %A "
410
+ Shell.replaceInFiles
411
+ ( seq {
412
+ yield " href=\" /" + project + " /" , " href=\" "
413
+ yield " src=\" /" + project + " /" , " src=\" " })
414
+ ( Directory.EnumerateFiles tempDocsDir |> Seq.filter ( fun x -> x.EndsWith( " .html" )))
415
+ )
336
416
337
417
Target.create " Release" ( fun _ ->
338
418
// not fully converted from FAKE 4
@@ -400,16 +480,16 @@ Target.create "All" ignore
400
480
==> " Build"
401
481
==> " CopyBinaries"
402
482
==> " RunTests"
403
- // ==> "GenerateDocs"
483
+ ==> " GenerateDocs"
404
484
==> " NuGet"
405
485
==> " All"
406
486
407
487
" RunTests" ?=> " CleanDocs"
408
488
409
489
" CleanDocs"
410
490
==> " Docs"
411
- // ==> "ReferenceDocs"
412
- // ==> "GenerateDocs"
491
+ ==> " ReferenceDocs"
492
+ ==> " GenerateDocs"
413
493
414
494
" Clean"
415
495
==> " Release"
@@ -418,6 +498,11 @@ Target.create "All" ignore
418
498
==> " PublishNuget"
419
499
==> " Release"
420
500
501
+ " GenerateDocs"
502
+ ==> " ReleaseDocs"
503
+
504
+ " All"
505
+ ==> " ReleaseLocal"
421
506
422
507
" Clean"
423
508
==> " AssemblyInfo"
@@ -427,4 +512,4 @@ Target.create "All" ignore
427
512
==> " NuGet"
428
513
==> " GitReleaseNuget"
429
514
430
- Target.runOrDefault " All"
515
+ Target.runOrDefaultWithArguments " All"
0 commit comments